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