The Assimilation Monitoring 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  struct sockaddr_in6(*ipv6sockaddr)(const NetAddr* self);
51  struct sockaddr_in(*ipv4sockaddr)(const NetAddr* self);
52  gboolean (*equal)(const NetAddr*,const NetAddr*);
53  guint (*hash)(const NetAddr*);
54  char * (*canonStr)(const NetAddr*);
55  NetAddr* (*toIPv6)(const NetAddr*);
56 
57  gpointer _addrbody;
58  guint16 _addrtype;
59  guint16 _addrlen;
60  guint16 _addrport;
61 
62 };
63 WINEXPORT NetAddr* netaddr_new(gsize objsize, guint16 port, guint16 addrtype, gconstpointer addrbody, guint16 addrlen);
64 WINEXPORT NetAddr* netaddr_sockaddr_new(const struct sockaddr_in6 *, socklen_t);
65 WINEXPORT NetAddr* netaddr_macaddr_new(gconstpointer macbuf, guint16 maclen);
66 WINEXPORT NetAddr* netaddr_mac48_new(gconstpointer macbuf);
67 WINEXPORT NetAddr* netaddr_mac64_new(gconstpointer macbuf);
68 WINEXPORT NetAddr* netaddr_ipv4_new(gconstpointer ipbuf, guint16 port);
69 WINEXPORT NetAddr* netaddr_ipv6_new(gconstpointer ipbuf, guint16 port);
70 WINEXPORT NetAddr* netaddr_string_new(const char* addrstr);
71 WINEXPORT gboolean netaddr_g_hash_equal(gconstpointer lhs, gconstpointer rhs);
72 WINEXPORT guint netaddr_g_hash_hash(gconstpointer addrptr);
73 
74 #define CONST_IPV6_LOOPBACK {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}
75 #define CONST_IPV4_LOOPBACK {127,0,0,1}
76 #define CONST_IPV6_IPV4SPACE 0,0,0,0,0,0,0,0,0,0,0xff,0xff
77 #define CONST_IPV6_IPV4START {CONST_IPV6_IPV4SPACE, 0, 0, 0, 0}
78 #define CONST_IPV6_MACSPACE 0xFE, 0x80, 0, 0, 0, 0, 0, 0x02
79 #define CONST_IPV6_MACSTART {CONST_IPV6_MACSPACE, 0, 0, 0, 0, 0, 0, 0, 0}
80 
81 
82 #define CONST_ASSIM_DEFAULT_V4_MCAST {224,0,2,5}
83 
84 
85 
86 #endif /* _NETADDR_H */