📄 udp.lst
字号:
1 .file "udp.c"
2 __SREG__ = 0x3f
3 __SP_H__ = 0x3e
4 __SP_L__ = 0x3d
5 __CCP__ = 0x34
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
11 .text
12 .Ltext0:
122 .global udp_generate_packet
124 udp_generate_packet:
1:net/udp.c **** /*
2:net/udp.c **** ,-----------------------------------------------------------------------------------------.
3:net/udp.c **** | net/udp
4:net/udp.c **** |-----------------------------------------------------------------------------------------
5:net/udp.c **** | this file implements a very basic udp protocol
6:net/udp.c **** | - ethernet packet generation is done
7:net/udp.c **** | - udp packet is constructed with disabled checksum!
8:net/udp.c **** |
9:net/udp.c **** | Author : Simon Schulz / avr{AT}auctionant.de
10:net/udp.c **** |
11:net/udp.c **** |
12:net/udp.c **** |
13:net/udp.c **** |-----------------------------------------------------------------------------------------
14:net/udp.c **** | License:
15:net/udp.c **** | This program is free software; you can redistribute it and/or modify it under
16:net/udp.c **** | the terms of the GNU General Public License as published by the Free Software
17:net/udp.c **** | Foundation; either version 2 of the License, or (at your option) any later
18:net/udp.c **** | version.
19:net/udp.c **** | This program is distributed in the hope that it will be useful, but
20:net/udp.c **** |
21:net/udp.c **** | WITHOUT ANY WARRANTY;
22:net/udp.c **** |
23:net/udp.c **** | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
24:net/udp.c **** | PURPOSE. See the GNU General Public License for more details.
25:net/udp.c **** |
26:net/udp.c **** | You should have received a copy of the GNU General Public License along with
27:net/udp.c **** | this program; if not, write to the Free Software Foundation, Inc., 51
28:net/udp.c **** | Franklin St, Fifth Floor, Boston, MA 02110, USA
29:net/udp.c **** |
30:net/udp.c **** | http://www.gnu.de/gpl-ger.html
31:net/udp.c **** `-----------------------------------------------------------------------------------------*/
32:net/udp.c **** #include "udp.h"
33:net/udp.c **** //generate an udp packet.
34:net/udp.c **** //
35:net/udp.c **** //usage:
36:net/udp.c **** // - put udp data at position UDP_POS_DATA
37:net/udp.c **** // - call udp_generate_packet with all neccessary fields and
38:net/udp.c **** // datalength=how many databytes to tx
39:net/udp.c **** // - call nic_send_packet(buffer) to TX
40:net/udp.c **** void udp_generate_packet(unsigned char *buffer,
41:net/udp.c **** uint32_t *dest_ip,
42:net/udp.c **** unsigned char *dest_mac, unsigned int source_port,
43:net/udp.c **** unsigned int dest_port, unsigned int data_length){
125 lobal udp_generate_packet
127 udp_generate_packet:
129 0002 5F92 .LM0:
130 0004 6F92 .LFBB1:
131 0006 7F92 push r4
132 0008 8F92 push r5
133 000a 9F92 push r6
134 000c AF92 push r7
135 000e BF92 push r8
136 0010 CF92 push r9
137 0012 DF92 push r10
138 0014 EF92 push r11
139 0016 FF92 push r12
140 0018 0F93 push r13
141 001a 1F93 push r14
142 push r15
143 push r16
144 001c 5C01 push r17
145 001e 522E /* prologue: function */
146 0020 732E /* frame size = 0 */
147 0022 402E movw r10,r24
148 0024 612E mov r5,r18
149 0026 4701 mov r7,r19
44:net/udp.c **** unsigned int dest_port, unsigned int data_length){
45:net/udp.c ****
46:net/udp.c **** //datalength = udpheader + datalen
150 */
151 /* frame size = 0 */
152 0028 88E0 movw r10,r24
153 002a 90E0 mov r5,r18
154 002c 880E mov r7,r19
155 002e 991E mov r4,r16
47:net/udp.c **** int data_length){
48:net/udp.c ****
49:net/udp.c **** //datalength = udpheader + datalen
156 size = 0 */
157 movw r10,r24
158 0030 C501 mov r5,r18
159 0032 E1E1 mov r7,r19
160 0034 EE2E mov r4,r16
161 0036 6401 mov r6,r17
162 0038 0E94 0000 movw r8,r14
50:net/udp.c **** int data_length){
51:net/udp.c ****
52:net/udp.c **** //datalength = udpheader + datalen
163 mov r5,r18
164 mov r7,r19
165 003c F501 mov r4,r16
166 003e 72A2 mov r6,r17
53:net/udp.c **** int data_length){
167 movw r10,r24
168 mov r5,r18
169 0040 53A2 mov r7,r19
54:net/udp.c **** unsigned int dest_port, unsigned int data_length){
170 */
171 /* frame size = 0 */
172 0042 64A2 movw r10,r24
55:net/udp.c **** unsigned int dest_port, unsigned int data_length){
173 r17
174 /* prologue: function */
175 0044 45A2 /* frame size = 0 */
56:net/udp.c **** unsigned int dest_port, unsigned int data_length){
57:net/udp.c ****
58:net/udp.c **** //datalength = udpheader + datalen
176 push r16
177 push r17
178 0046 96A2 /* prologue: function */
59:net/udp.c **** int data_length){
179 3
180 push r14
181 0048 87A2 push r15
60:net/udp.c **** unsigned int dest_port, unsigned int data_length){
61:net/udp.c ****
62:net/udp.c **** //datalength = udpheader + datalen
182
183 push r9
184 004a 10A6 push r10
63:net/udp.c **** int data_length){
185 0:
186 .LFBB1:
187 004c 11A6 push r4
188 push r5
64:net/udp.c **** unsigned int dest_port, unsigned int data_length){
65:net/udp.c ****
66:net/udp.c **** //datalength = udpheader + datalen
67:net/udp.c **** data_length = data_length + 8;
68:net/udp.c ****
69:net/udp.c **** //generate an ip packet (includes ethernet header)
70:net/udp.c **** ip_generate_packet(buffer, dest_ip, dest_mac, source_port, dest_port, IP_PROTOCOL_UDP, data_length
71:net/udp.c ****
72:net/udp.c **** //setup soure/dest port:
73:net/udp.c **** buffer[IP_POS_DATA + 0] = (source_port>>8);
74:net/udp.c **** buffer[IP_POS_DATA + 1] = (source_port );
75:net/udp.c **** buffer[IP_POS_DATA + 2] = ( dest_port>>8);
76:net/udp.c **** buffer[IP_POS_DATA + 3] = ( dest_port );
77:net/udp.c ****
78:net/udp.c **** //setup data length of udp
79:net/udp.c **** buffer[IP_POS_DATA + 4] = (data_length>>8);
80:net/udp.c **** buffer[IP_POS_DATA + 5] = (data_length );
81:net/udp.c ****
82:net/udp.c **** //store checksum: (0x0000 -> checksum disable)
83:net/udp.c **** buffer[IP_POS_DATA + 6] = 0x00;
84:net/udp.c **** buffer[IP_POS_DATA + 7] = 0x00;
85:net/udp.c ****
86:net/udp.c **** //calculate checksum now: (for ip header + udp header + data !!!
87:net/udp.c **** //add pseudo header (sourceip+targetip + 0x00 + PROTOCOL + LEN) after udp data:
88:net/udp.c ****
89:net/udp.c **** /* if (IP_POS_DATA+data_length+12 > 600){
90:net/udp.c **** //no more space -> send 0x0000 as checksum -> checksum=off
91:net/udp.c **** res16 = 0x0000;
92:net/udp.c **** }else{
93:net/udp.c **** //enough space to add checksum:
94:net/udp.c **** if ((IP_POS_DATA+data_length)&0x01){
95:net/udp.c **** //add 1byte padding
96:net/udp.c **** buffer[IP_POS_DATA+data_length] = 0x00;
97:net/udp.c **** data_length++;
98:net/udp.c **** }
99:net/udp.c ****
100:net/udp.c **** //add source+dest ip:
101:net/udp.c **** nic_ip_to_buffer(&buffer[IP_POS_DATA+data_length+4], *dest_ip);
189 dp_generate_packet:
191 004e 1F91 .LM0:
192 0050 0F91 .LFBB1:
193 0052 FF90 push r4
194 0054 EF90 push r5
195 0056 DF90 push r6
196 0058 CF90 push r7
197 005a BF90 push r8
198 005c AF90 push r9
199 005e 9F90 push r10
200 0060 8F90 push r11
201 0062 7F90 push r12
202 0064 6F90 push r13
203 0066 5F90 push r14
204 0068 4F90 push r15
205 006a 0895 push r16
206 push r17
207 /* prologue: function */
208 /* frame size = 0 */
209 movw r10,r24
DEFINED SYMBOLS
*ABS*:00000000 udp.c
C:\DOCUME~1\ESERVIS\USTAWI~1\Temp/ccVIT8d5.s:2 *ABS*:0000003f __SREG__
C:\DOCUME~1\ESERVIS\USTAWI~1\Temp/ccVIT8d5.s:3 *ABS*:0000003e __SP_H__
C:\DOCUME~1\ESERVIS\USTAWI~1\Temp/ccVIT8d5.s:4 *ABS*:0000003d __SP_L__
C:\DOCUME~1\ESERVIS\USTAWI~1\Temp/ccVIT8d5.s:5 *ABS*:00000034 __CCP__
C:\DOCUME~1\ESERVIS\USTAWI~1\Temp/ccVIT8d5.s:6 *ABS*:00000000 __tmp_reg__
C:\DOCUME~1\ESERVIS\USTAWI~1\Temp/ccVIT8d5.s:7 *ABS*:00000001 __zero_reg__
C:\DOCUME~1\ESERVIS\USTAWI~1\Temp/ccVIT8d5.s:124 .text:00000000 udp_generate_packet
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
ip_generate_packet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -