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

📄 tcp.lst

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


C51 COMPILER V7.06, COMPILATION OF MODULE TCP
OBJECT MODULE PLACED IN .\8052-obj\tcp.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\tcp.c LARGE OPTIMIZE(SIZE) BROWSE INTVECTOR(0X2000) INCDIR(D:\Work\opent
                    -cp\1-0-2\src\include\) DEFINE(MONITOR,CS8900) DEBUG OBJECTEXTEND CODE SYMBOLS PRINT(.\8052-lst\tcp.lst) PREPRINT(.\8052-
                    -lst\tcp.i) OBJECT(.\8052-obj\tcp.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   TCP                                                                   11/26/2004 11:32:45 PAGE 2   

  54          /** \file tcp.c
  55           *      \brief OpenTCP TCP 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 10.7.2002
  61           *      \bug
  62           *      \warning
  63           *      \todo
  64           *              \li Check if tcp_tempbuf can be thrown out and net_buf
  65           *              used instead. Application normally don't use the first part
  66           *              of tcp_tempbuf anyway and there shouldn't be any overlapping
  67           *              with other applications (TCP/UDP) either.
  68           *              \li     There's probably no need for that <b>+1</b> for determining
  69           *              the size of tcp_tempbuf. But if previous TODO is possible,
  70           *              this isn't important anyway.
  71           *              \li Implement per-socket window size (just add API function)
  72           *
  73           *      OpenTCP TCP implementation. All functions necessary for TCP
  74           *      processing are present here. Note that only a small subset
  75           *      of these functions must be used for "normal" applications that
  76           *      are using the TCP for communciation. For function declarations and
  77           *      lots of other usefull stuff see inet/tcp_ip.h.
  78           *
  79           *      For examples how to use TCP and write applications that communicate
  80           *      using TCP see inet/demo/main_demo.c, inet/demo/tcp_client_demo.c and
  81           *      inet/demo/tcp_server_demo.c.
  82           *
  83           */
  84          
  85          #include <inet/debug.h>
*** WARNING C318 IN LINE 85 OF ..\tcp.c: can't open file 'inet/debug.h'
  86          #include <inet/datatypes.h>
*** WARNING C318 IN LINE 86 OF ..\tcp.c: can't open file 'inet/datatypes.h'
  87          #include <inet/timers.h>
*** WARNING C318 IN LINE 87 OF ..\tcp.c: can't open file 'inet/timers.h'
  88          #include <inet/ethernet.h>
*** WARNING C318 IN LINE 88 OF ..\tcp.c: can't open file 'inet/ethernet.h'
  89          #include <inet/ip.h>
*** WARNING C318 IN LINE 89 OF ..\tcp.c: can't open file 'inet/ip.h'
  90          #include <inet/tcp_ip.h>
*** WARNING C318 IN LINE 90 OF ..\tcp.c: can't open file 'inet/tcp_ip.h'
  91          #include <inet/system.h>
*** WARNING C318 IN LINE 91 OF ..\tcp.c: can't open file 'inet/system.h'
  92          
  93          /**     \brief Used for storing field information about the received TCP packet
  94           *      
  95           *      Various fields from the TCP packet are stored in this variable. These
  96           *      values are then used to perform the necessary actions as defined 
  97           *      by the TCP specification: correctnes of the received TCP packet is
  98           *      checked by analyzing these fields, appropriate socket data is adjusted
  99           *      and/or control packet is sent based on it. See tcp_frame definition 
 100           *      for struct information.
 101           */
 102          struct tcp_frame received_tcp_packet;
 103          
 104          /** \brief TCP table holding connection parameters for every TCP socket 
 105           *
 106           *      TCP table is an array of tcp_socket structures holding all of the 
 107           * necessary information about the state, timers, timeouts and sequence
 108           *      and port numbers of the TCP sockets opened. Number of TCP sockets
C51 COMPILER V7.06   TCP                                                                   11/26/2004 11:32:45 PAGE 3   

 109           *      that can be opened at any given time is defined by the #NO_OF_TCPSOCKETS
 110           *      and may be changed in order to change the amount of used RAM memory.
 111           *      See tcb definition for more information about the structure itself.
 112           *
 113           *      \note As seen in the code, an array size is actually bigger for one
 114           *      than the #NO_OF_TCPSOCKETS defines. The last entry is used for sending
 115           *      control packets as answers to incoming TCP packets that do not map 
 116           *      to any existing TCP sockets.
 117           */
 118          struct tcb tcp_socket[NO_OF_TCPSOCKETS + 1]; 
*** ERROR C202 IN LINE 118 OF ..\TCP.C: 'NO_OF_TCPSOCKETS': undefined identifier
*** ERROR C136 IN LINE 118 OF ..\TCP.C: invalid dimension size: [0]
 119          
 120          UINT8 tcp_tempbuf[MIN_TCP_HLEN + 1]; /**< Temporary buffer used for sending TCP control packets */
*** ERROR C129 IN LINE 120 OF ..\TCP.C: missing ';' before 'tcp_tempbuf'
 121          
 122          
 123          /***********************************************************************/
 124          /*******        TCP API functions                                                                       ********/
 125          /***********************************************************************/
 126          
 127          /** \brief Allocate a free socket in TCP socket pool
 128           *  \ingroup tcp_app_api
 129           *      \author 
 130           *              \li Jari Lahti (jari.lahti@violasystems.com)
 131           *      \date 21.07.2002
 132           *      \param soctype type of socket wanted. Can take one of the following
 133           *              values:
 134           *              \li #TCP_TYPE_NONE
 135           *              \li #TCP_TYPE_SERVER
 136           *              \li #TCP_TYPE_CLIENT
 137           *              \li #TCP_TYPE_CLIENT_SERVER
 138           *      \param tos type of service for socket. For now only #TCP_TOS_NORMAL.
 139           *      \param tout Timeout of socket in seconds. Defines after how many seconds
 140           *              of inactivity (application not sending and/or receiving any data
 141           *              over TCP connection) will the TCP socket automatically be closed.
 142           *      \param listener pointer to callback function that will be invoked by
 143           *              the TCP/IP stack to inform socket application of certain events. See
 144           *              tcpc_demo_eventlistener() and tcps_demo_eventlistener() for more
 145           *              information on events and possible actions.
 146           *      \return 
 147           *              \li -1 - Error getting requested socket
 148           *              \li >=0 - Handle to reserved socket
 149           *
 150           *      Invoke this function to try to obtain a free socket from TCP socket pool.
 151           *      Function returns a handle to the free socket that is later used for 
 152           *      accessing the allocated socket (opening, connecting, sending data,
 153           *      closing, aborting, etc.).
 154           */
 155          INT8 tcp_getsocket (UINT8 soctype, UINT8 tos, UINT16 tout, INT32 (*listener)(INT8, UINT8, UINT32, UINT32) 
             -reentrant)
 156          {
 157                  INT8 i;
 158                  struct tcb* soc;
 159                  
 160                  if( NO_OF_TCPSOCKETS < 0 )
 161                          return(-1);
 162                  
 163                  if( NO_OF_TCPSOCKETS == 0 )
 164                          return(-1);
 165                  
 166                  if( (soctype != TCP_TYPE_SERVER) &&
C51 COMPILER V7.06   TCP                                                                   11/26/2004 11:32:45 PAGE 4   

 167                          (soctype != TCP_TYPE_CLIENT) &&
 168                          (soctype != TCP_TYPE_CLIENT_SERVER) &&
 169                          (soctype != TCP_TYPE_NONE)                              ) {
 170                          TCP_DEBUGOUT("Invalid socket type requested\r\n");
 171                          return(-1);
 172                  }
 173                  
 174                  if(listener == 0) {
 175                          TCP_DEBUGOUT("ERROR:Event listener function not specified\r\n");
 176                          return(-1);
 177                  }
 178                  
 179                  TCP_DEBUGOUT("Searching for free TCP socket...\r\n");
 180                  
 181                  for(i=0; i < NO_OF_TCPSOCKETS; i++)     {
 182                          soc = &tcp_socket[i];                   /* Get Socket   */
 183                  
 184                          if(soc->state == TCP_STATE_FREE) {
 185                                  /* We found it  */
 186                                  
 187                                  TCP_DEBUGOUT("Free socket found\r\n");
 188                                  
 189                                  soc->state = TCP_STATE_RESERVED;
 190                                  soc->type = soctype;
 191                                  soc->tos = tos;
 192                                  soc->event_listener = listener;
 193                                  soc->rem_ip = 0;
 194                                  soc->remport = 0;
 195                                  soc->locport = 0;
 196                                  soc->flags = 0;
 197                                  soc->tout = tout*TIMERTIC;
 198                                  
 199                                  return(i);
 200                          }
 201                  
 202                  }
 203                  
 204                  /* We are there so no socket found      */

⌨️ 快捷键说明

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