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

📄 tcp_ip.h

📁 用于嵌入式系统的TCP/IP协议栈
💻 H
字号:
/***********************************************************************//*                                                                     *//*   Module:  tcp_ip.h                                                 *//*   Release: 2001.3                                                   *//*   Version: 2000.1                                                   *//*   Purpose: TCP/IP stack prototypes and constants                    *//*                                                                     *//*---------------------------------------------------------------------*//*                                                                     *//*               Copyright 1999, Blunk Microsystems                    *//*                      ALL RIGHTS RESERVED                            *//*                                                                     *//*   Licensees have the non-exclusive right to use, modify, or extract *//*   this computer program for software development at a single site.  *//*   This program may be resold or disseminated in executable format   *//*   only. The source code may not be redistributed or resold.         *//*                                                                     *//***********************************************************************/#ifndef _TCP_IP_H /* Don't include this file more than once */#define _TCP_IP_H#ifdef __cplusplusextern "C"{#endif/***********************************************************************//* TargetTCP Configuration                                             *//***********************************************************************/#define TCP_PROBE       FALSE   /* TRUE enables protocol decoder */#define PPP_TRACE       FALSE   /* TRUE enables PPP trace output */#define MAX_PPP_INTF    1       /* maximum number of PPP channels */#define RARP_SERVER     FALSE   /* TRUE enables RARP server *//*** Buffer Size Definitions (multiple of 4)*/#define TCP_SML_SIZE    128#define TCP_MED_SIZE    (16 + 2047)     /* (1520 + 16) */#define TCP_BIG_SIZE    (8 * 1460)#define NIMHLEN         24      /* divisible by 4 and > any NI header */#if NIMHLEN % 4#error The value of NIMHLEN must be an even multiple of 4#endif#define MAX_ALEN        ETH_ALEN  /* maximum hardware address length *//***********************************************************************//* Symbol Definitions                                                  *//***********************************************************************/#define IP_ALEN         4#define ETH_MTU         1500#define ETH_HDR_LEN     14#define ETH_CRC_LEN     4#define ETH_ALEN        6/*** Hardware Types*/#define ETH_DIX_HW      1#define ETH_802_HW      6/*** Network Packet Types*/#define IP_TYPE         0x0800      /* type: Internet Protocol */#define ARP_TYPE        0x0806      /* type: ARP */#define RARP_TYPE       0x8035      /* type: RARP *//*** Network Interface Flags*/#define NIF_UP          (1 << 0)  /* set by TargetTCP only */#define NIF_BORROWED    (1 << 1)  /* set by TargetTCP only */#define NIF_P2P         (1 << 2)  /* interface is point to point */#define NIF_DEF_GW      (1 << 3)  /* add as default gateway */#define NIF_USE_DHCP    (1 << 4)  /* DHCP protocol */#define NIF_USE_RARP    (1 << 5)  /* use RARP for address assignment *//*** Network Interface Events*/#define NIE_UP          1#define NIE_DOWN        2#define NIE_RESTART     3/*** Modem Input Signals*/#define kDCD    (1 << 0)#define kDSR    (1 << 1)/*** PPP Option Flags*/#define OPT_ACFC        (1 << 0)#define OPT_PFC         (1 << 1)#define OPT_MAGIC       (1 << 2)#define OPT_ACCM        (1 << 3)#define OPT_MRU         (1 << 4)#define OPT_PAP         (1 << 5)#define OPT_CHAP        (1 << 6)#define OPT_ADDR        (1 << 7)#define OPT_VJHC        (1 << 8)#define OPT_DNS         (1 << 9)/*** PPP Interface Flags*/#define PPPF_DEF_GW     (1 << 0) /* interface is a default gateway */#define PPPF_TRACE      (1 << 1) /* trace logging is enabled */#define PPPF_PASSIVE    (1 << 2) /* connection is passive */#define PPPF_DEAD       (1 << 3) /* interface is dead */#define PPPF_NI_UP      (1 << 4) /* interface is connected *//***********************************************************************//* Type Definitions                                                    *//***********************************************************************//*** Network Buffer Definition*/typedef struct nbuf{  ui32 order;              /* number of contiguous regions */  void *flush;             /* points to socket if in receive queue */  void *seg_record;        /* link for out-of-order buffer queue */  ui32 next_hop;           /* IP address to send packet to */  struct netif *ni;        /* pointer to associated NI */  struct nbuf *next;       /* pointer to next linked NetBuf */  uint length;             /* length of packet data */  uint app_len;            /* length of first data region */  uint app_len2;           /* length of second data region */  ui32 type;               /* IP, ARP, or RARP type */  ui8  *ip_pkt;            /* pointer to start of IP packet */  void *ip_data;           /* pointer to start of IP data */  ui8  *app_data;          /* address of first data region */  ui8  *app_data2;         /* address of second data region */  ui8  data[1];            /* variable size field */} NetBuf;/*** Network Interface Structure (one instance per interface)*/typedef struct netif{  struct netif *next;     /* pointer to next linked NI structure */  struct netif *entry;    /* pointer to next NI, used by tcpPollReq() */  void (*poll)(void);     /* used by tcpPollReq() */  void (*transmit)(NetBuf *, void *hwa); /* called to transmit packet */  void (*broadcast)(NetBuf *); /* called to broadcast packet */  void (*report)(struct netif *ni, int event); /* called if not NULL */  ui32 ip_addr;           /* IP address for this interface */  ui32 ip_mask;           /* IP subnet mask */  ui32 remote_addr;       /* used for point-to-point interfaces */  void *hw_addr;          /* pointer to NI's hw address */  char *name;             /* name of this interface */  int  mtu;               /* max transfer unit (bytes) */  int  flags;             /* option/status flags */  int  ipkts;             /* number of input packets */  int  ierrs;             /* number of input packets with errors */  int  opkts;             /* number of output packets */  int  oerrs;             /* number of output packets with errors */  ui8  hw_type;           /* ARP HW type: ETH_DIX_HW or ... */  ui8  ha_len;            /* MAC address length */} Ni;/*** Chat Configuration*/typedef struct{  char *init;           /* initialization script */  char *dial;           /* dial script */  char *login;          /* login script */  char *hangup;         /* hangup script */  char *phone_number;   /* phone number */  char *phone_number2;  /* additional phone number */  char *username;       /* login user name */  char *password;       /* login password */  int   max_trys;       /* number of times to retry CHAT startup */} ChatCfg;/*** PPP Interface Control Block*/typedef struct{  /*  ** Serial Interface  */  int  (*connect)(void);    /* connects PPP channel interface */  void (*disconnect)(void); /* disconnects PPP channel interface */  int  (*sig_check)(void);  /* checks modem control signals */  void (*data_ind)(void *handle, ui8 *src, int length, int increment);  int  (*data_req)(void *handle, ui8 *dst, int space, int increment);  void (*start_tx)(void);   /* tx start callback */  void (*transmit)(NetBuf *buf);  void (*report)(void *ppp, int event); /* called if not NULL */  ui32 asyncmap;        /* bit-map indicating tx chars to be escaped */  char *addtl_esc;      /* additional chars escaped during tx */  char *username;       /* PPP authentication user name */  char *password;       /* PPP authentication password or key */  ui32 local_addr;      /* local IP address */  ui32 remote_addr;     /* remote IP address */  ui32 accept_opts;     /* peer requests that are accepted */  ui32 request_opts;    /* options we request */  ui32 flags;  ui16 mru;             /* requested max size of packets sent to us */  ui16 mtu;             /* requested max size of packets sent by us */  ui16 DCD_timeout;     /* # seconds persistence or 0xFFFF ignore */  ui16 DSR_timeout;     /* # seconds persistence or 0xFFFF ignore */  ChatCfg chat;  Ni ni;                /* network interface control block */} pppPublic;/*** Host List Entry*/typedef struct{  char *name;  ui32 ip_addr;  ui8  hw_type;  ui8  hw_addr[MAX_ALEN];} HostDesc;/***********************************************************************//* Global Variable Declarations                                        *//***********************************************************************/extern ui32 PriDnsServer;extern ui32 SecDnsServer;extern ui32 DefGateway;extern HostDesc HostsTable[];/***********************************************************************//* Function Prototypes                                                 *//***********************************************************************/void  TargetTcpInit(void);void  tcpPoll(void);void *tcpModule(int req, ...);void  tcpDataInd(NetBuf *buf);void *tcpGetBuf(int length);void  tcpRetBuf(void *bufpp);int   tcpAddNi(Ni *ni);int   tcpDelNi(Ni *ni);int   tcpStatNi(const char *name);void  tcpPollReq(Ni *ni);NetBuf *recvbuf(int s, int flags);NetBuf *recvbuffrom(int s, int flags, void *from, int *fromlen);void  tcpPerror(int err_code);void *pppAlloc(void);int   pppOpen(pppPublic *ppp);void  pppClose(pppPublic *ppp);void  pppFree(pppPublic *ppp);void  pppDataInd(void *buf);void *pppConnect(void);void  pppDisconnect(pppPublic *id);#ifdef __cplusplus}#endif#endif /* _TCP_IP_H */

⌨️ 快捷键说明

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