The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 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 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_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 783 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 811 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 253 of file netio.c.

References __FUNCTION__, ADDR_FAMILY_IPV4, ADDR_FAMILY_IPV6, _NetAddr::addrtype, _NetAddr::ipv6sockaddr, _NetAddr::ismcast, and _NetAddr::port.

Referenced by netio_new().

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 283 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 796 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 347 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 692 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 305 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 91 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 333 of file netio.c.

Referenced by 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 245 of file netio.c.

Referenced by netio_new().

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 127 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 803 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 558 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 643 of file netio.c.

References _NetAddr::_addrport, _netio_recvapacket(), FREE, netaddr_sockaddr_new(), _NetAddr::toIPv6, 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 516 of file netio.c.

References __FUNCTION__, _netio_sendapacket(), _NetAddr::baseclass, _FrameSet::baseclass, cryptframe_new_by_destaddr(), DEBUGMSG3, frameset_construct_packet(), _FrameSet::packet, _FrameSet::pktend, _AssimObj::toString, 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 417 of file netio.c.

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

Referenced by _netio_sendaframeset(), and _netio_sendframesets().

Here is the caller graph for this function:

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

Definition at line 769 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 475 of file netio.c.

References __FUNCTION__, _netio_sendapacket(), _NetAddr::baseclass, _FrameSet::baseclass, CASTTOCLASS, cryptframe_new_by_destaddr(), frameset_construct_packet(), _FrameSet::packet, _FrameSet::pktend, REF2, _AssimObj::toString, 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 776 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 100 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 340 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 229 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 684 of file netio.c.

Referenced by netio_new().

Here is the caller graph for this function:

FSTATIC SignFrame * _netio_signframe ( NetIO self)

Definition at line 353 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 790 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 763 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 360 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_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_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::input_queued(), _NetIO::is_encrypted, _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::signframe(), _NetIO::stats, and _NetIO::supportsreliable().

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: