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

📄 uip.h

📁 51单片机的Web Server代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*-----------------------------------------------------------------------------------*/
/* The following global variables are used for passing parameters
 * between uIP, the network device driver and the application. */
/*-----------------------------------------------------------------------------------*/

/* u8_t uip_buf[UIP_BUFSIZE]:
 *
 * The uip_buf array is used to hold incoming and outgoing
 * packets. The device driver fills this with incoming packets.
 */
extern u8_t uip_buf[UIP_BUFSIZE];

/* u8_t *uip_appdata:
 *
 * This pointer points to the application data when the application is
 * called. If the application wishes to send data, this is where the
 * application should write it. The application can also point this to
 * another location.
 */
extern volatile u8_t *uip_appdata; 

/* u[8|16]_t uip_len:
 *
 * When the application is called, uip_len contains the length of any
 * new data that has been received from the remote host. The
 * application should set this variable to the size of any data that
 * the application wishes to send. When the network device driver
 * output function is called, uip_len should contain the length of the
 * outgoing packet.
 */
#if UIP_BUFSIZE > 255
extern volatile u16_t uip_len;
#else
extern volatile u8_t uip_len;
#endif /* UIP_BUFSIZE > 255 */

/* struct uip_conn *uip_conn:
 *
 * When the application is called, uip_conn will point to the current
 * conntection, the one that should be processed by the
 * application. The uip_conns[] array is a list containing all
 * connections.
 */
extern struct uip_conn *uip_conn;  
extern struct uip_conn uip_conns[UIP_CONNS];

/* struct uip_conn:
 *
 * The uip_conn structure is used for identifying a connection. All
 * but one field in the structure are to be considered read-only by an
 * application. The only exception is the appstate field whos purpose
 * is to let the application store application-specific state (e.g.,
 * file pointers) for the connection. The size of this field is
 * configured in the "uipopt.h" header file.
 */
struct uip_conn {
  u8_t tcpstateflags; /* TCP state and flags. */
  u16_t lport, rport; /* The local and the remote port. */
  u16_t ripaddr[2];   /* The IP address of the remote peer. */
  u8_t rcv_nxt[4];    /* The sequence number that we expect to receive
			 next. */
  u8_t snd_nxt[4];    /* The sequence number that was last sent by
                         us. */
  u8_t ack_nxt[4];    /* The sequence number that should be ACKed by
			 next ACK from peer. */
#if UIP_TCP_MSS > 255  
  u16_t mss;          /* Maximum segment size for the connection. */
#else
  u8_t mss;
#endif /* UIP_TCP_MSS */  
  u8_t timer;         /* The retransmission timer. */
  u8_t nrtx;          /* Counts the number of retransmissions for a
                         particular segment. */
  
  u8_t appstate[UIP_APPSTATE_SIZE];
};

/* struct uip_stats:
 *
 * Contains statistics about the TCP/IP stack.
 */
struct uip_stats {
  struct {
    u16_t drop;
    u16_t recv;
    u16_t sent;
    u16_t vhlerr;   /* Number of packets dropped due to wrong IP version
		       or header length. */
    u16_t hblenerr; /* Number of packets dropped due to wrong IP length,
		       high byte. */
    u16_t lblenerr; /* Number of packets dropped due to wrong IP length,
		       low byte. */
    u16_t fragerr;  /* Number of packets dropped since they were IP
		       fragments. */
    u16_t chkerr;   /* Number of packets dropped due to IP checksum errors. */
    u16_t protoerr; /* Number of packets dropped since they were neither
		       ICMP nor TCP. */
  } ip;
  struct {
    u16_t drop;
    u16_t recv;
    u16_t sent;
    u16_t typeerr;
  } icmp;
  struct {
    u16_t drop;
    u16_t recv;
    u16_t sent;
    u16_t chkerr;
    u16_t ackerr;
    u16_t rst;
    u16_t rexmit;
    u16_t syndrop;  /* Number of dropped SYNs due to too few
                       connections was avaliable. */
    u16_t synrst;   /* Number of SYNs for closed ports, triggering a
                       RST. */
  } tcp;
};

extern struct uip_stats uip_stat;


/*-----------------------------------------------------------------------------------*/
/* All the stuff below this point is internal to uIP and should not be
 * used directly by an application or by a device driver.
 */
/*-----------------------------------------------------------------------------------*/
/* u8_t uip_flags:
 *
 * When the application is called, uip_flags will contain the flags
 * that are defined in this file. Please read below for more
 * infomation.
 */
extern volatile u8_t uip_flags;

/* The following flags may be set in the global variable uip_flags
   before calling the application callback. The UIP_ACKDATA and
   UIP_NEWDATA flags may both be set at the same time, whereas the
   others are mutualy exclusive. Note that these flags should *NOT* be
   accessed directly, but through the uip_has and uip_in
   functions/macros. */

#define UIP_ACKDATA   1     /* Signifies that the outstanding data was
			       acked and the application should send
			       out new data instead of retransmitting
			       the last data. */
#define UIP_NEWDATA   2     /* Flags the fact that the peer has sent
			       us new data. */
#define UIP_REXMIT    4     /* Tells the application to retransmit the
			       data that was last sent. */
#define UIP_POLL      8     /* Used for polling the application, to
			       check if the application has data that
			       it wants to send. */
#define UIP_CLOSE     16    /* The remote host has closed the
			       connection, thus the connection has
			       gone away. Or the application signals
			       that it wants to close the
			       connection. */
#define UIP_ABORT     32    /* The remote host has aborted the
			       connection, thus the connection has
			       gone away. Or the application signals
			       that it wants to abort the
			       connection. */
#define UIP_CONNECTED 64    /* We have got a connection from a remote
                               host and have set up a new connection
                               for it, or an active connection has
                               been successfully established. */

#define UIP_TIMEDOUT  128   /* The connection has been aborted due to
			       too many retransmissions. */


/* uip_process(flag):
 *
 * The actual uIP function which does all the work.
 */
void uip_process(u8_t flag);

/* The following flags are passed as an argument to the uip_process()
   function. They are used to distinguish between the two cases where
   uip_process() is called. It can be called either because we have
   incoming data that should be processed, or because the periodic
   timer has fired. */

#define UIP_DATA    1     /* Tells uIP that there is incoming data in
                             the uip_buf buffer. The length of the
                             data is stored in the global variable
                             uip_len. */
#define UIP_TIMER   2     /* Tells uIP that the periodic timer has
                             fired. */

/* The TCP states used in the uip_conn->tcpstateflags. */
#define CLOSED      0
#define SYN_RCVD    1
#define SYN_SENT    2
#define ESTABLISHED 3
#define FIN_WAIT_1  4
#define FIN_WAIT_2  5
#define CLOSING     6
#define TIME_WAIT   7
#define LAST_ACK    8
#define TS_MASK     15
  
#define UIP_OUTSTANDING 16
#define UIP_STOPPED     32

/* The TCP and IP headers. */
typedef struct {
  /* IP header. */
  u8_t vhl,
    tos,          
    len[2],       
    ipid[2],        
    ipoffset[2],  
    ttl,          
    proto;     
  u16_t ipchksum;
  u16_t srcipaddr[2], 
    destipaddr[2];
  /* TCP header. */
  u16_t srcport,
    destport;
  u8_t seqno[4],  
    ackno[4],
    tcpoffset,
    flags,
    wnd[2];     
  u16_t tcpchksum,
    urgp; 
  u8_t optdata[4];
} uip_tcpip_hdr;

void puthex(unsigned char Byte);//以十六进制格式显示1个字节数据
void putstring(unsigned char *str);//显示字符串
void putword(unsigned int Word);//以十六进制格式显示1个字数据

#endif /* __UIP_H__ */







⌨️ 快捷键说明

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