The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
netaddr.h
Go to the documentation of this file.
1 
26 #ifndef _NETADDR_H
27 #define _NETADDR_H
28 #include <projectcommon.h>
29 #include <assimobj.h>
30 #ifdef _MSC_VER
31 # include <winsock2.h>
32  typedef int socklen_t;
33 #else
34 # include <netinet/in.h>
35 #endif
36 typedef struct _NetAddr NetAddr;
37 
43 struct _NetAddr {
45  void (*setport)(NetAddr*, guint16);
46  guint16 (*port)(const NetAddr* self);
47  guint16 (*addrtype)(const NetAddr* self);
48  gboolean (*ismcast)(const NetAddr* self);
49  gboolean (*islocal)(const NetAddr* self);
50  gboolean (*isanyaddr)(const NetAddr* self);
51  struct sockaddr_in6(*ipv6sockaddr)(const NetAddr* self);
52  struct sockaddr_in(*ipv4sockaddr)(const NetAddr* self);
53  gboolean (*equal)(const NetAddr*,const NetAddr*);
54  guint (*hash)(const NetAddr*);
55  char * (*canonStr)(const NetAddr*);
56  NetAddr* (*toIPv6)(const NetAddr*);
57  gpointer _addrbody;
59  guint16 _addrtype;
60  guint16 _addrlen;
61  guint16 _addrport;
62 
63 };
64 WINEXPORT NetAddr* netaddr_new(gsize objsize, guint16 port, guint16 addrtype, gconstpointer addrbody, guint16 addrlen);
65 WINEXPORT NetAddr* netaddr_sockaddr_new(const struct sockaddr_in6 *, socklen_t);
66 WINEXPORT NetAddr* netaddr_macaddr_new(gconstpointer macbuf, guint16 maclen);
67 WINEXPORT NetAddr* netaddr_mac48_new(gconstpointer macbuf);
68 WINEXPORT NetAddr* netaddr_mac64_new(gconstpointer macbuf);
69 WINEXPORT NetAddr* netaddr_ipv4_new(gconstpointer ipbuf, guint16 port);
70 WINEXPORT NetAddr* netaddr_ipv6_new(gconstpointer ipbuf, guint16 port);
71 WINEXPORT NetAddr* netaddr_string_new(const char* addrstr);
72 WINEXPORT NetAddr* netaddr_dns_new(const char* addrstr);
73 WINEXPORT gboolean netaddr_g_hash_equal(gconstpointer lhs, gconstpointer rhs);
74 WINEXPORT guint netaddr_g_hash_hash(gconstpointer addrptr);
75 
76 #define CONST_IPV6_LOOPBACK {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}
77 #define CONST_IPV4_LOOPBACK {127,0,0,1}
78 #define CONST_IPV6_IPV4SPACE 0,0,0,0,0,0,0,0,0,0,0xff,0xff
79 #define CONST_IPV6_IPV4START {CONST_IPV6_IPV4SPACE, 0, 0, 0, 0}
80 #define CONST_IPV6_MACSPACE 0xFE, 0x80, 0, 0, 0, 0, 0, 0x02
81 #define CONST_IPV6_MACSTART {CONST_IPV6_MACSPACE, 0, 0, 0, 0, 0, 0, 0, 0}
82 
83 
84 #define CONST_ASSIM_DEFAULT_V4_MCAST {224,0,2,5}
85 
86 
88 #endif /* _NETADDR_H */