?? udp.lst
字號(hào):
80 =2 };
81 =2
82 =2 struct tcp { uint EtherHead[9];
83 =2 uint IpHead[10];
C51 COMPILER V7.06 UDP 07/10/2003 14:34:43 PAGE 14
84 =2 uint SourcePort; /*源端口*/
85 =2 uint DestPort; /*目的端口*/
86 =2 ulong SeqNum; /*順序號(hào)*/
87 =2 ulong AckNum; /*確認(rèn)號(hào)*/
88 =2 uchar offset; /*數(shù)據(jù)偏移量*/
89 =2 uchar control; /*連接控制*/
90 =2 uint window; /*流控*/
91 =2 uint Crc; /*校驗(yàn)和 ,包括偽頭部,TCP頭部,數(shù)據(jù)*/
92 =2 uint urg; /*緊急指針*/
93 =2 uchar tcpdata[1478]; /*TCP數(shù)據(jù)*/
94 =2 };
95 =2
96 =2 struct udp { uint EtherHead[9];
97 =2 uint IpHead[10];
98 =2 uint SourcePort; /*源端口*/
99 =2 uint DestPort; /*目的端口*/
100 =2 uint length;
101 =2 uint Crc; /*校驗(yàn)和,包括偽頭部,udp頭部,數(shù)據(jù)*/
102 =2 uchar udpdata[1478]; /*udp數(shù)據(jù)*/
103 =2 };
104 =2
105 =2 /*所有協(xié)議的共用體*/
106 =2 union Netcard {struct {uchar bytebuf[1536];}bytes;
107 =2 struct {uint wordbuf[768];}words;
108 =2 struct ethernet EtherFrame;
109 =2 struct retransmit ResendFrame;
110 =2 struct arp ArpFrame;
111 =2 struct icmp IcmpFrame;
112 =2 struct tcp TcpFrame;
113 =2 struct ip IpFrame;
114 =2 struct udp UdpFrame;
115 =2 struct IpPacket IpPacket;
116 =2 };
117 =2
118 =2 struct Socket_Type{
119 =2 uint My_Port; //本機(jī)端口
120 =2 uint Dest_Port; //對(duì)方端口
121 =2 uint Dest_Ip[2]; //對(duì)方ip
122 =2 uint Dest_Mac_Id[3]; //對(duì)方的以太網(wǎng)地址
123 =2 ulong IRS; //初始化順序號(hào)
124 =2 ulong ISS; //我的初始化序列號(hào)
125 =2 ulong Rcv_Next; //對(duì)方的順序號(hào)
126 =2 ulong Send_Next; //我的已經(jīng)發(fā)送順序號(hào)
127 =2 ulong Sent_UnAck; //我的還沒(méi)有確認(rèn)順序號(hào)
128 =2 //unsigned long dest_ack_number;
129 =2 uint Rcv_Window; //對(duì)方的window大小
130 =2 uint Snd_Window; //我的window大小
131 =2 uint Dest_Max_Seg_Size; //對(duì)方接受的最大的數(shù)據(jù)包大小MTU
132 =2 uint My_Max_Seg_Size; //我能接受的最大的數(shù)據(jù)包大小
133 =2 ulong My_Wl1; //seq
134 =2 ulong My_Wl2; //ack
135 =2 uchar State; //連接狀態(tài)
136 =2 uchar Open;
137 =2 };
138 =2
139 =2 /*tcp state define */
140 =2
141 =2 #define TCP_STATE_LISTEN 0
142 =2 #define TCP_STATE_SYN_RCVD 1
143 =2 #define TCP_STATE_SYN_SENT 2
144 =2 #define TCP_STATE_ESTABLISHED 3
145 =2 #define TCP_STATE_FIN_WAIT1 4
C51 COMPILER V7.06 UDP 07/10/2003 14:34:43 PAGE 15
146 =2 #define TCP_STATE_FIN_WAIT2 5
147 =2 #define TCP_STATE_CLOSING 6
148 =2 #define TCP_STATE_CLOSE_WAIT 7
149 =2 #define TCP_STATE_LAST_ACK 8
150 =2 #define TCP_STATE_CLOSED 9
151 =2 #define TCP_STATE_TIME_WAIT 10
152 =2 //tcp連接的標(biāo)志位
153 =2 #define TCP_FIN 0x01
154 =2 #define TCP_SYN 0x02
155 =2 #define TCP_RST 0x04
156 =2 #define TCP_PSH 0x08
157 =2 #define TCP_ACK 0x10
158 =2 #define TCP_URG 0x20
159 =2
160 =2
161 =2 /*** RTL8019's address deifne ***/
162 =2 #define dp668
163 =2 #ifdef dp668 //reg00- 10為isa網(wǎng)卡接口的寄存器地址300-31f
164 =2 #define RED_ADDR0 RTL8019AS_BASE_ADDRESS+0x00
165 =2 #define RED_ADDR1 RTL8019AS_BASE_ADDRESS+0x01
166 =2 #define RED_ADDR2 RTL8019AS_BASE_ADDRESS+0x02
167 =2 #define RED_ADDR3 RTL8019AS_BASE_ADDRESS+0x03
168 =2 #define RED_ADDR4 RTL8019AS_BASE_ADDRESS+0x04
169 =2 #define RED_ADDR5 RTL8019AS_BASE_ADDRESS+0x05
170 =2 #define RED_ADDR6 RTL8019AS_BASE_ADDRESS+0x06
171 =2 #define RED_ADDR7 RTL8019AS_BASE_ADDRESS+0x07
172 =2 #define RED_ADDR8 RTL8019AS_BASE_ADDRESS+0x08
173 =2 #define RED_ADDR9 RTL8019AS_BASE_ADDRESS+0x09
174 =2 #define RED_ADDRa RTL8019AS_BASE_ADDRESS+0x0a
175 =2 #define RED_ADDRb RTL8019AS_BASE_ADDRESS+0x0b
176 =2 #define RED_ADDRc RTL8019AS_BASE_ADDRESS+0x0c
177 =2 #define RED_ADDRd RTL8019AS_BASE_ADDRESS+0x0d
178 =2 #define RED_ADDRe RTL8019AS_BASE_ADDRESS+0x0e
179 =2 #define RED_ADDRf RTL8019AS_BASE_ADDRESS+0x0f
180 =2 #define RED_ADDR10 RTL8019AS_BASE_ADDRESS+0x10
181 =2 #define RED_ADDR18 RTL8019AS_BASE_ADDRESS+0x18
182 =2 #define Reg00 XBYTE[RED_ADDR0]
183 =2 #define Reg01 XBYTE[RED_ADDR1]
184 =2 #define Reg02 XBYTE[RED_ADDR2]
185 =2 #define Reg03 XBYTE[RED_ADDR3]
186 =2 #define Reg04 XBYTE[RED_ADDR4]
187 =2 #define Reg05 XBYTE[RED_ADDR5]
188 =2 #define Reg06 XBYTE[RED_ADDR6]
189 =2 #define Reg07 XBYTE[RED_ADDR7]
190 =2 #define Reg08 XBYTE[RED_ADDR8]
191 =2 #define Reg09 XBYTE[RED_ADDR9]
192 =2 #define Reg0a XBYTE[RED_ADDRa]
193 =2 #define Reg0b XBYTE[RED_ADDRb]
194 =2 #define Reg0c XBYTE[RED_ADDRc]
195 =2 #define Reg0d XBYTE[RED_ADDRd]
196 =2 #define Reg0e XBYTE[RED_ADDRe]
197 =2 #define Reg0f XBYTE[RED_ADDRf]
198 =2 #define Reg10 XBYTE[RED_ADDR10]
199 =2 #define Reg18 XBYTE[RED_ADDR18]
200 =2
201 =2 #endif
202 =2
3 =1
4 =1 #define COM_RXD_BUFF_SIZE 600 //串口接收緩沖區(qū)大小
5 =1 #define COM_TXD_BUFF_SIZE 600 //串口發(fā)送緩沖區(qū)大小
6 =1 #define COMMAND_BUFF_SIZE 600
7 =1 #define RT_BUFF_NUM 1 //5 was changed to 3,2002/12/19 14:10
C51 COMPILER V7.06 UDP 07/10/2003 14:34:43 PAGE 16
8 =1 #define TCP_MAX_RETXD 8 //tcp包最多重發(fā)的次數(shù)
9 =1 //uchar code Mac_ID[6];//將RTL8019的物理地址存儲(chǔ)在程序空間中
10 =1
11 =1
12 =1 #include "arp.h"
1 =2 #ifdef ARP_GLOBALS
=2 #define ARP_EXT
=2 #else
4 =2 #define ARP_EXT extern
5 =2 #endif
6 =2
7 =2 ARP_EXT void Arp_Request(unsigned long ip_address);
8 =2 ARP_EXT void Arp_Answer();
9 =2 ARP_EXT void Gateway_Arp_Request(); //在每分鐘的前三秒對(duì)網(wǎng)關(guān)地址進(jìn)行解析
10 =2 ARP_EXT void Arp_Process();
13 =1 #include "GLOBAL.h"
1 =2 #ifdef GLOBAL_GLOBALS
=2 #define GLOBAL_EXT
=2 #else
4 =2 #define GLOBAL_EXT extern
5 =2 #endif
6 =2 GLOBAL_EXT xdata struct Socket_Type TCP1024;
7 =2 GLOBAL_EXT xdata union Ip_Address_Type My_Ip_Address ; //本機(jī)IP地址
8 =2 GLOBAL_EXT xdata union Ip_Address_Type Gateway_Ip_Address; //網(wǎng)關(guān)IP地址
9 =2 GLOBAL_EXT xdata union Ip_Address_Type Mask_Ip_Address; //子網(wǎng)掩碼
10 =2 GLOBAL_EXT xdata union Ip_Address_Type Ping_Ip_Address; //保存PING命令的目的主機(jī)的物理地址
11 =2 GLOBAL_EXT xdata union Netcard RxdNetBuff; //數(shù)據(jù)接收緩沖區(qū)
12 =2 GLOBAL_EXT xdata union Netcard TxdNetBuff; //數(shù)據(jù)發(fā)送緩沖區(qū)
13 =2 GLOBAL_EXT xdata union Netcard Resend_Buff;
14 =2 GLOBAL_EXT xdata union Ethernet_Address_Type Gateway_MAC; //網(wǎng)關(guān)的物理地址
15 =2 GLOBAL_EXT xdata union Ethernet_Address_Type Ping_MAC; //PING的物理地址
16 =2 GLOBAL_EXT union u RemotePort;
17 =2
18 =2
19 =2 GLOBAL_EXT bit BiSecond; //兩秒時(shí),該標(biāo)志置1
20 =2 GLOBAL_EXT bit Tcp_Timeout; //TCP超時(shí)標(biāo)志,定時(shí)器0中斷中將該標(biāo)志置位
21 =2 GLOBAL_EXT bit TcpConnected;
22 =2 GLOBAL_EXT bit ComTxdBufempty;
23 =2
24 =2 GLOBAL_EXT uchar Msec; //10毫秒
25 =2 GLOBAL_EXT uchar Sec; //秒鐘
26 =2 GLOBAL_EXT uchar Min; //分鐘
27 =2 GLOBAL_EXT uchar Gateway_IP_TTL;
28 =2 GLOBAL_EXT uchar Ping_IP_TTL;
29 =2 GLOBAL_EXT uchar Ping_Count; //ping的次數(shù),決定本地回顯次數(shù)
30 =2 GLOBAL_EXT uchar Udp_Count;
31 =2 GLOBAL_EXT uchar RtTime; //重發(fā)時(shí)間
32 =2 GLOBAL_EXT uchar Tcp_Drop_Count;
33 =2 GLOBAL_EXT uint FrameIndex;
34 =2
35 =2 GLOBAL_EXT uint ComTxdRead; //串口接收讀指針
36 =2 GLOBAL_EXT uint ComRxdRead; //串口發(fā)送讀指針
37 =2 GLOBAL_EXT uint ComRxdWrite; //串口接收寫指針
38 =2 GLOBAL_EXT uint ComTxdWrite; //串口發(fā)送寫指針
39 =2 GLOBAL_EXT xdata uchar ComRxdBuf[]; //串口的接收緩沖區(qū)
40 =2 GLOBAL_EXT xdata uchar ComTxdBuf[]; //串口的發(fā)送緩沖區(qū)
41 =2
42 =2 GLOBAL_EXT uchar code HexTable[];
43 =2 GLOBAL_EXT xdata uchar Command_Buf[COMMAND_BUFF_SIZE];//命令緩沖區(qū)
44 =2 GLOBAL_EXT xdata unsigned char IpStr[16];
45 =2 GLOBAL_EXT xdata unsigned char PortStr[5];
46 =2
C51 COMPILER V7.06 UDP 07/10/2003 14:34:43 PAGE 17
47 =2 GLOBAL_EXT void initial_system();
48 =2 GLOBAL_EXT bit Rec_NewPacket();
49 =2 GLOBAL_EXT unsigned char VerifyIpHeadCrc();
50 =2 GLOBAL_EXT unsigned char VerifyTcpCrc();
51 =2 GLOBAL_EXT uint CreateIpHeadCrc();
52 =2 GLOBAL_EXT uint CreateIcmpCrc();//
53 =2 GLOBAL_EXT unsigned char VerifyUdpCrc();
54 =2 GLOBAL_EXT uint CreateTcpCrc();
55 =2 GLOBAL_EXT void Create_Ip_Frame(uint length,uint IPH,uint IPL,uchar NextProtocal);
56 =2 GLOBAL_EXT union Ip_Address_Type *IP_Str2Hex(unsigned char *Str); //IP字符串轉(zhuǎn)換到IP地址值
57 =2 GLOBAL_EXT void Delay_MS(uint ms_number);
58 =2 GLOBAL_EXT void IP_Hex2Str(union Ip_Address_Type ip) ;
59 =2 GLOBAL_EXT void Port_Hex2Str(unsigned int portnum); //IP地址值轉(zhuǎn)換到IP字符串
60 =2 GLOBAL_EXT void Send_Packet(union Netcard *TxdNetBuff,uint length);
61 =2
62 =2
14 =1 #include "ICMP.h"
1 =2 #ifdef ICMP_GLOBALS
=2 #define ICMP_EXT
=2 #else
4 =2 #define ICMP_EXT extern
5 =2 #endif
6 =2
7 =2 ICMP_EXT void Ping_Answer();
8 =2 ICMP_EXT void Ping_Request();
9 =2 ICMP_EXT void Ping_Echo();
10 =2 ICMP_EXT void Process_Ping();
11 =2
15 =1 #include "INPUT.h"
1 =2 #ifdef INPUT_GLOBALS
=2 #define INPUT_EXT
=2 #else
4 =2 #define INPUT_EXT extern
5 =2 #endif
6 =2 INPUT_EXT void process_command();
7 =2
16 =1 #include "TCP.h"
1 =2 #ifdef TCP_GLOBALS
=2 #define TCP_EXT
=2 #else
4 =2 #define TCP_EXT extern
5 =2 #endif
6 =2 TCP_EXT void TCP1024_Init();
7 =2
8 =2 TCP_EXT void Process_Tcp_Timeout();
9 =2 TCP_EXT void Process_Tcp();
10 =2
17 =1 #include "UART.h"
1 =2 #ifdef UART_GLOBALS
=2 #define UART_EXT
=2 #else
4 =2 #define UART_EXT extern
5 =2 #endif
6 =2 UART_EXT unsigned char Get_Char();
7 =2
8 =2 UART_EXT void Printf_Char(uchar ascii);
9 =2
10 =2 UART_EXT void Printf_String(uchar *string);
11 =2 UART_EXT void Printf_IPStr(union Ip_Address_Type ip);
12 =2 UART_EXT void Printf_PortStr(unsigned int portnum);
13 =2 UART_EXT void Printf_Hex(unsigned char senddata);
14 =2
C51 COMPILER V7.06 UDP 07/10/2003 14:34:43 PAGE 18
18 =1 #include "UDP.h"
1 =2 #ifdef UDP_GLOBALS
2 =2 #define UDP_EXT
3 =2 #else
=2 #define UDP_EXT extern
=2 #endif
6 =2
7 =2 UDP_EXT void Process_Udp();
8 =2 UDP_EXT void Process_Udp_Command();
19 =1
20 =1
21 =1 #define RTL8019AS_BASE_ADDRESS 0x5000
22 =1
23 =1 #define MY_MAC_ID {0x52,0x54,0x4c,0x19,0xf8,0x23}//將RTL8019的物理地址存儲(chǔ)在程序空間
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -