📄 ethernet.lst
字号:
142 1 temp=reg1f;//读网卡的复位端口
*** ERROR C202 IN LINE 142 OF MYWORK\ETHERNET\ETHERNET.C: 'reg1f': undefined identifier
143 1 reg1f=temp; //写网卡的复位端口
*** ERROR C202 IN LINE 143 OF MYWORK\ETHERNET\ETHERNET.C: 'reg1f': undefined identifier
144 1 delay_ms(200);
145 1 }
146
147 void ne2000init()//ne2000网卡初始化
148 {
C51 COMPILER V7.02b ETHERNET 08/25/2006 12:00:06 PAGE 4
149 1 rtl8019as_rst();
150 1
151 1 //??????????????????????????????????删
152 1
153 1 #ifdef debug
page(2);
PrintStr("\nPSTART=");
PrintByte(reg01);
PrintStr("\nPSTOP=");
PrintByte(reg02);
PrintStr("\nTPSR=");
PrintByte(reg04);
PrintStr("\nRCR=");
PrintByte(reg0c);
PrintStr("\nTCR=");
PrintByte(reg0d);
PrintStr("\nDCR=");
PrintByte(reg0e);
#endif
168 1 }
169
170 void send_packet(union netcard *txdnet,unsigned int length)//ne2000发包子程序
171 {//发送一个数据包的命令,长度最小为60字节,最大1514字节需要发送的数据包要先存放在txdnet缓冲区
172 1 unsigned char i;
173 1 unsigned int ii;
174 1
175 1 //??????????????????????????????????删
176 1
177 1 reg00=0x3E; //to sendpacket;
*** ERROR C202 IN LINE 177 OF MYWORK\ETHERNET\ETHERNET.C: 'reg00': undefined identifier
178 1 }
179
180 bit recv_packet(union netcard *rxdnet)//ne2000收包子程序
181 {
182 1 unsigned char i;
183 1 unsigned int ii;
184 1 unsigned char bnry,curr;
185 1
186 1 //??????????????????????????????????删
187 1 return 0;
188 1 }
189
190 void trans_pack(union netcard *txdnet,union ip_address_type destip,unsigned int length,unsigned char type)
-//发包至缓冲区
191 {
*** ERROR C230 IN LINE 191 OF MYWORK\ETHERNET\ETHERNET.C: 'ip_address_type': unknown struct/union/enum tag
*** ERROR C230 IN LINE 191 OF MYWORK\ETHERNET\ETHERNET.C: 'ip_address_type': unknown struct/union/enum tag
192 1 unsigned char i;
193 1 unsigned int j;
194 1
195 1 for(i=0;i<MaxLenTxBuf;i++){
*** ERROR C202 IN LINE 195 OF MYWORK\ETHERNET\ETHERNET.C: 'MaxLenTxBuf': undefined identifier
196 2 if(txdbuf[i].status==0){
197 3 txdbuf[i].status=1;
198 3 txdbuf[i].length=length;
199 3 txdbuf[i].type=type;
200 3 txdbuf[i].ip.dwords=destip.dwords;
201 3 txdbuf[i].ttl=8;
202 3 if(type==PINGTYPE) txdbuf[i].pinganswerd=1;
*** ERROR C202 IN LINE 202 OF MYWORK\ETHERNET\ETHERNET.C: 'PINGTYPE': undefined identifier
203 3 for(j=0;j<length;j++)
204 3 txdbuf[i].pack.bytes.bytebuf[j]=txdnet->bytes.bytebuf[j];
C51 COMPILER V7.02b ETHERNET 08/25/2006 12:00:06 PAGE 5
205 3 break;
206 3 }
207 2 }
208 1 }
209
210 void process_trans_pack()//发包缓冲区发送处理
211 {
212 1 unsigned char i,j;
213 1 unsigned char ipstr[16];
214 1
215 1 for(i=0;i<MaxLenTxBuf;i++){
*** ERROR C202 IN LINE 215 OF MYWORK\ETHERNET\ETHERNET.C: 'MaxLenTxBuf': undefined identifier
216 2 if(txdbuf[i].status==1){
217 3 if(txdbuf[i].type==PINGTYPE){
218 4 if(txdbuf[i].ttl==0)
219 4 txdbuf[i].status=0;
220 4 else{
221 5 txdbuf[i].ttl--;
222 5
223 5 ping_ip_address.dwords=txdbuf[i].ip.dwords;
*** ERROR C230 IN LINE 223 OF MYWORK\ETHERNET\ETHERNET.C: 'ip_address_type': unknown struct/union/enum tag
*** ERROR C204 IN LINE 223 OF MYWORK\ETHERNET\ETHERNET.C: 'dwords': undefined member
224 5
225 5 if(txdbuf[i].pinganswerd==0){
226 6 PrintStr("\n\tRequest timed out.(");
227 6 HEXToIPadr(ipstr,&txdbuf[i].ip.dwords);
228 6 PrintStr(ipstr);
229 6 PrintStr(")\n");
230 6 }
231 5 else
232 5 txdbuf[i].pinganswerd=0;
233 5
234 5 if(ping_ip_address.dwords==my_ip_address.dwords){
235 6 PrintStr("\n\tReply from ");
236 6 HEXToIPadr(ipstr,&txdbuf[i].ip.dwords);
237 6 PrintStr(ipstr);
238 6 //PrintLong(txdbuf[i].ip.dwords);
239 6 PrintStr(" TTL=80\n");
240 6 txdbuf[i].pinganswerd=1;
241 6 }
242 5 else if((ping_ip_address.dwords&mask_ip_address.dwords)!=(my_ip_address.dwords&mask_ip_address.dwords
-))
243 5 ping_ip_address.dwords=gateway_ip_address.dwords;//not in same subnet.
244 5
245 5 if(findmacadr(ping_ip_address,&ping_ethernet_address)==1){
246 6 ping_request();
247 6 //for(j=0;j<3;j++)
248 6 // txdbuf[i].pack.etherframe.destnodeid[j]=ping_ethernet_address.words[j];
249 6 for(j=0;j<3;j++)
250 6 txdnet.etherframe.destnodeid[j]=ping_ethernet_address.words[j];
251 6 //send_packet(&txdbuf[i].pack,txdbuf[i].length);
252 6 send_packet(&txdnet,txdbuf[i].length);
253 6 }
254 5 else{
255 6 arp_request(ping_ip_address.dwords);
256 6 }
257 5 }
258 4 }
259 3 else if(txdbuf[i].type==UDPTYPE){
260 4 if(txdbuf[i].ttl==0)
261 4 txdbuf[i].status=0;
262 4 else{
C51 COMPILER V7.02b ETHERNET 08/25/2006 12:00:06 PAGE 6
263 5 txdbuf[i].ttl--;
264 5
265 5 ping_ip_address.dwords=txdbuf[i].ip.dwords;
266 5
267 5 if(ping_ip_address.dwords==my_ip_address.dwords){
268 6 PrintStr("\nUDP myself ERROR!\n");
269 6 txdbuf[i].ttl=0;
270 6 }
271 5 else if((ping_ip_address.dwords&mask_ip_address.dwords)!=(my_ip_address.dwords&mask_ip_address.dwords
-))
272 5 ping_ip_address.dwords=gateway_ip_address.dwords;//not in same subnet.
273 5
274 5 if(findmacadr(ping_ip_address,&ping_ethernet_address)==1){
275 6 for(j=0;j<3;j++)
276 6 txdbuf[i].pack.etherframe.destnodeid[j]=ping_ethernet_address.words[j];
277 6 //remake_udp(&txdbuf[i].pack);
278 6 send_packet(&txdbuf[i].pack,txdbuf[i].length);
279 6 txdbuf[i].ttl=0;
280 6 }
281 5 else{
282 6 arp_request(ping_ip_address.dwords);
283 6 }
284 5 }
285 4 }
286 3 }
287 2 }
288 1 }
289
290 void arp_request(unsigned long ip_address)//ARP请求
291 {//请求解析ip地址
292 1 unsigned char i;
293 1
294 1 //??????????????????????????????????删
295 1
296 1 for(i=0x2E;i<(0x2E+18);i++)
297 1 txdnet.bytes.bytebuf[i]=0x00;
298 1 send_packet(&txdnet,60);
299 1 }
300
301 void arp_answer()//ARP应答
302 {
303 1 unsigned char i;
304 1
305 1 //??????????????????????????????????删
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -