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

📄 ip.lst

📁 cs8900 c51应用
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.06   IP                                                                    11/26/2004 11:32:45 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE IP
OBJECT MODULE PLACED IN .\8052-obj\ip.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\ip.c LARGE OPTIMIZE(SIZE) BROWSE INTVECTOR(0X2000) INCDIR(D:\Work\opentc
                    -p\1-0-2\src\include\) DEFINE(MONITOR,CS8900) DEBUG OBJECTEXTEND CODE SYMBOLS PRINT(.\8052-lst\ip.lst) PREPRINT(.\8052-ls
                    -t\ip.i) OBJECT(.\8052-obj\ip.obj)

stmt level    source

   1          /*
   2           *Copyright (c) 2000-2002 Viola Systems Ltd.
   3           *All rights reserved.
   4           *
   5           *Redistribution and use in source and binary forms, with or without 
   6           *modification, are permitted provided that the following conditions 
   7           *are met:
   8           *
   9           *1. Redistributions of source code must retain the above copyright 
  10           *notice, this list of conditions and the following disclaimer.
  11           *
  12           *2. Redistributions in binary form must reproduce the above copyright 
  13           *notice, this list of conditions and the following disclaimer in the 
  14           *documentation and/or other materials provided with the distribution.
  15           *
  16           *3. The end-user documentation included with the redistribution, if 
  17           *any, must include the following acknowledgment:
  18           *      "This product includes software developed by Viola 
  19           *      Systems (http://www.violasystems.com/)."
  20           *
  21           *Alternately, this acknowledgment may appear in the software itself, 
  22           *if and wherever such third-party acknowledgments normally appear.
  23           *
  24           *4. The names "OpenTCP" and "Viola Systems" must not be used to 
  25           *endorse or promote products derived from this software without prior 
  26           *written permission. For written permission, please contact 
  27           *opentcp@opentcp.org.
  28           *
  29           *5. Products derived from this software may not be called "OpenTCP", 
  30           *nor may "OpenTCP" appear in their name, without prior written 
  31           *permission of the Viola Systems Ltd.
  32           *
  33           *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 
  34           *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  35           *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  36           *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 
  37           *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  38           *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  39           *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
  40           *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  41           *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
  42           *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
  43           *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44           *====================================================================
  45           *
  46           *OpenTCP is the unified open source TCP/IP stack available on a series 
  47           *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
  48           *
  49           *For more information on how to network-enable your devices, or how to 
  50           *obtain commercial technical support for OpenTCP, please see 
  51           *<http://www.violasystems.com/>.
  52           */
  53          
C51 COMPILER V7.06   IP                                                                    11/26/2004 11:32:45 PAGE 2   

  54          /** \file ip.c
  55           *      \brief OpenTCP IP protocol implementation
  56           *      \author 
  57           *              \li Jari Lahti (jari.lahti@violasystems.com)
  58           *              \li Vladan Jovanovic (vladan.jovanovic@violasystems.com)
  59           *      \version 1.0
  60           *      \date 11.6.2002
  61           *      \bug
  62           *      \warning
  63           *      \todo 
  64           *              \li Implement stub handler for supporting fragmented datagrams (
  65           *              may be usefull on MCUs with lots of available RAM)
  66           *  
  67           *      OpenTCP IP protocol implementation functions. For declaration,
  68           *      constants and data structures refer to inet/ip.h.
  69           */
  70          #include <inet/debug.h>
*** WARNING C318 IN LINE 70 OF ..\ip.c: can't open file 'inet/debug.h'
  71          #include <inet/datatypes.h>
*** WARNING C318 IN LINE 71 OF ..\ip.c: can't open file 'inet/datatypes.h'
  72          #include <inet/ethernet.h>
*** WARNING C318 IN LINE 72 OF ..\ip.c: can't open file 'inet/ethernet.h'
  73          #include <inet/arp.h>
*** WARNING C318 IN LINE 73 OF ..\ip.c: can't open file 'inet/arp.h'
  74          #include <inet/ip.h>
*** WARNING C318 IN LINE 74 OF ..\ip.c: can't open file 'inet/ip.h'
  75          #include <inet/system.h>
*** WARNING C318 IN LINE 75 OF ..\ip.c: can't open file 'inet/system.h'
  76          
  77          
  78          /**     \brief Used for storing various information about the incoming IP packet
  79           *      
  80           *      Various fields from the IP packet are stored in this structure. These
  81           *      values are later used from other upper layer protocols (ICMP, UDP, TCP
  82           *      and possibly others) to extract needed information about the received
  83           *      packet. See ip_frame definition for struct information.
  84           */
  85          struct ip_frame received_ip_packet;
  86          
  87          /**     \brief Used for storing various information about the outgoing IP packet
  88           *      
  89           *      Various fields from the IP packet are stored in this structure. These
  90           *      values are filled based on the information supplied by the upper 
  91           *      layer protocols (ICMP, UDP, TCP and possibly others) and used to form
  92           *      a correct IP packet (correct filed values, checksum,..). See ip_frame
  93           *      definition for struct information.
  94           */
  95          struct ip_frame send_ip_packet;
  96          
  97          UINT16 ip_id;   /**< ID field in the next IP packet that will be sent */
*** ERROR C129 IN LINE 97 OF ..\IP.C: missing ';' before 'ip_id'
  98          
  99          /** \brief Process received IP frame
 100           *      \ingroup periodic_functions
 101           *      \author 
 102           *              \li Jari Lahti
 103           *      \date 11.06.2002
 104           *      \param frame pointer to ethernet_frame structure holding information
 105           *              about the received frame that carries IP datagram.
 106           *      \return
 107           *              \li -1 - IP packet not OK
 108           *              \li >0 - Length of next layer data (IP packet OK)
C51 COMPILER V7.06   IP                                                                    11/26/2004 11:32:45 PAGE 3   

 109           *
 110           *      Process received IP packet by checking necessary header information
 111           *      and storing it accordingly to received_ip_packet variable. If everything
 112           *      checks out, return length of the data carried in the IP datagram (for
 113           *      higher-level protocols), otherwise return -1.
 114           */
 115          INT16 process_ip_in (struct ethernet_frame* frame)
 116          {
 117          
 118                  UINT8 olen;
 119                  UINT8 i;
 120                  
 121                  /* Check for Protocol                                                           */
 122                  
 123                  IP_DEBUGOUT("Checking if IP Protocol\n\r");
 124                  
 125                  if( frame->protocol != PROTOCOL_IP )
 126                          return(-1);
 127                  
 128                  
 129                  IP_DEBUGOUT("It's IP\n\r");
 130                  
 131                  if( frame->frame_size < ETH_HEADER_LEN )
 132                          return(-1);
 133                          
 134                  if( (frame->frame_size - ETH_HEADER_LEN) < IP_HLEN )
 135                          return(-1); 
 136                                          
 137                  /* Get IP Header Information                                            */
 138                          
 139                  NETWORK_RECEIVE_INITIALIZE(frame->buf_index);
 140                          
 141                  received_ip_packet.vihl = RECEIVE_NETWORK_B();
 142                          
 143                  /* Is it IPv4?  */
 144                          
 145                  if( (received_ip_packet.vihl & 0xF0) != 0x40 ) {
 146                          IP_DEBUGOUT("ERROR: IP is not version 4!\n\r");
 147                          return(-1);
 148                  }
 149                          
 150                  IP_DEBUGOUT("IP Version 4 OK!\n\r");    
 151                          
 152                  received_ip_packet.tos = RECEIVE_NETWORK_B();                                           
 153                  
 154                  received_ip_packet.tlen = ((UINT16)RECEIVE_NETWORK_B()) << 8;
 155                  received_ip_packet.tlen |= RECEIVE_NETWORK_B();
 156                          
 157                  received_ip_packet.id = RECEIVE_NETWORK_B() << 8;
 158                  received_ip_packet.id |= RECEIVE_NETWORK_B();
 159                          
 160                  received_ip_packet.frags = ((UINT16)RECEIVE_NETWORK_B()) << 8;
 161                  received_ip_packet.frags |= RECEIVE_NETWORK_B();
 162                          
 163                  received_ip_packet.ttl= RECEIVE_NETWORK_B();
 164                          
 165                  received_ip_packet.protocol= RECEIVE_NETWORK_B();
 166                          
 167                  received_ip_packet.checksum = ((UINT16)RECEIVE_NETWORK_B()) << 8;
 168                  received_ip_packet.checksum |= RECEIVE_NETWORK_B();
 169                          
 170                  received_ip_packet.sip = (((UINT32)RECEIVE_NETWORK_B()) << 24);
C51 COMPILER V7.06   IP                                                                    11/26/2004 11:32:45 PAGE 4   

 171                  received_ip_packet.sip |= (((UINT32)RECEIVE_NETWORK_B()) << 16);
 172                  received_ip_packet.sip |= (((UINT32)RECEIVE_NETWORK_B()) << 8);
 173                  received_ip_packet.sip |= RECEIVE_NETWORK_B();
 174                          
 175                  received_ip_packet.dip = (((UINT32)RECEIVE_NETWORK_B()) << 24);
 176                  received_ip_packet.dip |= (((UINT32)RECEIVE_NETWORK_B()) << 16);
 177                  received_ip_packet.dip |= (((UINT32)RECEIVE_NETWORK_B()) << 8);
 178                  received_ip_packet.dip |= RECEIVE_NETWORK_B();
 179          
 180                  /* Is that packet for us?                       */

⌨️ 快捷键说明

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