25 #define MAX_IP_SZ (MAX_IP_INT*sizeof(int))
30 #define IPV6_ADDR_BROADCAST { 0xff020000, 0x0, 0x0, 0x1 }
32 #define LOOPBACK_IP 0x7f000001
33 #define LOOPBACK_NET 0x7f000000
34 #define LOOPBACK_BCAST 0x7fffffff
36 #define LOOPBACK_IPV6 { 0x0, 0x0, 0x0, 0x1 }
53 #define NTK_RESTRICTED_10_MASK(x) (((x) & ~0xff000000)|0x0a000000)
54 #define NTK_RESTRICTED_172_MASK(x) (((((x) & ~0xff000000) | 0xac000000) & ~0x00e00000) | 0x00100000)
55 #define NTK_RESTRICTED_IPV6_MASK(x) (((x) & ~0xffff0000)|0xfec00000)
60 #define NTK_PRIVATE_C(x) (((x) & __constant_htonl(0xffff0000)) == __constant_htonl(0xc0a80000))
64 #define NTK_PRIVATE_B(x) (((x) & __constant_htonl(0xff000000)) == __constant_htonl(0xac000000))\
65 && ((x) & __constant_htonl(0x00100000)) && \
66 !((x) & __constant_htonl(0x00e00000))
90 #define INET_PREFIX_PACK_SZ (sizeof(u_char) + sizeof(u_short) +\
91 sizeof(u_char) + MAX_IP_SZ)
95 #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000))
96 #define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
97 #define BADCLASS(x) (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
98 #define ZERONET(x) (((x) & htonl(0xff000000)) == htonl(0x00000000))
99 #define LOCAL_MCAST(x) (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
102 #define IPV6_ADDR_ANY 0x0000U
104 #define IPV6_ADDR_UNICAST 0x0001U
105 #define IPV6_ADDR_MULTICAST 0x0002U
107 #define IPV6_ADDR_LOOPBACK 0x0010U
108 #define IPV6_ADDR_LINKLOCAL 0x0020U
109 #define IPV6_ADDR_SITELOCAL 0x0040U
111 #define IPV6_ADDR_COMPATv4 0x0080U
113 #define IPV6_ADDR_SCOPE_MASK 0x00f0U
115 #define IPV6_ADDR_MAPPED 0x1000U
116 #define IPV6_ADDR_RESERVED 0x2000U
121 #ifndef IPTOS_LOWDELAY
122 #define IPTOS_LOWDELAY 0x10
123 #define IPTOS_THROUGHPUT 0x08
124 #define IPTOS_RELIABILITY 0x04
125 #define IPTOS_LOWCOST 0x02
126 #define IPTOS_MINCOST IPTOS_LOWCOST
134 #define RESTRICTED_10 1
136 #define RESTRICTED_172 2
138 #define RESTRICTED_10_STR "10.0.0.0-10.255.255.255"
139 #define RESTRICTED_172_STR "172.16.0.0-172.31.255.255"
193 struct sockaddr *from,
socklen_t *fromlen);
196 struct sockaddr *from,
socklen_t *fromlen, u_int timeout);
199 const struct sockaddr *to,
socklen_t tolen);
202 const struct sockaddr *to,
socklen_t tolen, u_int timeout);
203 ssize_t
inet_sendfile(
int out_fd,
int in_fd, off_t *offset,
size_t count);
ssize_t inet_sendto_timeout(int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen, u_int timeout)
Definition: inet.c:1079
int inet_is_ip_local(inet_prefix *ip, int class)
Definition: inet.c:176
int join_ipv6_multicast(int socket, int idx)
Definition: inet.c:601
const char * inet_to_str(inet_prefix ip)
Definition: inet.c:432
int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits)
Definition: inet.c:273
u_char family
Definition: inet.h:75
u_short len
Definition: inet.h:76
int new_broadcast_sk(int family, int dev_idx)
int inet_setip_bcast(inet_prefix *ip, int family)
Definition: inet.c:101
int set_tos_sk(int socket, int lowdelay)
Definition: inet.c:782
int ipv6_addr_type(inet_prefix addr)
Definition: inet.c:301
int inet_close(int *sk)
Definition: inet.c:575
void inet_copy_ipdata_raw(u_int *dst_data, inet_prefix *ip)
Definition: inet.c:198
#define INT_TYPE_16BIT
Definition: endianness.h:36
int new_tcp_conn(inet_prefix *host, short port, char *dev)
Definition: inet.c:801
ssize_t inet_recv(int s, void *buf, size_t len, int flags)
Definition: inet.c:905
int set_keepalive_sk(int socket)
Definition: inet.c:758
int inet_getpeername(int sk, inet_prefix *ip, short *port)
Definition: inet.c:581
const char * ipraw_to_str(u_int ip[4], int family)
Definition: inet.c:407
void inet_copy_ipdata(u_int *dst_data, inet_prefix *ip)
Definition: inet.c:207
ssize_t inet_send(int s, const void *msg, size_t len, int flags)
Definition: inet.c:997
int new_dgram_socket(int sock_type)
Definition: inet.c:558
void pack_inet_prefix(inet_prefix *ip, char *pack)
Definition: inet.c:221
void inet_ntohl(u_int *data, int family)
Definition: inet.c:34
int new_udp_conn(inet_prefix *host, short port, char *dev)
Definition: inet.c:830
int inet_setip_loopback(inet_prefix *ip, int family)
Definition: inet.c:132
void unpack_inet_prefix(inet_prefix *ip, char *pack)
Definition: inet.c:247
int inet_to_sockaddr(inet_prefix *ip, u_short port, struct sockaddr *dst, socklen_t *dstlen)
Definition: inet.c:477
#define MAX_IP_INT
Definition: inet.h:24
int unset_keepalive_sk(int socket)
Definition: inet.c:770
int new_socket(int sock_type)
Definition: inet.c:547
ssize_t inet_sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
Definition: inet.c:1104
u_char bits
Definition: inet.h:77
int set_nonblock_sk(int fd)
Definition: inet.c:635
int set_reuseaddr_sk(int socket)
Definition: inet.c:657
unsigned int socklen_t
Definition: libip4tc.c:26
int my_family
Definition: inet.h:141
int set_broadcast_sk(int socket, int family, inet_prefix *host, short port, int dev_idx)
Definition: inet.c:703
ssize_t inet_send_timeout(int s, const void *msg, size_t len, int flags, u_int timeout)
Definition: inet.c:1025
int str_to_inet(const char *src, inet_prefix *ip)
Definition: inet.c:442
int restricted_mode
Definition: inet.h:141
ssize_t inet_recvfrom_timeout(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen, u_int timeout)
Definition: inet.c:973
#define INT_INFO
Definition: endianness.h:90
int inet_setip_raw(inet_prefix *ip, u_int *data, int family)
Definition: inet.c:70
void inet_copy(inet_prefix *dst, inet_prefix *src)
Definition: inet.c:190
int inet_setip_anyaddr(inet_prefix *ip, int family)
Definition: inet.c:116
int inet_setip_localaddr(inet_prefix *ip, int family, int class)
Definition: inet.c:155
int sockaddr_to_inet(struct sockaddr *ip, inet_prefix *dst, u_short *port)
Definition: inet.c:515
ssize_t inet_recv_timeout(int s, void *buf, size_t len, int flags, u_int timeout)
Definition: inet.c:931
int restricted_class
Definition: inet.h:141
void inet_htonl(u_int *data, int family)
Definition: inet.c:53
static const int_info inet_prefix_iinfo
Definition: inet.h:85
ssize_t inet_sendto(int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
Definition: inet.c:1050
int inet_validate_ip(inet_prefix ip)
Definition: inet.c:372
int family
Definition: if.c:34
int flags
Definition: if.c:39
int inet_setip(inet_prefix *ip, u_int *data, int family)
Definition: inet.c:94
int new_bcast_conn(inet_prefix *host, short port, int dev_idx)
Definition: inet.c:860
int unset_nonblock_sk(int fd)
Definition: inet.c:646
ssize_t inet_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
Definition: inet.c:951
int set_bindtodevice_sk(int socket, char *dev)
Definition: inet.c:670