📄 uip.h
字号:
#define uip_newdata() (uip_flags & UIP_NEWDATA)/* uip_acked(): * * Will reduce to non-zero if the previously sent data has been * acknowledged by the remote host. This means that the application * can send new data. uip_reset_acked() can be used to reset the acked * flag. */#define uip_acked() (uip_flags & UIP_ACKDATA)#define uip_reset_acked() (uip_flags &= ~UIP_ACKDATA)/* uip_connected(): * * Reduces to non-zero if the current connection has been connected to * a remote host. This will happen both if the connection has been * actively opened (with uip_connect()) or passively opened (with * uip_listen()). */#define uip_connected() (uip_flags & UIP_CONNECTED)/* uip_closed(): * * Is non-zero if the connection has been closed by the remote * host. The application may do the necessary clean-ups. */#define uip_closed() (uip_flags & UIP_CLOSE)/* uip_aborted(): * * Non-zero if the current connection has been aborted (reset) by the * remote host. */#define uip_aborted() (uip_flags & UIP_ABORT)/* uip_timedout(): * * Non-zero if the current connection has been aborted due to too many * retransmissions. */#define uip_timedout() (uip_flags & UIP_TIMEDOUT)/* uip_rexmit(): * * Reduces to non-zero if the previously sent data has been lost in * the network, and the application should retransmit it. The * application should set the uip_appdata buffer and the uip_len * variable just as it did the last time this data was to be * transmitted. */#define uip_rexmit() (uip_flags & UIP_REXMIT)/* uip_poll(): * * Is non-zero if the reason the application is invoked is that the * current connection has been idle for a while and should be * polled. */#define uip_poll() (uip_flags & UIP_POLL)/* uip_mss(): * * Gives the current maxium segment size (MSS) of the current * connection. */#define uip_mss() (uip_conn->mss)/* uIP convenience and converting functions. *//* uip_ipaddr(&ipaddr, addr0,addr1,addr2,addr3): * * Packs an IP address into a two element 16-bit array. Such arrays * are used to represent IP addresses in uIP. */#define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \ (addr)[0] = htons(((addr0) << 8) | (addr1)); \ (addr)[1] = htons(((addr2) << 8) | (addr3)); \ } while(0)/* htons(), ntohs(): * * Macros for converting 16-bit quantities between host and network * byte order. */#ifndef htons#if BYTE_ORDER == BIG_ENDIAN#define htons(n) (n)#else /* BYTE_ORDER == BIG_ENDIAN */#define htons(n) ((((u16_t)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))#endif /* BYTE_ORDER == BIG_ENDIAN */#endif /* htons *///#define ntohs(n) htons(n)#ifndef ntohs#if BYTE_ORDER == BIG_ENDIAN#define ntohs(n) (n)#else /* BYTE_ORDER == BIG_ENDIAN */#define ntohs(n) ((((u16_t)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))#endif /* BYTE_ORDER == BIG_ENDIAN */#endif /* ntohs *//*-----------------------------------------------------------------------------------*//* 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 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 >= 256extern u16_t uip_len;#elseextern u8_t uip_len;#endif /* UIP_BUFSIZE >=256 *//* 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_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 ipchkerr; /* 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 u8_t uip_flags;/* uip_process(flag): * * The actual uIP function which does all the work. */void uip_process(u8_t flag);/* The TCP and IP headers. */struct uip_tcpip_hdr_t { /* 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];};#define uip_tcpip_hdr struct uip_tcpip_hdr_t#endif /* __UIP_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -