📄 tcpipapi.h
字号:
#define AF_INET6 28
#define PF_INET6 AF_INET6
#define SOCK_STREAM 1 /* stream socket , TCP */
#define SOCK_DGRAM 2 /* datagram socket, UDP */
//ulps
#define IP_ICMP (unsigned char)1
#define IP_IGMP (unsigned char)2
#define IP_TCP (unsigned char)6
#define IP_UDP (unsigned char)17
/*****************************************************************************/
#define MSG_BLOCKING 0x0000 /* this message should be blocking */
#define MSG_TIMEOUT 0x0001 /* wake up from recv after we have timed out*/
#define MSG_DONTWAIT 0x0080 /* this message should be nonblocking */
/*****************************************************************************/
//Socket options
/*****************************************************************************/
//protocol levels
#define IP_PROTOIP_LEVEL 0 /* ip level */
#define IP_PROTOTCP_LEVEL 6 /* tcp level */
#ifndef TCPIP_STACK_V2
#define SOCKET_LEVEL 0x7fff /* socket level */
#else
#define SOCKET_LEVEL 0xffff /* socket level */
#endif
//ip level options
#ifndef TCPIP_STACK_V2
#define IPO_TTL 0x0001 /* IP Time to live, default 64 seconds*/
#define IPO_TOS 0x0002 /* IP type of service , default 0*/
#else
#define IPO_TOS 0x0003 /* IP type of service , default 0*/
#define IPO_TTL 0x0004 /* IP Time to live, default 64 seconds*/
#endif
//tcp level options
#define TCP_NODELAY 0x0001 /* Disable/enable the nagle algorithm*/
#define TCP_NOPUSH 0x0004 /* Delay sending until a full segment is buffered*/
#define TCP_SLOW_START 0x0200 /* Disable/enable TCP slow start algorithm*/
#define TCP_KEEPALIVE 0x4001 /* Set idle time,before sending keepalive probes, default 7200 seconds*/
#define TCP_DELAY_ACK 0x4002 /* Set the TCP delay ack time in millseconds*/
#define TCP_KEEPALIVE_INTV 0x4004 /* Set keep alive interval probes (default 75 seconds) */
#define TCP_KEEPALIVE_CNT 0x4005 /* Set max. number of keep alive probes, before tcp gives up, default 12*/
#define TCP_FINWT2TIME 0x4006 /* Set the max. amount of time TCP will wait for the remote side to close, after it initiate a close*/
#define TCP_2MSLTIME 0x4007 /* Set the max. amount of time TCP will wait in the TIME WAIT state, once it has initiated a close*/
#define TCP_MAXRT 0x0010 /* Set the TCP/IP Timeout, OptionLength: 2 Bytes (INT) */
#define TCP_MAXREXMIT 0x4003 /* Set the Maximal TCP/IP Send retries, OptionLength: 2 Bytes (INT) */
#define TCP_SSL_CLIENT 0x5000 /* Set this option to enable SSL client negotiation */
#define TCP_SSL_SERVER 0x5001 /* Set this option to enable SSL server negotiation */
#define TCP_SSLSESSION 0x5002 /* Set the SSL session number for this socket */
#define TCP_SSL_SEND_MIN_SIZE 0x5004 /* Set the SSL send minimum size */
#define TCP_SSL_SEND_MAX_SIZE 0x5005 /* Set the SSL record maximum size */
//socket level options
#define SO_REUSEADDR 0x0004 /* allow local address reuse ,default 0 disable*/
#define SO_KEEPALIVE 0x0008 /* keep connections alive, default 0 disable*/
#define SO_SNDBUF 0x1001 /* send buffer size, default TCP 4096, UDP 2048 bytes */
#define SO_RCVBUF 0x1002 /* receive buffer size,default TCP 4096, UDP 2048 bytes */
/*****************************************************************************/
////socket call back function and event flags, TCP sockets only!!
/*****************************************************************************/
#define CB_CONNECT_COMPLT 0x0001 /* connection complete*/
#define CB_ACCEPT 0x0002 /* remote has establ. a connection to our listening server*/
#define CB_RECV 0x0004 /* incoming data arrived*/
#define CB_SEND_COMPLT 0x0010 /* sending of data has been acked by the peer*/
#define CB_REMOTE_CLOSE 0x0020 /* peer has shutdown the connection*/
#define CB_SOCKET_ERROR 0x0040 /* an error occured on the connection*/
#define CB_RESET 0x0080 /* peer has sent a rest on the connection*/
#define CB_CLOSE_COMPLT 0x0100 /* close has been completed*/
/*****************************************************************************/
////ArpRouteCache Entry flags
/*****************************************************************************/
#define INDIRECT 0x00000002UL // Indirect route (struct GatewayEntry)
#define LINKLAYER 0x00000008UL // Valid Arp entry (struct ArpEntry)
#define LOCALROUTE 0x00000010UL // Local route (struct LocalNetRouteEntry)
#define STATIC 0x00000020UL // Static route
#define CLONED_ARP 0x00000C00UL // Cloned arp entry
#define ROUTE_UP 0x00010000UL // Route is up
#define HOST_IP 0x00020000UL // arpIpAddress entry is a host address, 0: network address
/*****************************************************************************/
//PPP options
/*****************************************************************************/
// PPP Protocol levels
#define PPP_LCP_PROTOCOL 0x21c0 // LCP, Link control protocol
#define PPP_IPCP_PROTOCOL 0x2180 // IPCP, Internet protocol control protocol
#define PPP_PROTOCOL 0x0000 // PPP common
// For .remoteLocalFlag
#define PPP_OPTION_WANT 0 // What we want to use for our side
#define PPP_OPTION_ALLOW 1 // What we will allow the remote side to use
// Protocol options for .optionName field
// LCP protocol options
#define PPP_LCP_MAX_RECV_UNIT 1 // Maximum receive unit
#define PPP_LCP_ACCM 2 // Async Ctrl Char Map
#define PPP_LCP_AUTH_PROTOCOL 3 // Authentication, def. 0, else PPP_PAP or PPP_CHAP
#define PPP_LCP_PROTOCOL_COMP 7 // Turn On/Off protocol field compression
#define PPP_LCP_ADDRCONTROL_COMP 8 // Turn ON/OFF address/control field compression
#define PPP_LCP_TERM_RETRY 9 // Terminate retries,
#define PPP_LCP_CONFIG_RETRY 10 // Config retries,
#define PPP_LCP_TIMEOUT 11 // Retransmission timeout in seconds
#define PPP_LCP_MAX_FAILURES 12 // LCP maximum failure
// IPCP protocol options
#define PPP_IPCP_COMP_PROTOCOL 2 // VJ-TCP/IP header compression
#define PPP_IPCP_IP_ADDRESS 3 // IP Address the requesting system wishes to use
#define PPP_IPCP_VJ_SLOTS 4 // Number of VJ slots
#define PPP_IPCP_RETRY 5 // IPCP Timeout, retry options
#define PPP_IPCP_TIMEOUT 6 // IPCP timeout seconds
#define PPP_IPCP_MAX_FAILURES 7 // LCP maximum failures
#define PPP_IPCP_DNS_PRI 29 // Specify DNS prim. server IP
#define PPP_IPCP_DNS_SEC 31 // Specify DNS sec. server IP
//PPP options
#define PPP_SEND_BUFFER_SIZE 1 // Data buffered by PPP link layer, before the device driver send function
// is called, length 2, def. 1 (Byte)
//Authentication constants
#define PPP_PAP 0x23c0 // PAP authentication
#define PPP_CHAP 0x23c2 // CHAP authentication
/*****************************************************************************/
//Errorcodes
/*****************************************************************************/
#define API_NOT_SUPPORTED -2
#define API_ERROR -1
#define API_ENOERROR 0
//PPP server states
#define PPPS_UNDEFINED -1 /* Undefined, should not happen*/
#define PPPS_NOT_STARTED 0 /* PPP server was not started*/
#define PPPS_DISABLED 1 /* Server started, but disabled */
#define PPPS_ENABLED 2 /* Server enabled, not connected*/
#define PPPS_LNKUP 3 /* Connection established*/
#define PPPS_MODEMCLOSING 4 /* Server hangs up modem*/
#define PPPS_MODEMINIT 5 /* Server tries init modem*/
//PPP client states
#define PPP_NOTAVAIL -1 /* Client is not running*/
#define PPP_LNKDOWN 0 /* Link is down*/
#define PPP_LNKWILLOPEN 1 /* open link in progress*/
#define PPP_LNKUP 2 /* Link is established*/
//PPP client errorcodes
#define PPP_INV_COMPORT -1 /* invalid comport specified,
this errorCode also occurs, if
the pppclient is interrupted while dialing
(e.g. user break with setting the flag modem_break
at the struct pppclient_init
or another modem error)
*/
#define PPP_INUSE -2 /* ppp client already in use */
#define PPP_INV_USER -3 /* invalid user or password */
#define PPP_OPEN_FAIL -4 /* connection failed */
#define PPP_INV_DEV -5 /* pppclient interface not found */
#define PPP_IPCFG_FAIL -6
#define PPP_CONNECT_FAIL -7
//************************************************************************************
//BSD defines, macros
//************************************************************************************
#define INET6_ADDRSTRLEN 46 //max length of an IPv6 address int text format
#define INET_ADDRSTRLEN 16 //max length of an IPv4 string
// Compare 2 IPv6 addresses
// Parameter: const struct in6_addr *Addr1
// const struct in6_addr *Addr1
#define IN6_ARE_ADDR_EQUAL(Addr1, Addr2) \
( ((Addr1)->ip6Addr.ip6U32[0] == (Addr2)->ip6Addr.ip6U32[0]) \
&& ((Addr1)->ip6Addr.ip6U32[1] == (Addr2)->ip6Addr.ip6U32[1]) \
&& ((Addr1)->ip6Addr.ip6U32[2] == (Addr2)->ip6Addr.ip6U32[2]) \
&& ((Addr1)->ip6Addr.ip6U32[3] == (Addr2)->ip6Addr.ip6U32[3]))
//Test if address is local loopback
//Parameter: const struct in6_addr *Addr
#define IN6_IS_ADDR_LOOPBACK(Addr) \
( ((Addr)->ip6Addr.ip6U32[0] == (0UL)) \
&& ((Addr)->ip6Addr.ip6U32[1] == (0UL)) \
&& ((Addr)->ip6Addr.ip6U32[2] == (0UL)) \
&& ((Addr)->ip6Addr.ip6U32[3] == (0x01000000UL)))
//Check IPv6 address to see if it is the unspecified address (i.e. all 0's)
//Parameter: const struct in6_addr *Addr
#define IN6_IS_ADDR_UNSPECIFIED(Addr) \
( ((Addr)->ip6Addr.ip6U32[0] == (0UL)) \
&& ((Addr)->ip6Addr.ip6U32[1] == (0UL)) \
&& ((Addr)->ip6Addr.ip6U32[2] == (0UL)) \
&& ((Addr)->ip6Addr.ip6U32[3] == (0UL)))
//Test, if IPv6 address is a multicast address
//Parameter: const struct in6_addr *Addr
#define IN6_IS_ADDR_MULTICAST(Addr) \
((Addr)->ip6Addr.ip6U8[0] == (unsigned char) 0xff)
//Test IPv6 address, if it is a link-local scope
//Parameter: const struct in6_addr *Addr
#define IN6_IS_ADDR_LINKLOCAL(Addr) \
(((Addr)->ip6Addr.ip6U8[0] == (unsigned char) 0xfe) \
&& (((Addr)->ip6Addr.ip6U8[1] & (unsigned char) 0xc0) == (unsigned char) 0x80))
//Test IPv6 address to see if it is a site-local scope unicast address.
//Parameter: const struct in6_addr *Addr
#define IN6_IS_ADDR_SITELOCAL(Addr) \
(((Addr)->ip6Addr.ip6U8[0] == (unsigned char) 0xfe) \
&& (((Addr)->ip6Addr.ip6U8[1] & (unsigned char) 0xc0) == (unsigned char) 0xc0))
//Test IPv6 address,if it represents an IPv4 address (i.e. IPv4-mapped IPv6 address)
//Parameter: const struct in6_addr *Addr
#define IN6_IS_ADDR_V4MAPPED(Addr) \
((((Addr)->ip6Addr.ip6U32[0]) == (0UL)) && \
(((Addr)->ip6Addr.ip6U32[1]) == (0UL)) && \
(((Addr)->ip6Addr.ip6U32[2]) == (0xFFFF0000UL)))
//Test IPv6 address, if it is an IPv4-compatible IPv6 address.
//Parameter: const struct in6_addr *Addr
#define IN6_IS_ADDR_V4COMPAT(Addr) \
((((Addr)->ip6Addr.ip6U32[0]) == (0UL)) && \
(((Addr)->ip6Addr.ip6U32[1]) == (0UL)) && \
(((Addr)->ip6Addr.ip6U32[2]) == (0UL)) && \
(((Addr)->ip6Addr.ip6U32[3]) != (0UL)) && \
(((Addr)->ip6Addr.ip6U32[3]) != (0x01000000UL)))
//Copy one IPv6 address to another
//Parameter: const struct in6_addr *AddrSrc
//Parameter: const struct in6_addr *AddrDest
#define IPV6_addr_copy(AddrSrc, AddrDst) \
{ \
(AddrDst)->ip6Addr.ip6U32[0] = (AddrSrc)->ip6Addr.ip6U32[0]; \
(AddrDst)->ip6Addr.ip6U32[1] = (AddrSrc)->ip6Addr.ip6U32[1]; \
(AddrDst)->ip6Addr.ip6U32[2] = (AddrSrc)->ip6Addr.ip6U32[2]; \
(AddrDst)->ip6Addr.ip6U32[3] = (AddrSrc)->ip6Addr.ip6U32[3]; \
}
//BSD address constants used for IPv4, in network byte order
#define INADDR_ANY (0x00000000UL)
#define INADDR_LOOPBACK (0x0100007FUL)
/*****************************************************************************/
#endif _TCPIP_API_H__
/*****************************************************************************/
//end tcpipapi.h
/***************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -