⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arp.lst

📁 在89C51上实现TCPIP协议
💻 LST
字号:
C51 COMPILER V7.07   ARP                                                                   04/20/2004 18:04:40 PAGE 1   


C51 COMPILER V7.07, COMPILATION OF MODULE ARP
OBJECT MODULE PLACED IN .\out\arp.obj
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE src\arp.c BROWSE DEBUG OBJECTEXTEND PRINT(.\lst\arp.lst) OBJECT(.\out\arp.o
                    -bj)

stmt level    source

   1          /*
   2           * Copyright (C) 2002 by TechiZ. All rights reserved.
   3           *
   4           * This program was written in Korean(Comment and some more).
   5           *
   6           * This program was developed by TechiZ(The Company name).
   7           * TechiZ want to share this program with you who loves the 8051 & the TCP/IP.
   8           * 
   9           * You MUST DOWNLOAD THIS CODE from TechiZ Homepage.
  10           * You DO NOT USE THIS CODE FOR COMMERCIAL PURPOSE.
  11           * This code is ONLY FREE FOR THE STUDY.
  12           * If you want more, send me E-mail.
  13           *
  14           * E-mail: techiz@techiz.com
  15           * ( Subject is : [T89C51RD2 & TinyTCP] bla~ bla bla.... )
  16           *
  17           * Homepage: http://www.techiz.com
  18           * 
  19           * You DO NOT DELETE THIS COPYRIGHT MESSAGE IN THE USING OF THIS CODE.
  20           *
  21           * In the using of this code, TechiZ does NOT GUARANTEE ABOUT WORKING WITHOUT ERROR.
  22           */
  23          
  24          /* 
  25           * SAR: Simple Address Resolution Protocol Implementation
  26           * Written by Geoffrey Cooper, September 27, 1983
  27           * 
  28           * This package implements a very simple version of the Plummer Address
  29           * Resolution Protocol (RFC 826).  It allows clients to resolve Internet
  30           * addresses into Ethernet addresses, and knows how to respond to an
  31           * address resolution request (when the transmit buffer is free).
  32           * 
  33           * Routines:
  34           * 
  35           *  sar_CheckPacket( pb ) => 1, if ARP packet and processed, 0 otherwise
  36           *  sar_MapIn2Eth( ina, ethap ) => 1 if did it, 0 if couldn't.
  37           *
  38           * Copyright (C) 1983, 1986 IMAGEN Corporation
  39           *  "This code may be duplicated in whole or in part provided that [1] there
  40           *   is no commercial gain involved in the duplication, and [2] that this
  41           *   copyright notice is preserved on all copies.  Any other duplication
  42           *   requires written notice of the author (Geoffrey H. Cooper)."
  43           * 
  44           */
  45          
  46          #include "tinytcp.h"
  47          #define WARNING
  48          
  49          extern BYTE sed_Send( WORD pkLengthInOctets );
  50          extern BYTE sed_Receive( BYTE *buf );
  51          extern void Move( BYTE *src, BYTE *dest, WORD numbytes );
  52          extern BYTE *sed_IsPacket(void);
  53          extern BYTE sed_CheckPacket( BYTE *BufLocation, WORD expectedType );
  54          extern BYTE *sed_FormatPacket( BYTE *destEAddr, WORD ethType );
C51 COMPILER V7.07   ARP                                                                   04/20/2004 18:04:40 PAGE 2   

  55          
  56                          extern void putb_ser(byte byte_data);
  57                          
  58          extern void print(byte *ch);
  59          
  60          sar_CheckPacket(arp_Header *ap)
  61          {
  62   1              arp_Header *op;
  63   1              unsigned char i ;
  64   1              char *ptr ;
  65   1              
  66   1                      //      print( "our data : ") ;
  67   1      
  68   1                      //      for ( i=0,ptr=(char *)ap ; i<sizeof( arp_Header ); i++) {
  69   1                      //              putb_ser( *ptr++ ) ;
  70   1                      //      }
  71   1      
  72   1                      //      print("\r\n") ;
  73   1      
  74   1              if ( ap->hwType != arp_TypeEther || /* have ethernet hardware, */
  75   1              ap->protType != 0x800 ||       /* and internet software, */
  76   1              ap->opcode != ARP_REQUEST ||   /* and be a resolution req. */
  77   1              ap->dstIPAddr != sin_lclINAddr ) /* for my addr. */ 
  78   1                      return ( 0 );                  /* .... or we ignore it. */
  79   1      
  80   1              //print("it's ours\r\n") ;
  81   1              
  82   1              /* format response. */
  83   1              op = (arp_Header *)sed_FormatPacket(ap->srcEthAddr, 0x806);
  84   1              op->hwType = arp_TypeEther;
  85   1              op->protType = 0x800;
  86   1              op->hwProtAddrLen = (sizeof(eth_HwAddress) << 8) + sizeof(in_HwAddress);
  87   1              op->opcode = ARP_REPLY;
  88   1              op->srcIPAddr = sin_lclINAddr;
  89   1              Move(sed_lclEthAddr, op->srcEthAddr, sizeof(eth_HwAddress));
  90   1              op->dstIPAddr = ap->srcIPAddr;                  /* Modified By Junku */
  91   1              Move(ap->srcEthAddr, op->dstEthAddr, sizeof(eth_HwAddress));
  92   1      
  93   1              sed_Send(sizeof(arp_Header));
  94   1          
  95   1              return ( 1 );
  96   1      }
*** WARNING C280 IN LINE 63 OF SRC\ARP.C: 'i': unreferenced local variable
*** WARNING C280 IN LINE 64 OF SRC\ARP.C: 'ptr': unreferenced local variable
  97          
  98          /* 
  99           * Do an address resolution bit.
 100           */
 101          #ifndef WARNING
              sar_MapIn2Eth(DWORD ina, eth_HwAddress *ethap )
              {
                      register arp_Header *op;
                      extern in_HwAddress sin_lclINAddr;
                      //register i;  /* never used */
                      DWORD endTime;
                      DWORD rxMitTime;
              
                      sed_Receive( 0 );
                      endTime = clock_ValueRough() + 2000;            /* 20ms * 2000 = 40 Sec */
                      while ( endTime > clock_ValueRough() ) {
                              op = (arp_Header *)sed_FormatPacket((BYTE *)&sed_ethBcastAddr[0], 0x0806);
                              op->hwType = arp_TypeEther;
C51 COMPILER V7.07   ARP                                                                   04/20/2004 18:04:40 PAGE 3   

                              op->protType = 0x800;
                              op->hwProtAddrLen = (sizeof(eth_HwAddress) << 8) + sizeof(in_HwAddress);
                              op->opcode = ARP_REQUEST;
                              op->srcIPAddr = sin_lclINAddr;
                              Move(sed_lclEthAddr, op->srcEthAddr, sizeof(eth_HwAddress));
                              op->dstIPAddr = ina;
              
                              /* ...and send the packet */
                              sed_Send( sizeof(arp_Header) );
              
                              rxMitTime = clock_ValueRough() + 400; /* 20ms * 200 = 4 Sec */
                              while ( rxMitTime > clock_ValueRough() ) {
                                      op = (arp_Header *)sed_IsPacket();
                                      if ( op ) {
                                              if ( sed_CheckPacket(op, 0x806) == 1 && 
                                                      op->protType == 0x800 &&
                                                      op->srcIPAddr == ina &&
                                                      op->opcode == ARP_REPLY ) {
                                                      Move(op->srcEthAddr, (BYTE *)ethap, sizeof(eth_HwAddress));
                                                      return ( 1 );
                                              }
                                              sed_Receive(op);
                                      }
                              }
                      }
                      return ( 0 );
              }
              #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    257    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      10
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  2 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -