The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
NetAddr class

This is our basic NetAddr object. More...

Collaboration diagram for NetAddr class:

Data Structures

struct  _NetAddr
 The NetAddr class class represents a general network address - whether IP, MAC, or any other type of address. More...
 

Macros

#define CHAR_BIT   8
 

Functions

FSTATIC gchar * _netaddr_toString_ipv6_ipv4 (const NetAddr *self, gboolean ipv4format)
 Convert this IPv6-encapsulated IPv4 NetAddr to a string. More...
 
FSTATIC gchar * _netaddr_toString (gconstpointer baseobj)
 Convert this IPv6-encapsulated IPv4 NetAddr to an IPv4 representation Convert this NetAddr to a string. More...
 
FSTATIC gchar * _netaddr_canonStr (const NetAddr *)
 
FSTATIC NetAddr_netaddr_toIPv6 (const NetAddr *self)
 Convert this IPv6-encapsulated IPv4 NetAddr to an IPv4 representation. More...
 
FSTATIC gchar * _netaddr_toStringflex (const NetAddr *self, gboolean canon_format)
 Convert this NetAddr to a string. More...
 
FSTATIC gboolean _netaddr_equal (const NetAddr *self, const NetAddr *other)
 Return TRUE if these two addresses are "equal" (equivalent) More...
 
FSTATIC guint _netaddr_hash (const NetAddr *self)
 NetAddr hash function which worries about denial of service via hash collisions. More...
 
WINEXPORT gboolean netaddr_g_hash_equal (gconstpointer lhs, gconstpointer rhs)
 g_hash_table equal comparator for a NetAddr More...
 
WINEXPORT guint netaddr_g_hash_hash (gconstpointer addrptr)
 g_hash_table hash function for a NetAddr More...
 
FSTATIC void _netaddr_finalize (AssimObj *base)
 Finalize (free) this object. More...
 
FSTATIC guint16 _netaddr_port (const NetAddr *self)
 Return the port of this NetAddr. More...
 
FSTATIC void _netaddr_setport (NetAddr *self, guint16 port)
 Set the port of this NetAddr. More...
 
FSTATIC guint16 _netaddr_addrtype (const NetAddr *self)
 Return the address type of this NetAddr. More...
 
FSTATIC gboolean _netaddr_ismcast (const NetAddr *self)
 Return TRUE if this is a multicast address. More...
 
FSTATIC gboolean _netaddr_islocal (const NetAddr *self)
 Return TRUE if this is a multicast address. More...
 
FSTATIC gboolean _netaddr_isanyaddr (const NetAddr *self)
 
NetAddrnetaddr_new (gsize objsize, guint16 port, guint16 addrtype, gconstpointer addrbody, guint16 addrlen)
 Generic NetAddr constructor. More...
 
FSTATIC NetAddr_netaddr_string_ipv4_new (const char *addrstr)
 Convert a string to an IPv4 NetAddr. More...
 
FSTATIC NetAddr_netaddr_string_ipv6_new (const char *addrstr)
 Convert a string into an IPv6 address - possibly including a port as per RFC 4291. More...
 
FSTATIC NetAddr_netaddr_string_macaddr_new (const char *addrstr)
 Create a NetAddr from a 48-bit or 64-bit-format MAC address string. More...
 
NetAddrnetaddr_string_new (const char *addrstr)
 Create a NetAddr from an ipv4, ipv6 or MAC address string. More...
 
NetAddrnetaddr_dns_new (const char *sysname_or_addr)
 Create a NetAddr from a DNS name or an ipv4 or ipv6 constant string. More...
 
NetAddrnetaddr_macaddr_new (gconstpointer macbuf, guint16 maclen)
 Create new NetAddr from a MAC address. More...
 
NetAddrnetaddr_mac48_new (gconstpointer macbuf)
 Create new NetAddr from a MAC48 address. More...
 
NetAddrnetaddr_mac64_new (gconstpointer macbuf)
 Create new NetAddr from a MAC64 address. More...
 
NetAddrnetaddr_ipv4_new (gconstpointer ipbuf, guint16 port)
 Create new NetAddr from a IPv4 address. More...
 
NetAddrnetaddr_ipv6_new (gconstpointer ipbuf, guint16 port)
 Create new NetAddr from a IPv6 address. More...
 
NetAddrnetaddr_sockaddr_new (const struct sockaddr_in6 *sa_in6, socklen_t length)
 Create new NetAddr from a struct sockaddr More...
 
FSTATIC struct sockaddr_in6 _netaddr_ipv6sockaddr (const NetAddr *self)
 
FSTATIC struct sockaddr_in _netaddr_ipv4sockaddr (const NetAddr *self)
 

Detailed Description

This is our basic NetAddr object.

It represents network addresses of any of a wide variety of well-known well-known types. It is a class from which we might eventually make subclasses, and is managed by our C-Class Management system.

Macro Definition Documentation

#define CHAR_BIT   8

Definition at line 321 of file netaddr.c.

Referenced by _netaddr_hash().

Function Documentation

FSTATIC guint16 _netaddr_addrtype ( const NetAddr self)

Return the address type of this NetAddr.

Definition at line 435 of file netaddr.c.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC gchar * _netaddr_canonStr ( const NetAddr self)

Definition at line 122 of file netaddr.c.

References _netaddr_toStringflex().

Referenced by netaddr_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gboolean _netaddr_equal ( const NetAddr self,
const NetAddr other 
)

Return TRUE if these two addresses are "equal" (equivalent)

Todo:
Perhaps we ought to eventually compare for MAC addresses and IPv6 equivalents ;-)
Todo:
Not sure if it should treat the two loopbacks as the same...

Definition at line 240 of file netaddr.c.

References __FUNCTION__, _NetAddr::_addrbody, _NetAddr::_addrlen, _NetAddr::_addrport, _NetAddr::_addrtype, ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, CONST_IPV6_IPV4SPACE, and DEBUGMSG5.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC void _netaddr_finalize ( AssimObj self)

Finalize (free) this object.

Definition at line 405 of file netaddr.c.

References CASTTOCLASS, FREE, and FREECLASSOBJ.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC guint _netaddr_hash ( const NetAddr self)

NetAddr hash function which worries about denial of service via hash collisions.

Note that this function will produce results unique to this process instance. This is to avoid denial of service through has hash collisions

Definition at line 327 of file netaddr.c.

References __FUNCTION__, _NetAddr::_addrbody, _NetAddr::_addrlen, _NetAddr::_addrport, _NetAddr::_addrtype, _netaddr_toIPv6(), ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, CHAR_BIT, CONST_IPV6_LOOPBACK, DEBUGMSG5, netaddr_ipv6_new(), and UNREF.

Referenced by netaddr_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC struct sockaddr_in _netaddr_ipv4sockaddr ( const NetAddr self)

Definition at line 1112 of file netaddr.c.

References ADDR_FAMILY_IPV4.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC struct sockaddr_in6 _netaddr_ipv6sockaddr ( const NetAddr self)
Todo:
May need to account for the "any" IPv4 address here and translate it into the "any" IPv6 address...

Definition at line 1065 of file netaddr.c.

References __FUNCTION__, ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, and DEBUGMSG3.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC gboolean _netaddr_isanyaddr ( const NetAddr self)

Definition at line 485 of file netaddr.c.

References ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, anyaddr, and CONST_IPV6_IPV4SPACE.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC gboolean _netaddr_islocal ( const NetAddr self)

Return TRUE if this is a multicast address.

Definition at line 459 of file netaddr.c.

References ADDR_FAMILY_IPV4, and ADDR_FAMILY_IPV6.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC gboolean _netaddr_ismcast ( const NetAddr self)

Return TRUE if this is a multicast address.

Todo:
recognize IPv6 multicast addresses too...

Definition at line 442 of file netaddr.c.

References ADDR_FAMILY_IPV4.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC guint16 _netaddr_port ( const NetAddr self)

Return the port of this NetAddr.

Definition at line 419 of file netaddr.c.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC void _netaddr_setport ( NetAddr self,
guint16  port 
)

Set the port of this NetAddr.

Definition at line 427 of file netaddr.c.

Referenced by netaddr_new().

Here is the caller graph for this function:

FSTATIC NetAddr * _netaddr_string_ipv4_new ( const char *  addrstr)

Convert a string to an IPv4 NetAddr.

Definition at line 550 of file netaddr.c.

References DIMOF, and netaddr_ipv4_new().

Referenced by netaddr_string_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC NetAddr * _netaddr_string_ipv6_new ( const char *  addrstr)

Convert a string into an IPv6 address - possibly including a port as per RFC 4291.

Format is either abcd:efab:cdab:cdef:abcd:efab:cdab:cdef with :: standing in for missing zeroes - or [abcd:efab:cdab:cdef:abcd:efab:cdab:cdef]:port-in-decimal - as per standard convention and the RFC.

Definition at line 666 of file netaddr.c.

References __FUNCTION__, _NetAddr::baseclass, CONST_IPV6_IPV4SPACE, DEBUGMSG5, DIMOF, DUMP5, and netaddr_ipv6_new().

Referenced by netaddr_string_new().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr * _netaddr_string_macaddr_new ( const char *  addrstr)

Create a NetAddr from a 48-bit or 64-bit-format MAC address string.

  • either : or - are permitted as the delimter between bytes (octets)

Definition at line 878 of file netaddr.c.

References DIMOF, netaddr_mac48_new(), and netaddr_mac64_new().

Referenced by netaddr_string_new().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr * _netaddr_toIPv6 ( const NetAddr self)

Convert this IPv6-encapsulated IPv4 NetAddr to an IPv4 representation.

Todo:
Convert MAC addresses to IPv6 addresses??

Definition at line 129 of file netaddr.c.

References ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, CONST_IPV6_IPV4SPACE, and netaddr_ipv6_new().

Referenced by _netaddr_hash(), and netaddr_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gchar * _netaddr_toString ( gconstpointer  baseobj)

Convert this IPv6-encapsulated IPv4 NetAddr to an IPv4 representation Convert this NetAddr to a string.

Definition at line 115 of file netaddr.c.

References _netaddr_toStringflex(), and CASTTOCONSTCLASS.

Referenced by netaddr_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gchar * _netaddr_toString_ipv6_ipv4 ( const NetAddr self,
gboolean  ipv4format 
)

Convert this IPv6-encapsulated IPv4 NetAddr to a string.

Definition at line 83 of file netaddr.c.

Referenced by _netaddr_toStringflex().

Here is the caller graph for this function:

FSTATIC gchar * _netaddr_toStringflex ( const NetAddr self,
gboolean  canonformat 
)

Convert this NetAddr to a string.

Definition at line 160 of file netaddr.c.

References _netaddr_toString_ipv6_ipv4(), ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, and cma.tests.cma_test::byte1.

Referenced by _netaddr_canonStr(), and _netaddr_toString().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_dns_new ( const char *  sysname_or_addr)

Create a NetAddr from a DNS name or an ipv4 or ipv6 constant string.

Definition at line 943 of file netaddr.c.

References __FUNCTION__, DEBUGMSG, netaddr_sockaddr_new(), and netaddr_string_new().

Referenced by cma.AssimCclasses.pyNetAddr::__init__().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT gboolean netaddr_g_hash_equal ( gconstpointer  lhs,
gconstpointer  rhs 
)

g_hash_table equal comparator for a NetAddr

Definition at line 388 of file netaddr.c.

References CASTTOCONSTCLASS, and _NetAddr::equal.

Referenced by main(), and netio_new().

Here is the caller graph for this function:

WINEXPORT guint netaddr_g_hash_hash ( gconstpointer  addrptr)

g_hash_table hash function for a NetAddr

Definition at line 397 of file netaddr.c.

References CASTTOCONSTCLASS.

Referenced by main(), and netio_new().

Here is the caller graph for this function:

NetAddr* netaddr_ipv4_new ( gconstpointer  ipbuf,
guint16  port 
)

Create new NetAddr from a IPv4 address.

Parameters
[in]ipbufPointer to 4-byte IPv4 address
[in]portPort (or zero for non-port-specific IP address)

Definition at line 1024 of file netaddr.c.

References ADDR_FAMILY_IPV4, and netaddr_new().

Referenced by cma.AssimCclasses.pySwitchDiscovery::__init__(), cma.AssimCclasses.pyNetAddr::__init__(), _netaddr_string_ipv4_new(), main(), and cma.AssimCclasses.pyNetIO::recvframesets().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_ipv6_new ( gconstpointer  ipbuf,
guint16  port 
)

Create new NetAddr from a IPv6 address.

Parameters
[in]ipbufPointer to 16-byte IPv6 address
[in]portPort (or zero for non-port-specific IP address)

Definition at line 1032 of file netaddr.c.

References ADDR_FAMILY_IPV6, and netaddr_new().

Referenced by cma.AssimCclasses.pySwitchDiscovery::__init__(), cma.AssimCclasses.pyNetAddr::__init__(), _netaddr_hash(), _netaddr_string_ipv6_new(), _netaddr_toIPv6(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_mac48_new ( gconstpointer  macbuf)

Create new NetAddr from a MAC48 address.

Parameters
[in]macbufPointer to physical (MAC) address

Definition at line 1010 of file netaddr.c.

References netaddr_macaddr_new().

Referenced by cma.AssimCclasses.pySwitchDiscovery::__init__(), cma.AssimCclasses.pyNetAddr::__init__(), _netaddr_string_macaddr_new(), and cma.AssimCclasses.pySwitchDiscovery::decode_discovery().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_mac64_new ( gconstpointer  macbuf)

Create new NetAddr from a MAC64 address.

Parameters
[in]macbufPointer to physical (MAC) address

Definition at line 1017 of file netaddr.c.

References netaddr_macaddr_new().

Referenced by cma.AssimCclasses.pySwitchDiscovery::__init__(), cma.AssimCclasses.pyNetAddr::__init__(), _netaddr_string_macaddr_new(), and cma.AssimCclasses.pySwitchDiscovery::decode_discovery().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_macaddr_new ( gconstpointer  macbuf,
guint16  maclen 
)

Create new NetAddr from a MAC address.

Parameters
[in]macbufPointer to physical (MAC) address
[in]maclenlength of 'macbuf'

Definition at line 1000 of file netaddr.c.

References ADDR_FAMILY_802, and netaddr_new().

Referenced by netaddr_mac48_new(), and netaddr_mac64_new().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_new ( gsize  objsize,
guint16  port,
guint16  addrtype,
gconstpointer  addrbody,
guint16  addrlen 
)

Generic NetAddr constructor.

Parameters
[in]objsizeSize of object to construct
[in]portPort (if applicable)
[in]addrtypeIETF/IANA address type
[in]addrbodyPointer to address body
[in]addrlenLength of address

Definition at line 501 of file netaddr.c.

References _NetAddr::_addrport, _AssimObj::_finalize, _netaddr_addrtype(), _netaddr_canonStr(), _netaddr_equal(), _netaddr_finalize(), _netaddr_hash(), _netaddr_ipv4sockaddr(), _netaddr_ipv6sockaddr(), _netaddr_isanyaddr(), _netaddr_islocal(), _netaddr_ismcast(), _netaddr_port(), _netaddr_setport(), _netaddr_toIPv6(), _netaddr_toString(), assimobj_new(), BINDDEBUG, CASTTOCLASS, proj_class_register_subclassed(), and _AssimObj::toString.

Referenced by _addrframe_setaddr(), _ipportframe_setaddr(), netaddr_ipv4_new(), netaddr_ipv6_new(), netaddr_macaddr_new(), and netaddr_sockaddr_new().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_sockaddr_new ( const struct sockaddr_in6 *  sa_in6,
socklen_t  length 
)

Create new NetAddr from a struct sockaddr

Todo:
convert IPv4 encapsulated addresses to real IPv4 addresses??
Parameters
[in]sa_in6struct sockaddr to construct address from
[in]lengthnumber of bytes in 'sa'

Definition at line 1043 of file netaddr.c.

References ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, and netaddr_new().

Referenced by _netio_boundaddr(), _netio_recvframesets(), and netaddr_dns_new().

Here is the call graph for this function:

Here is the caller graph for this function:

NetAddr* netaddr_string_new ( const char *  addrstr)

Create a NetAddr from an ipv4, ipv6 or MAC address string.

Definition at line 915 of file netaddr.c.

References _netaddr_string_ipv4_new(), _netaddr_string_ipv6_new(), and _netaddr_string_macaddr_new().

Referenced by _configcontext_JSON_parse_value(), main(), nanoobey_setconfig(), netaddr_dns_new(), and test_childprocess_modenv().

Here is the call graph for this function:

Here is the caller graph for this function: