The Assimilation Project  based on Assimilation version 1.1.6.1462071269
NetIO class

(Abstract) NetIO objects are able to perform network writes and reads. More...

Collaboration diagram for NetIO class:

Modules

 NetIOudp class
 A NetIOudp object performs network writes and reads on UDP sockets.
 

Functions

FSTATIC gint _netio_getfd (const NetIO *self)
 Member function to return the file descriptor underlying this NetIO object. More...
 
FSTATIC void _netio_setblockio (const NetIO *self, gboolean blocking)
 Member function to set blocking/non-blocking mode on our sockets. More...
 
FSTATIC gboolean _netio_mcastjoin (NetIO *self, const NetAddr *src, const NetAddr *localaddr)
 Set up a NetIO object to listen to (join) a particular multicast group. More...
 
FSTATIC gboolean _netio_setmcast_ttl (NetIO *self,guint8 ttlin)
 Set up the multicast TTL for this NetIO object. More...
 
FSTATIC int _netio_getsockbufsize (const NetIO *self, gboolean forinput)
 Return the kernel's idea of what our input or output socket buffer size is. More...
 
FSTATIC int _netio_setsockbufsize (const NetIO *self, gboolean forinput, gsize bufsize)
 Set the kernel's idea of what our input or output socket buffer size as close as we can We'll even do a binary search to maximize the value if we can't get what we want. More...
 
FSTATIC void _netio_maximize_sockbufsize (const NetIO *self, gboolean forinput, int desiredsize)
 Maximize the socket buffer size as requested - as best we can... More...
 
FSTATIC gboolean _netio_input_queued (const NetIO *self)
 Member function that returns TRUE if input is ready to be read. More...
 
FSTATIC gboolean _netio_bindaddr (NetIO *self,const NetAddr *src,gboolean silent)
 Member function to bind this NewIO object to a NetAddr address. More...
 
FSTATIC gboolean _netio_bindaddr_v4 (NetIO *self,const NetAddr *src,gboolean silent)
 Member function to bind this NewIO object to an IPv4 NetAddr address. More...
 
FSTATIC NetAddr_netio_boundaddr (const NetIO *self)
 Member function to return the bound NetAddr (with port) of this NetIO object. More...
 
FSTATIC void _netio_finalize (AssimObj *aself)
 Member function to free this NetIO object. More...
 
FSTATIC gsize _netio_getmaxpktsize (const NetIO *self)
 Get the max packet size for this NetIO transport. More...
 
FSTATIC gsize _netio_setmaxpktsize (NetIO *self,gsize maxpktsize)
 Set the max packet size for this NetIO transport. More...
 
FSTATIC CompressFrame_netio_compressframe (NetIO *self)
 
FSTATIC SignFrame_netio_signframe (NetIO *self)
 
NetIOnetio_new (gsize objsize, ConfigContext *config, PacketDecoder *decoder)
 NetIO constructor. More...
 
FSTATIC void _netio_sendapacket (NetIO *self,gconstpointer packet,gconstpointer pktend,const NetAddr *destaddr)
 NetIO internal function to send a packet (datagram) More...
 
FSTATIC void _netio_sendapacket_v4 (NetIO *self,gconstpointer packet,gconstpointer pktend,const NetAddr *destaddr)
 NetIO internal function to send a packet (datagram) More...
 
FSTATIC void _netio_sendframesets (NetIO *self,const NetAddr *destaddr,GSList *framesets)
 NetIO member function to send a GSList of FrameSets. More...
 
FSTATIC void _netio_sendaframeset (NetIO *self, const NetAddr *destaddr, FrameSet *frameset)
 
FSTATIC gpointer _netio_recvapacket (NetIO *self,gpointer *pktend,struct sockaddr_in6 *srcaddr, socklen_t *addrlen)
 Internal function to receive a packet from our NetIO object General method: More...
 
FSTATIC GSList * _netio_recvframesets (NetIO *self,NetAddr **src)
 Member function to receive a collection of FrameSets (GSList*) out of our NetIO object. More...
 
FSTATIC void _netio_setpktloss (NetIO *self, double rcvloss, double xmitloss)
 Set the desired level of packet loss - doesn't take effect from this call alone. More...
 
FSTATIC void _netio_enablepktloss (NetIO *self, gboolean enable)
 Enable (or disable) packet loss as requested. More...
 
gboolean netio_is_dual_ipv4v6_stack (void)
 
FSTATIC gboolean _netio_sendareliablefs (NetIO *self, NetAddr *dest, guint16 queueid, FrameSet *frameset)
 
FSTATIC gboolean _netio_sendreliablefs (NetIO *self, NetAddr *dest, guint16 queueid, GSList *fslist)
 
FSTATIC gboolean _netio_ackmessage (NetIO *self, NetAddr *dest, FrameSet *frameset)
 
FSTATIC gboolean _netio_supportsreliable (NetIO *self)
 
FSTATIC void _netio_closeconn (NetIO *self, guint16 qid, const NetAddr *destaddr)
 
FSTATIC void _netio_netaddr_destroy (gpointer addrptr)
 g_hash_table destructor for a NetAddr More...
 
FSTATIC void _netio_addalias (NetIO *self, NetAddr *fromaddr, NetAddr *toaddr)
 Add an alias to our alias table. More...
 
typedef struct _NetIOstats NetIOstats
 
typedef struct _NetIO NetIO
 

Detailed Description

(Abstract) NetIO objects are able to perform network writes and reads.

It is a class from which we must make subclasses, and is managed by our C-Class Management system.

Typedef Documentation

typedef struct _NetIO NetIO

Definition at line 53 of file netio.h.

typedef struct _NetIOstats NetIOstats

Definition at line 40 of file netio.h.

Function Documentation

FSTATIC gboolean _netio_ackmessage ( NetIO self,
NetAddr dest,
FrameSet frameset 
)

Definition at line 974 of file netio.c.

References __FUNCTION__.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_addalias ( NetIO self,
NetAddr fromaddr,
NetAddr toaddr 
)

Add an alias to our alias table.

Parameters
selfUs
fromaddrAddress to map from
toaddrAddress to map the from address to

Definition at line 1002 of file netio.c.

References _NetAddr::baseclass, DUMP3, and REF.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC gboolean _netio_bindaddr ( NetIO self,
const NetAddr src,
gboolean  silent 
)

Member function to bind this NewIO object to a NetAddr address.

Parameters
[in,out]selfThe object being bound
[in]srcThe address to bind it to
[in]silentTRUE if no message on error

Definition at line 345 of file netio.c.

References __FUNCTION__, _netio_bindaddr_v4(), ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, _NetAddr::addrtype, _NetAddr::ipv6sockaddr, and _NetAddr::ismcast.

Referenced by netio_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gboolean _netio_bindaddr_v4 ( NetIO self,
const NetAddr src,
gboolean  silent 
)

Member function to bind this NewIO object to an IPv4 NetAddr address.

Parameters
[in,out]selfThe object being bound
[in]srcThe address to bind it to
[in]silentTRUE if no message on error

Definition at line 375 of file netio.c.

References __FUNCTION__, _NetAddr::baseclass, FREE, _NetAddr::ipv4sockaddr, _NetAddr::ismcast, _NetAddr::toIPv4, _AssimObj::toString, and UNREF.

Referenced by _netio_bindaddr().

Here is the caller graph for this function:

FSTATIC NetAddr * _netio_boundaddr ( const NetIO self)

Member function to return the bound NetAddr (with port) of this NetIO object.

Parameters
[in]selfThe object being examined

Definition at line 411 of file netio.c.

References __FUNCTION__, and netaddr_sockaddr_new().

Referenced by netio_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _netio_closeconn ( NetIO self,
guint16  qid,
const NetAddr destaddr 
)

Definition at line 987 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC CompressFrame * _netio_compressframe ( NetIO self)

Definition at line 475 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_enablepktloss ( NetIO self,
gboolean  enable 
)

Enable (or disable) packet loss as requested.

Definition at line 883 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_finalize ( AssimObj aself)

Member function to free this NetIO object.

Parameters
[in,out]aselfThe object being freed

Definition at line 433 of file netio.c.

References _assimobj_finalize(), CASTTOCLASS, UNREF, and UNREF2.

Referenced by netio_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gint _netio_getfd ( const NetIO self)

Member function to return the file descriptor underlying this NetIO object.

Parameters
[in]selfThe object whose file descriptor is being returned

Definition at line 97 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC gsize _netio_getmaxpktsize ( const NetIO self)

Get the max packet size for this NetIO transport.

Parameters
[in]selfThe object whose max pkt size is being returned

Definition at line 461 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC int _netio_getsockbufsize ( const NetIO self,
gboolean  forinput 
)

Return the kernel's idea of what our input or output socket buffer size is.

Definition at line 251 of file netio.c.

References __FUNCTION__.

Referenced by _netio_maximize_sockbufsize(), _netio_setsockbufsize(), and netio_new().

Here is the caller graph for this function:

FSTATIC gboolean _netio_input_queued ( const NetIO self)

Member function that returns TRUE if input is ready to be read.

Parameters
[in]selfThe NetIO object being queried

Definition at line 337 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_maximize_sockbufsize ( const NetIO self,
gboolean  forinput,
int  desiredsize 
)

Maximize the socket buffer size as requested - as best we can...

Definition at line 299 of file netio.c.

References __FUNCTION__, _netio_getsockbufsize(), and DEBUGMSG2.

Referenced by _netio_setsockbufsize().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gboolean _netio_mcastjoin ( NetIO self,
const NetAddr src,
const NetAddr localaddr 
)

Set up a NetIO object to listen to (join) a particular multicast group.

Definition at line 133 of file netio.c.

References __FUNCTION__, _NetAddr::_addrtype, ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, _NetAddr::addrtype, _NetAddr::ipv4sockaddr, _NetAddr::ipv6sockaddr, _NetAddr::ismcast, and UNREF.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_netaddr_destroy ( gpointer  addrptr)

g_hash_table destructor for a NetAddr

Definition at line 994 of file netio.c.

References CASTTOCLASS, and UNREF.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC gpointer _netio_recvapacket ( NetIO self,
gpointer *  pktend,
struct sockaddr_in6 *  srcaddr,
socklen_t *  addrlen 
)

Internal function to receive a packet from our NetIO object General method:

  • use MSG_PEEK to get message length
  • malloc the amount of memory indicated by MSG_PEEK
  • receive message into malloced buffer
  • check for errors
  • return received message, length, etc.
Parameters
[in,out]selfTransport to receive packet from
[out]pktendPointer to one past end of packet
[out]srcaddrPointer to source address as sockaddr
[out]addrlenlength of address in 'srcaddr'

Definition at line 733 of file netio.c.

References __FUNCTION__, CONST_IPV6_IPV4SPACE, CONST_IPV6_IPV4START, DEBUGMSG3, FREE, and MALLOC.

Referenced by _netio_recvframesets().

Here is the caller graph for this function:

FSTATIC GSList * _netio_recvframesets ( NetIO self,
NetAddr **  src 
)

Member function to receive a collection of FrameSets (GSList*) out of our NetIO object.

Parameters
[in,out]selfNetIO routine to receive a set of FrameSets from a single address.
[out]srcconstructed source address for FrameSets

Definition at line 818 of file netio.c.

References __FUNCTION__, _NetAddr::_addrport, _netio_recvapacket(), assim_g_notify_unref(), _NetAddr::baseclass, DEBUG, DEBUGMSG, FREE, g_slist_free_full, netaddr_sockaddr_new(), _NetAddr::toIPv6, _AssimObj::toString, and UNREF.

Referenced by netio_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _netio_sendaframeset ( NetIO self,
const NetAddr destaddr,
FrameSet frameset 
)
Parameters
[in,out]selfThe NetIO object doing the sending
[in]destaddrWhere to send the FrameSets
[in]framesetThe framesets being sent

Definition at line 697 of file netio.c.

References __FUNCTION__, _netio_sendapacket(), _FrameSet::baseclass, cryptframe_new_by_destaddr(), DEBUGMSG3, DUMP3, frameset_construct_packet(), _FrameSet::packet, _FrameSet::pktend, and UNREF2.

Referenced by netio_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _netio_sendapacket ( NetIO self,
gconstpointer  packet,
gconstpointer  pktend,
const NetAddr destaddr 
)

NetIO internal function to send a packet (datagram)

Parameters
[in]selfObject doing the sending
[in]packetPacket to send
[in]pktendone byte past end of packet
[in]destaddrwhere to send it

Definition at line 547 of file netio.c.

References __FUNCTION__, _netio_sendapacket_v4(), _NetAddr::baseclass, DEBUGMSG3, DUMP3, g_info, _NetAddr::ipv6sockaddr, and _AssimObj::toString.

Referenced by _netio_sendaframeset(), and _netio_sendframesets().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _netio_sendapacket_v4 ( NetIO self,
gconstpointer  packet,
gconstpointer  pktend,
const NetAddr destaddr 
)

NetIO internal function to send a packet (datagram)

Parameters
[in]selfObject doing the sending
[in]packetPacket to send
[in]pktendone byte past end of packet
[in]destaddrwhere to send it

Definition at line 610 of file netio.c.

References __FUNCTION__, _NetAddr::baseclass, DEBUGMSG3, DUMP3, g_info, _NetAddr::ipv4sockaddr, and _AssimObj::toString.

Referenced by _netio_sendapacket().

Here is the caller graph for this function:

FSTATIC gboolean _netio_sendareliablefs ( NetIO self,
NetAddr dest,
guint16  queueid,
FrameSet frameset 
)

Definition at line 960 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_sendframesets ( NetIO self,
const NetAddr destaddr,
GSList *  framesets 
)

NetIO member function to send a GSList of FrameSets.

Todo:
consider optimizing this code to send multiple FrameSets in a single datagram - using sendmsg(2) assuming we start constructing GSLists with more than one FrameSet in it on a regular basis.
Todo:
change netio_sendframesets to use sendmsg(2) instead of sendto(2)... This loop would then be to set up a struct iovec, and would be followed by a sendmsg(2) call - eliminating sendapacket() above.
Parameters
[in,out]selfThe NetIO object doing the sending
[in]destaddrWhere to send the FrameSets
[in]framesetsThe framesets being sent

Definition at line 663 of file netio.c.

References __FUNCTION__, _netio_sendapacket(), _FrameSet::baseclass, CASTTOCLASS, cryptframe_new_by_destaddr(), DEBUGMSG3, DUMP3, frameset_construct_packet(), _FrameSet::packet, _FrameSet::pktend, REF2, and UNREF2.

Referenced by netio_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gboolean _netio_sendreliablefs ( NetIO self,
NetAddr dest,
guint16  queueid,
GSList *  fslist 
)

Definition at line 967 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_setblockio ( const NetIO self,
gboolean  blocking 
)

Member function to set blocking/non-blocking mode on our sockets.

Definition at line 106 of file netio.c.

References __FUNCTION__.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC gsize _netio_setmaxpktsize ( NetIO self,
gsize  maxpktsize 
)

Set the max packet size for this NetIO transport.

Parameters
[in,out]selfThe object whose max packet size to set
[in]maxpktsizeSize to set the max packet size to.

Definition at line 468 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

gboolean _netio_setmcast_ttl ( NetIO self,
guint8  ttlin 
)

Set up the multicast TTL for this NetIO object.

Parameters
[in,out]selfnetIO object to set the TTL of
[in]ttlinmulticast TTL TTL Scope 0 Restricted to the same host. Won't be output by any interface. 1 Restricted to the same subnet. Won't be forwarded by a router. <32 Restricted to the same site, organization or department. <64 Restricted to the same region. <128 Restricted to the same continent. <255 Unrestricted in scope. Global.

Definition at line 235 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC void _netio_setpktloss ( NetIO self,
double  rcvloss,
double  xmitloss 
)

Set the desired level of packet loss - doesn't take effect from this call alone.

Definition at line 875 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC int _netio_setsockbufsize ( const NetIO self,
gboolean  forinput,
gsize  bufsize 
)

Set the kernel's idea of what our input or output socket buffer size as close as we can We'll even do a binary search to maximize the value if we can't get what we want.

Definition at line 270 of file netio.c.

References __FUNCTION__, _netio_getsockbufsize(), _netio_maximize_sockbufsize(), and DEBUGMSG2.

Referenced by netio_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC SignFrame * _netio_signframe ( NetIO self)

Definition at line 481 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC gboolean _netio_supportsreliable ( NetIO self)

Definition at line 981 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

gboolean netio_is_dual_ipv4v6_stack ( void  )

Definition at line 954 of file netio.c.

Referenced by cma.AssimCclasses.pyNetIO::is_dual_ipv4v6_stack(), and main().

Here is the caller graph for this function:

NetIO* netio_new ( gsize  objsize,
ConfigContext config,
PacketDecoder decoder 
)

NetIO constructor.

Don't call directly! - this is an abstract class...

Parameters
[in]objsizeThe size of the object to construct (or zero)
[in]configConfiguration Information
[in]decoderPacket decoder

Definition at line 488 of file netio.c.

References _NetIO::_compressframe, _NetIO::_configinfo, _NetIO::_decoder, _AssimObj::_finalize, _NetIO::_maxpktsize, _netio_ackmessage(), _netio_addalias(), _netio_bindaddr(), _netio_boundaddr(), _netio_closeconn(), _netio_compressframe(), _netio_enablepktloss(), _netio_finalize(), _netio_getfd(), _netio_getmaxpktsize(), _netio_getsockbufsize(), _netio_input_queued(), _netio_mcastjoin(), _netio_netaddr_destroy(), _netio_recvframesets(), _netio_sendaframeset(), _netio_sendareliablefs(), _netio_sendframesets(), _netio_sendreliablefs(), _netio_setblockio(), _netio_setmaxpktsize(), _netio_setmcast_ttl(), _netio_setpktloss(), _netio_setsockbufsize(), _netio_signframe(), _netio_supportsreliable(), _NetIO::_signframe, _NetIO::ackmessage(), _NetIO::addalias, _NetIO::aliases, assimobj_new(), _NetIO::baseclass, _NetIO::bindaddr(), BINDDEBUG, _NetIO::boundaddr, CASTTOCLASS, _NetIO::closeconn(), _NetIO::compressframe(), obsolete_cma::config, CONFIGNAME_COMPRESS, CONFIGNAME_OUTSIG, _NetIO::enablepktloss(), _NetIO::getfd(), _ConfigContext::getframe, _NetIO::getmaxpktsize(), _NetIO::getsockbufsize(), _NetIO::input_queued(), _NetIO::mcastjoin(), netaddr_g_hash_equal(), netaddr_g_hash_hash(), NEWSUBCLASS, _NetIO::outputpending(), _NetIO::recvframesets(), REF, REF2, _NetIO::sendaframeset(), _NetIO::sendareliablefs(), _NetIO::sendframesets(), _NetIO::sendreliablefs(), _NetIO::setblockio(), _NetIO::setmaxpktsize(), _NetIO::setmcast_ttl(), _NetIO::setpktloss(), _NetIO::setsockbufsize(), _NetIO::signframe(), _NetIO::stats, _NetIO::supportsreliable(), and _NetIO::v4only.

Referenced by cma.AssimCclasses.pyNetIO::__init__(), and netioudp_new().

Here is the call graph for this function:

Here is the caller graph for this function: