📄 uip.h
字号:
*
*/
struct uip_stats {
struct {
uip_stats_t drop; /**< Number of dropped packets at the IP
layer. */
uip_stats_t recv; /**< Number of received packets at the IP
layer. */
uip_stats_t sent; /**< Number of sent packets at the IP
layer. */
uip_stats_t vhlerr; /**< Number of packets dropped due to wrong
IP version or header length. */
uip_stats_t hblenerr; /**< Number of packets dropped due to wrong
IP length, high byte. */
uip_stats_t lblenerr; /**< Number of packets dropped due to wrong
IP length, low byte. */
uip_stats_t fragerr; /**< Number of packets dropped since they
were IP fragments. */
uip_stats_t chkerr; /**< Number of packets dropped due to IP
checksum errors. */
uip_stats_t protoerr; /**< Number of packets dropped since they
were neither ICMP, UDP nor TCP. */
} ip; /**< IP statistics. */
struct {
uip_stats_t drop; /**< Number of dropped ICMP packets. */
uip_stats_t recv; /**< Number of received ICMP packets. */
uip_stats_t sent; /**< Number of sent ICMP packets. */
uip_stats_t typeerr; /**< Number of ICMP packets with a wrong
type. */
} icmp; /**< ICMP statistics. */
struct {
uip_stats_t drop; /**< Number of dropped TCP segments. */
uip_stats_t recv; /**< Number of recived TCP segments. */
uip_stats_t sent; /**< Number of sent TCP segments. */
uip_stats_t chkerr; /**< Number of TCP segments with a bad
checksum. */
uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK
number. */
uip_stats_t rst; /**< Number of recevied TCP RST (reset) segments. */
uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */
uip_stats_t syndrop; /**< Number of dropped SYNs due to too few
connections was avaliable. */
uip_stats_t synrst; /**< Number of SYNs for closed ports,
triggering a RST. */
} tcp; /**< TCP statistics. */
#if UIP_UDP
struct {
uip_stats_t drop; /**< Number of dropped UDP segments. */
uip_stats_t recv; /**< Number of recived UDP segments. */
uip_stats_t sent; /**< Number of sent UDP segments. */
uip_stats_t chkerr; /**< Number of UDP segments with a bad
checksum. */
} udp; /**< UDP statistics. */
#endif /* UIP_UDP */
};
/**
* The uIP TCP/IP statistics.
*
* This is the variable in which the uIP TCP/IP statistics are gathered.
*/
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;
/* The following flags may be set in the global variable uip_flags
before calling the application callback. The UIP_ACKDATA,
UIP_NEWDATA, and UIP_CLOSE 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 only through the uIP
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. These values are never used directly, but only in
the macrose defined in this file. */
#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. */
#define UIP_POLL_REQUEST 3 /* Tells uIP that a connection should
be polled. */
#define UIP_UDP_SEND_CONN 4 /* Tells uIP that a UDP datagram
should be constructed in the
uip_buf buffer. */
#if UIP_UDP
#define UIP_UDP_TIMER 5
#endif /* UIP_UDP */
/* The TCP states used in the uip_conn->tcpstateflags. */
#define UIP_CLOSED 0
#define UIP_SYN_RCVD 1
#define UIP_SYN_SENT 2
#define UIP_ESTABLISHED 3
#define UIP_FIN_WAIT_1 4
#define UIP_FIN_WAIT_2 5
#define UIP_CLOSING 6
#define UIP_TIME_WAIT 7
#define UIP_LAST_ACK 8
#define UIP_TS_MASK 15
#define UIP_STOPPED 16
/* The TCP and IP headers. */
#ifdef __ICCARM__
#pragma pack(1)
#endif
struct uip_tcpip_hdr {
#if UIP_CONF_IPV6
/* IPv6 header. */
u8_t vtc,
tcflow;
u16_t flow;
u8_t len[2];
u8_t proto, ttl;
uip_ip6addr_t srcipaddr, destipaddr;
#else /* UIP_CONF_IPV6 */
/* IPv4 header. */
u8_t vhl,
tos,
len[2],
ipid[2],
ipoffset[2],
ttl,
proto;
u16_t ipchksum;
u16_t srcipaddr[2],
destipaddr[2];
#endif /* UIP_CONF_IPV6 */
/* TCP header. */
u16_t srcport,
destport;
u8_t seqno[4],
ackno[4],
tcpoffset,
flags,
wnd[2];
u16_t tcpchksum;
u8_t urgp[2];
u8_t optdata[4];
} PACK_STRUCT_END;
#ifdef __ICCARM__
#pragma pack()
#endif
/* The ICMP and IP headers. */
#ifdef __ICCARM__
#pragma pack(1)
#endif
struct uip_icmpip_hdr {
#if UIP_CONF_IPV6
/* IPv6 header. */
u8_t vtc,
tcf;
u16_t flow;
u8_t len[2];
u8_t proto, ttl;
uip_ip6addr_t srcipaddr, destipaddr;
#else /* UIP_CONF_IPV6 */
/* IPv4 header. */
u8_t vhl,
tos,
len[2],
ipid[2],
ipoffset[2],
ttl,
proto;
u16_t ipchksum;
u16_t srcipaddr[2],
destipaddr[2];
#endif /* UIP_CONF_IPV6 */
/* ICMP (echo) header. */
u8_t type, icode;
u16_t icmpchksum;
#if !UIP_CONF_IPV6
u16_t id, seqno;
#else /* !UIP_CONF_IPV6 */
u8_t flags, reserved1, reserved2, reserved3;
u8_t icmp6data[16];
u8_t options[1];
#endif /* !UIP_CONF_IPV6 */
} PACK_STRUCT_END;
#ifdef __ICCARM__
#pragma pack()
#endif
/* The UDP and IP headers. */
#ifdef __ICCARM__
#pragma pack(1)
#endif
struct uip_udpip_hdr {
#if UIP_CONF_IPV6
/* IPv6 header. */
u8_t vtc,
tcf;
u16_t flow;
u8_t len[2];
u8_t proto, ttl;
uip_ip6addr_t srcipaddr, destipaddr;
#else /* UIP_CONF_IPV6 */
/* IP header. */
u8_t vhl,
tos,
len[2],
ipid[2],
ipoffset[2],
ttl,
proto;
u16_t ipchksum;
u16_t srcipaddr[2],
destipaddr[2];
#endif /* UIP_CONF_IPV6 */
/* UDP header. */
u16_t srcport,
destport;
u16_t udplen;
u16_t udpchksum;
} PACK_STRUCT_END;
#ifdef __ICCARM__
#pragma pack()
#endif
/**
* The buffer size available for user data in the \ref uip_buf buffer.
*
* This macro holds the available size for user data in the \ref
* uip_buf buffer. The macro is intended to be used for checking
* bounds of available user data.
*
* Example:
\code
snprintf(uip_appdata, UIP_APPDATA_SIZE, "%u\n", i);
\endcode
*
* \hideinitializer
*/
#define UIP_APPDATA_SIZE (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
#define UIP_PROTO_ICMP 1
#define UIP_PROTO_TCP 6
#define UIP_PROTO_UDP 17
#define UIP_PROTO_ICMP6 58
/* Header sizes. */
#if UIP_CONF_IPV6
#define UIP_IPH_LEN 40
#else /* UIP_CONF_IPV6 */
#define UIP_IPH_LEN 20 /* Size of IP header */
#endif /* UIP_CONF_IPV6 */
#define UIP_UDPH_LEN 8 /* Size of UDP header */
#define UIP_TCPH_LEN 20 /* Size of TCP header */
#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP +
UDP
header */
#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP +
TCP
header */
#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN
#if UIP_FIXEDADDR
extern const uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
#else /* UIP_FIXEDADDR */
extern uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
#endif /* UIP_FIXEDADDR */
/**
* Representation of a 48-bit Ethernet address.
*/
#ifdef __ICCARM__
#pragma pack(1)
#endif
struct uip_eth_addr {
u8_t addr[6];
} PACK_STRUCT_END;
#ifdef __ICCARM__
#pragma pack()
#endif
/**
* Calculate the Internet checksum over a buffer.
*
* The Internet checksum is the one's complement of the one's
* complement sum of all 16-bit words in the buffer.
*
* See RFC1071.
*
* \param buf A pointer to the buffer over which the checksum is to be
* computed.
*
* \param len The length of the buffer over which the checksum is to
* be computed.
*
* \return The Internet checksum of the buffer.
*/
u16_t uip_chksum(u16_t *buf, u16_t len);
/**
* Calculate the IP header checksum of the packet header in uip_buf.
*
* The IP header checksum is the Internet checksum of the 20 bytes of
* the IP header.
*
* \return The IP header checksum of the IP header in the uip_buf
* buffer.
*/
u16_t uip_ipchksum(void);
/**
* Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
*
* The TCP checksum is the Internet checksum of data contents of the
* TCP segment, and a pseudo-header as defined in RFC793.
*
* \return The TCP checksum of the TCP segment in uip_buf and pointed
* to by uip_appdata.
*/
u16_t uip_tcpchksum(void);
/**
* Calculate the UDP checksum of the packet in uip_buf and uip_appdata.
*
* The UDP checksum is the Internet checksum of data contents of the
* UDP segment, and a pseudo-header as defined in RFC768.
*
* \return The UDP checksum of the UDP segment in uip_buf and pointed
* to by uip_appdata.
*/
u16_t uip_udpchksum(void);
/**
* Work out the fasted way of sending the data to the low level driver. */
int uip_fast_send( int xARP );
#endif /* __UIP_H__ */
/** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -