The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
inet.h File Reference
#include "endianness.h"
Include dependency graph for inet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  inet_prefix
 

Macros

#define MAX_IP_INT   4
 
#define MAX_IP_SZ   (MAX_IP_INT*sizeof(int))
 
#define IPV6_ADDR_BROADCAST   { 0xff020000, 0x0, 0x0, 0x1 }
 
#define LOOPBACK_IP   0x7f000001
 
#define LOOPBACK_NET   0x7f000000
 
#define LOOPBACK_BCAST   0x7fffffff
 
#define LOOPBACK_IPV6   { 0x0, 0x0, 0x0, 0x1 }
 
#define NTK_RESTRICTED_10_MASK(x)   (((x) & ~0xff000000)|0x0a000000)
 
#define NTK_RESTRICTED_172_MASK(x)   (((((x) & ~0xff000000) | 0xac000000) & ~0x00e00000) | 0x00100000)
 
#define NTK_RESTRICTED_IPV6_MASK(x)   (((x) & ~0xffff0000)|0xfec00000)
 
#define NTK_PRIVATE_C(x)   (((x) & __constant_htonl(0xffff0000)) == __constant_htonl(0xc0a80000))
 
#define NTK_PRIVATE_B(x)
 
#define INET_PREFIX_PACK_SZ
 
#define LOOPBACK(x)   (((x) & htonl(0xff000000)) == htonl(0x7f000000))
 
#define MULTICAST(x)   (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
 
#define BADCLASS(x)   (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
 
#define ZERONET(x)   (((x) & htonl(0xff000000)) == htonl(0x00000000))
 
#define LOCAL_MCAST(x)   (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
 
#define IPV6_ADDR_ANY   0x0000U
 
#define IPV6_ADDR_UNICAST   0x0001U
 
#define IPV6_ADDR_MULTICAST   0x0002U
 
#define IPV6_ADDR_LOOPBACK   0x0010U
 
#define IPV6_ADDR_LINKLOCAL   0x0020U
 
#define IPV6_ADDR_SITELOCAL   0x0040U
 
#define IPV6_ADDR_COMPATv4   0x0080U
 
#define IPV6_ADDR_SCOPE_MASK   0x00f0U
 
#define IPV6_ADDR_MAPPED   0x1000U
 
#define IPV6_ADDR_RESERVED   0x2000U /* reserved address space */
 
#define IPTOS_LOWDELAY   0x10
 
#define IPTOS_THROUGHPUT   0x08
 
#define IPTOS_RELIABILITY   0x04
 
#define IPTOS_LOWCOST   0x02
 
#define IPTOS_MINCOST   IPTOS_LOWCOST
 
#define RESTRICTED_10
 
#define RESTRICTED_172   2 /* 172.16.0.0-172.31.255.255 class */
 
#define RESTRICTED_10_STR   "10.0.0.0-10.255.255.255"
 
#define RESTRICTED_172_STR   "172.16.0.0-172.31.255.255"
 

Functions

void inet_ntohl (u_int *data, int family)
 
void inet_htonl (u_int *data, int family)
 
int inet_setip_raw (inet_prefix *ip, u_int *data, int family)
 
int inet_setip (inet_prefix *ip, u_int *data, int family)
 
int inet_setip_bcast (inet_prefix *ip, int family)
 
int inet_setip_anyaddr (inet_prefix *ip, int family)
 
int inet_setip_loopback (inet_prefix *ip, int family)
 
int inet_setip_localaddr (inet_prefix *ip, int family, int class)
 
int inet_is_ip_local (inet_prefix *ip, int class)
 
void inet_copy_ipdata_raw (u_int *dst_data, inet_prefix *ip)
 
void inet_copy_ipdata (u_int *dst_data, inet_prefix *ip)
 
void inet_copy (inet_prefix *dst, inet_prefix *src)
 
void pack_inet_prefix (inet_prefix *ip, char *pack)
 
void unpack_inet_prefix (inet_prefix *ip, char *pack)
 
int inet_addr_match (const inet_prefix *a, const inet_prefix *b, int bits)
 
int ipv6_addr_type (inet_prefix addr)
 
int inet_validate_ip (inet_prefix ip)
 
const char * ipraw_to_str (u_int ip[4], int family)
 
const char * inet_to_str (inet_prefix ip)
 
int str_to_inet (const char *src, inet_prefix *ip)
 
int inet_to_sockaddr (inet_prefix *ip, u_short port, struct sockaddr *dst, socklen_t *dstlen)
 
int sockaddr_to_inet (struct sockaddr *ip, inet_prefix *dst, u_short *port)
 
int new_socket (int sock_type)
 
int new_dgram_socket (int sock_type)
 
int inet_close (int *sk)
 
int inet_getpeername (int sk, inet_prefix *ip, short *port)
 
int join_ipv6_multicast (int socket, int idx)
 
int set_keepalive_sk (int socket)
 
int unset_keepalive_sk (int socket)
 
int set_nonblock_sk (int fd)
 
int unset_nonblock_sk (int fd)
 
int set_reuseaddr_sk (int socket)
 
int set_bindtodevice_sk (int socket, char *dev)
 
int set_broadcast_sk (int socket, int family, inet_prefix *host, short port, int dev_idx)
 
int new_broadcast_sk (int family, int dev_idx)
 
int set_tos_sk (int socket, int lowdelay)
 
int new_tcp_conn (inet_prefix *host, short port, char *dev)
 
int new_udp_conn (inet_prefix *host, short port, char *dev)
 
int new_bcast_conn (inet_prefix *host, short port, int dev_idx)
 
ssize_t inet_recv (int s, void *buf, size_t len, int flags)
 
ssize_t inet_recvfrom (int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
 
ssize_t inet_recv_timeout (int s, void *buf, size_t len, int flags, u_int timeout)
 
ssize_t inet_recvfrom_timeout (int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen, u_int timeout)
 
ssize_t inet_send (int s, const void *msg, size_t len, int flags)
 
ssize_t inet_sendto (int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
 
ssize_t inet_send_timeout (int s, const void *msg, size_t len, int flags, u_int timeout)
 
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)
 
ssize_t inet_sendfile (int out_fd, int in_fd, off_t *offset, size_t count)
 

Variables

static const int_info inet_prefix_iinfo
 
int my_family
 
int restricted_mode
 
int restricted_class
 

Macro Definition Documentation

#define BADCLASS (   x)    (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
#define INET_PREFIX_PACK_SZ
Value:
(sizeof(u_char) + sizeof(u_short) +\
sizeof(u_char) + MAX_IP_SZ)
#define MAX_IP_SZ
Definition: inet.h:25
#define IPTOS_LOWCOST   0x02
#define IPTOS_LOWDELAY   0x10
#define IPTOS_MINCOST   IPTOS_LOWCOST
#define IPTOS_RELIABILITY   0x04
#define IPTOS_THROUGHPUT   0x08
#define IPV6_ADDR_ANY   0x0000U
#define IPV6_ADDR_BROADCAST   { 0xff020000, 0x0, 0x0, 0x1 }
#define IPV6_ADDR_COMPATv4   0x0080U
#define IPV6_ADDR_LINKLOCAL   0x0020U
#define IPV6_ADDR_LOOPBACK   0x0010U
#define IPV6_ADDR_MAPPED   0x1000U
#define IPV6_ADDR_MULTICAST   0x0002U
#define IPV6_ADDR_RESERVED   0x2000U /* reserved address space */
#define IPV6_ADDR_SCOPE_MASK   0x00f0U
#define IPV6_ADDR_SITELOCAL   0x0040U
#define IPV6_ADDR_UNICAST   0x0001U
#define LOCAL_MCAST (   x)    (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
#define LOOPBACK (   x)    (((x) & htonl(0xff000000)) == htonl(0x7f000000))
#define LOOPBACK_BCAST   0x7fffffff
#define LOOPBACK_IP   0x7f000001
#define LOOPBACK_IPV6   { 0x0, 0x0, 0x0, 0x1 }
#define LOOPBACK_NET   0x7f000000
#define MAX_IP_INT   4
#define MAX_IP_SZ   (MAX_IP_INT*sizeof(int))
#define MULTICAST (   x)    (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
#define NTK_PRIVATE_B (   x)
Value:
(((x) & __constant_htonl(0xff000000)) == __constant_htonl(0xac000000))\
&& ((x) & __constant_htonl(0x00100000)) && \
!((x) & __constant_htonl(0x00e00000))
#define NTK_PRIVATE_C (   x)    (((x) & __constant_htonl(0xffff0000)) == __constant_htonl(0xc0a80000))
#define NTK_RESTRICTED_10_MASK (   x)    (((x) & ~0xff000000)|0x0a000000)
#define NTK_RESTRICTED_172_MASK (   x)    (((((x) & ~0xff000000) | 0xac000000) & ~0x00e00000) | 0x00100000)
#define NTK_RESTRICTED_IPV6_MASK (   x)    (((x) & ~0xffff0000)|0xfec00000)
#define RESTRICTED_10
Value:
1 /* We are using the 10.x.x.x class for
the restricted mode */
#define RESTRICTED_10_STR   "10.0.0.0-10.255.255.255"
#define RESTRICTED_172   2 /* 172.16.0.0-172.31.255.255 class */
#define RESTRICTED_172_STR   "172.16.0.0-172.31.255.255"
#define ZERONET (   x)    (((x) & htonl(0xff000000)) == htonl(0x00000000))

Function Documentation

int inet_addr_match ( const inet_prefix a,
const inet_prefix b,
int  bits 
)

Here is the caller graph for this function:

int inet_close ( int *  sk)

Here is the caller graph for this function:

void inet_copy ( inet_prefix dst,
inet_prefix src 
)

Here is the caller graph for this function:

void inet_copy_ipdata ( u_int *  dst_data,
inet_prefix ip 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void inet_copy_ipdata_raw ( u_int *  dst_data,
inet_prefix ip 
)

Here is the caller graph for this function:

int inet_getpeername ( int  sk,
inet_prefix ip,
short *  port 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void inet_htonl ( u_int *  data,
int  family 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int inet_is_ip_local ( inet_prefix ip,
int  class 
)

Here is the call graph for this function:

void inet_ntohl ( u_int *  data,
int  family 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t inet_recv ( int  s,
void *  buf,
size_t  len,
int  flags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t inet_recv_timeout ( int  s,
void *  buf,
size_t  len,
int  flags,
u_int  timeout 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t inet_recvfrom ( int  s,
void *  buf,
size_t  len,
int  flags,
struct sockaddr *  from,
socklen_t fromlen 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t inet_recvfrom_timeout ( int  s,
void *  buf,
size_t  len,
int  flags,
struct sockaddr *  from,
socklen_t fromlen,
u_int  timeout 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t inet_send ( int  s,
const void *  msg,
size_t  len,
int  flags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t inet_send_timeout ( int  s,
const void *  msg,
size_t  len,
int  flags,
u_int  timeout 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t inet_sendfile ( int  out_fd,
int  in_fd,
off_t *  offset,
size_t  count 
)

Here is the call graph for this function:

ssize_t inet_sendto ( int  s,
const void *  msg,
size_t  len,
int  flags,
const struct sockaddr *  to,
socklen_t  tolen 
)

Here is the call graph for this function:

Here is the caller graph for this function:

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 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int inet_setip ( inet_prefix ip,
u_int *  data,
int  family 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int inet_setip_anyaddr ( inet_prefix ip,
int  family 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int inet_setip_bcast ( inet_prefix ip,
int  family 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int inet_setip_localaddr ( inet_prefix ip,
int  family,
int  class 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int inet_setip_loopback ( inet_prefix ip,
int  family 
)

Here is the call graph for this function:

int inet_setip_raw ( inet_prefix ip,
u_int *  data,
int  family 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int inet_to_sockaddr ( inet_prefix ip,
u_short  port,
struct sockaddr *  dst,
socklen_t dstlen 
)

Here is the call graph for this function:

Here is the caller graph for this function:

const char* inet_to_str ( inet_prefix  ip)

Here is the call graph for this function:

int inet_validate_ip ( inet_prefix  ip)

Here is the call graph for this function:

Here is the caller graph for this function:

const char* ipraw_to_str ( u_int  ip[4],
int  family 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int ipv6_addr_type ( inet_prefix  addr)

Here is the caller graph for this function:

int join_ipv6_multicast ( int  socket,
int  idx 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int new_bcast_conn ( inet_prefix host,
short  port,
int  dev_idx 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int new_broadcast_sk ( int  family,
int  dev_idx 
)
int new_dgram_socket ( int  sock_type)

Here is the call graph for this function:

Here is the caller graph for this function:

int new_socket ( int  sock_type)

Here is the call graph for this function:

Here is the caller graph for this function:

int new_tcp_conn ( inet_prefix host,
short  port,
char *  dev 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int new_udp_conn ( inet_prefix host,
short  port,
char *  dev 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pack_inet_prefix ( inet_prefix ip,
char *  pack 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int set_bindtodevice_sk ( int  socket,
char *  dev 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int set_broadcast_sk ( int  socket,
int  family,
inet_prefix host,
short  port,
int  dev_idx 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int set_keepalive_sk ( int  socket)

Here is the call graph for this function:

Here is the caller graph for this function:

int set_nonblock_sk ( int  fd)

Here is the call graph for this function:

Here is the caller graph for this function:

int set_reuseaddr_sk ( int  socket)

Here is the call graph for this function:

Here is the caller graph for this function:

int set_tos_sk ( int  socket,
int  lowdelay 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int sockaddr_to_inet ( struct sockaddr *  ip,
inet_prefix dst,
u_short *  port 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int str_to_inet ( const char *  src,
inet_prefix ip 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void unpack_inet_prefix ( inet_prefix ip,
char *  pack 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int unset_keepalive_sk ( int  socket)

Here is the call graph for this function:

int unset_nonblock_sk ( int  fd)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const int_info inet_prefix_iinfo
static
Initial value:
= { 1,
{ (1<<1) },
{ sizeof(u_char) },
{ 1 }
}
int my_family
int restricted_class
int restricted_mode