RetroArch
uip_ip.h
Go to the documentation of this file.
1 #ifndef __UIP_IP_H__
2 #define __UIP_IP_H__
3 
4 #include "uip.h"
5 
6 #define UIP_INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */
7 #define UIP_INADDR_LOOPBACK ((u32_t) 0x7f000001) /* 127.0.0.1 */
8 
9 #define UIP_IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12)
10 #define UIP_IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
11 #define UIP_IPH_TOS(hdr) (ntohs((hdr)->_v_hl_tos) & 0xff)
12 #define UIP_IPH_LEN(hdr) ((hdr)->_len)
13 #define UIP_IPH_ID(hdr) ((hdr)->_id)
14 #define UIP_IPH_OFFSET(hdr) ((hdr)->_offset)
15 #define UIP_IPH_TTL(hdr) (ntohs((hdr)->_ttl_proto) >> 8)
16 #define UIP_IPH_PROTO(hdr) (ntohs((hdr)->_ttl_proto) & 0xff)
17 #define UIP_IPH_CHKSUM(hdr) ((hdr)->_chksum)
18 
19 #define UIP_IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
20 #define UIP_IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
21 #define UIP_IPH_ID_SET(hdr, id) (hdr)->_id = (id)
22 #define UIP_IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
23 #define UIP_IPH_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(UIP_IPH_PROTO(hdr) | ((ttl) << 8)))
24 #define UIP_IPH_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (htons((proto) | (UIP_IPH_TTL(hdr) << 8)))
25 #define UIP_IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
26 
27 /*
28  * Option flags per-socket. These are the same like SO_XXX.
29  */
30 #define UIP_SOF_DEBUG (u16_t)0x0001U /* turn on debugging info recording */
31 #define UIP_SOF_ACCEPTCONN (u16_t)0x0002U /* socket has had listen() */
32 #define UIP_SOF_REUSEADDR (u16_t)0x0004U /* allow local address reuse */
33 #define UIP_SOF_KEEPALIVE (u16_t)0x0008U /* keep connections alive */
34 #define UIP_SOF_DONTROUTE (u16_t)0x0010U /* just use interface addresses */
35 #define UIP_SOF_BROADCAST (u16_t)0x0020U /* permit sending of broadcast msgs */
36 #define UIP_SOF_USELOOPBACK (u16_t)0x0040U /* bypass hardware when possible */
37 #define UIP_SOF_LINGER (u16_t)0x0080U /* linger on close if data present */
38 #define UIP_SOF_OOBINLINE (u16_t)0x0100U /* leave received OOB data in line */
39 #define UIP_SOF_REUSEPORT (u16_t)0x0200U /* allow local address & port reuse */
40 
41 #define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = htonl(((u32_t)(a & 0xff) << 24) | ((u32_t)(b & 0xff) << 16) | \
42  ((u32_t)(c & 0xff) << 8) | (u32_t)(d & 0xff))
43 
44 #define ip_addr_set(dest, src) (dest)->addr = \
45  ((src) == NULL? 0:\
46  (src)->addr)
47 
56 #define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
57  (mask)->addr) == \
58  ((addr2)->addr & \
59  (mask)->addr))
60 #define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
61 
62 #define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == 0)
63 
64 #define ip_addr_isbroadcast uip_ipaddr_isbroadcast
65 
66 #define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
67 
68 #define ip4_addr1(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
69 #define ip4_addr2(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
70 #define ip4_addr3(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
71 #define ip4_addr4(ipaddr) ((u16_t)(ntohl((ipaddr)->addr)) & 0xff)
72 
73 #ifndef HAVE_IN_ADDR
74 #define HAVE_IN_ADDR
75 struct in_addr {
76  u32 s_addr;
77 };
78 #endif
79 
80 /* The IP Address */
82 struct uip_ip_addr {
86 
88 struct uip_ip_addr2 {
89  PACK_STRUCT_FIELD(u16_t addrw[2]);
92 
93 /* The IP Header */
95 struct uip_ip_hdr {
96 #define UIP_IP_RF 0x8000
97 #define UIP_IP_DF 0x4000
98 #define UIP_IP_MF 0x2000
99 #define UIP_IP_OFFMASK 0x1fff
100  PACK_STRUCT_FIELD(u16_t _v_hl_tos);
101  PACK_STRUCT_FIELD(u16_t _len);
104  PACK_STRUCT_FIELD(u16_t _ttl_proto);
105  PACK_STRUCT_FIELD(u16_t _chksum);
106 
111 
112 #define UIP_IP_PCB \
113  struct uip_ip_addr local_ip; \
114  struct uip_ip_addr remote_ip; \
115  u16_t so_options; \
116  u8_t tos; \
117  u8_t ttl
118 
119 struct uip_pbuf;
120 struct uip_netif;
121 struct ip_addr;
122 
123 
124 void uip_ipinit();
125 
126 u32_t uip_ipaddr(const u8_t *cp);
127 s32_t uip_ipaton(const u8_t *cp,struct in_addr *addr);
128 s8_t uip_ipinput(struct uip_pbuf *p,struct uip_netif *inp);
129 s8_t uip_ipoutput(struct uip_pbuf *p,struct uip_ip_addr *src,struct uip_ip_addr *dst,u8_t ttl,u8_t tos,u8_t proto);
130 s8_t uip_ipoutput_if(struct uip_pbuf *p,struct uip_ip_addr *src,struct uip_ip_addr *dst,u8_t ttl,u8_t tos,u8_t proto,struct uip_netif *netif);
131 struct uip_netif* uip_iproute(struct uip_ip_addr *dst);
133 
134 
135 #endif
Definition: uip_ip.h:82
PACK_STRUCT_FIELD(u32_t addr)
s8 s8_t
Definition: cc.h:44
PACK_STRUCT_BEGIN struct uip_ip_addr PACK_STRUCT_STRUCT
Definition: ip_addr.h:41
Definition: uip_ip.h:95
NSUInteger _offset
Definition: Context.m:698
#define PACK_STRUCT_BEGIN
Definition: arch.h:46
Definition: ip_addr.h:64
Definition: uip_pbuf.h:27
Definition: netif.h:72
PACK_STRUCT_FIELD(u16_t addrw[2])
struct uip_netif * uip_iproute(struct uip_ip_addr *dst)
Definition: uip_ip.c:253
void uip_ipinit()
Definition: uip_ip.c:410
u32_t uip_ipaddr(const u8_t *cp)
Definition: uip_ip.c:483
GLenum const GLvoid * addr
Definition: glext.h:10528
u8_t uip_ipaddr_isbroadcast(struct uip_ip_addr *addr, struct uip_netif *netif)
Definition: uip_ip.c:264
s8_t uip_ipoutput_if(struct uip_pbuf *p, struct uip_ip_addr *src, struct uip_ip_addr *dst, u8_t ttl, u8_t tos, u8_t proto, struct uip_netif *netif)
Definition: uip_ip.c:359
GLenum src
Definition: glext.h:6980
GLfloat GLfloat p
Definition: glext.h:9809
#define PACK_STRUCT_END
Definition: arch.h:50
s8_t uip_ipinput(struct uip_pbuf *p, struct uip_netif *inp)
Definition: uip_ip.c:280
u8 u8_t
Definition: cc.h:43
const char * proto
Definition: civetweb.c:11575
PACK_STRUCT_FIELD(u16_t _v_hl_tos)
Definition: uip_ip.h:88
s32 s32_t
Definition: cc.h:48
s32_t uip_ipaton(const u8_t *cp, struct in_addr *addr)
Definition: uip_ip.c:415
u32 u32_t
Definition: cc.h:47
GLenum GLenum dst
Definition: glext.h:6980
u32_t s_addr
Definition: ip_addr.h:65
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
s8_t uip_ipoutput(struct uip_pbuf *p, struct uip_ip_addr *src, struct uip_ip_addr *dst, u8_t ttl, u8_t tos, u8_t proto)
Definition: uip_ip.c:399
Definition: uip_netif.h:29
u16 u16_t
Definition: cc.h:45