if(nodeinfo.nodetype == NT_HOST) (void)CNET_set_handler(EV_APPLICATIONREADY, appl_ready, 0);
CnetNodeType | meaning |
---|---|
NT_HOST | this node is a host with an Application Layer and keyboard |
NT_ROUTER | this node is a router without an Application Layer or keyboard |
Note that calls to the functions
CNET_write_application, CNET_read_application, CNET_enable_application, CNET_disable_application and CNET_set_handler(EV_APPLICATIONLAYER,...) or CNET_set_handler(EV_KEYBOARDREADY,...)
are only valid if called from a node of node type NT_HOST.
if(linkinfo[link].linktype == LT_ETHERNET) (void)CNET_set_promiscuous(link, 1);
CnetNodeType | meaning |
---|---|
LT_LOOPBACK | this link (which will always be link 0) is used to quickly deliver data from a node to itself |
LT_ETHERNET | this link connects this node to other nodes via a shared Ethernet segment |
LT_POINT2POINT | this link connects this node to one other node via a dedicated (``private'') link as in a wide-area network |
Calls to the functions
CNET_set_promiscuous, and CNET_set_nicaddrcannot set the attributes of link 0, the LOOPBACK link, nor set a NIC address to either the zero address, 00:00:00:00:00:00, or the broadcast address, ff:ff:ff:ff:ff:ff.
Frames written to Ethernet links are ``expected'' to carry the address of their destination Network Interface Card (NIC) at the very beginning of the frame. cnet interprets the leading LEN_NICADDR bytes of each frame on an Ethernet segment to be an address. The special address, whose string representation is ff:ff:ff:ff:ff:ff, is interpreted as the Ethernet broadcast address. Any frame carrying the broadcast address as its destination address will be delivered to all NICs on the Ethernet segment, except the sender. cnet does not support multicast or group addressing.
cnet provides the functions CNET_parse_nicaddr and CNET_format_nicaddr to convert between character strings and the CnetNicaddr datatype.
CnetEvent | meaning |
---|---|
EV_NULL | this event is used internally and is never seen by your protocols |
EV_REBOOT | raised as reboot_node(EV_REBOOT, ... , ...) |
EV_SHUTDOWN | raised before cnet is (cleanly) terminated |
EV_APPLICATIONREADY | raised when there is a message ready for delivery |
EV_PHYSICALREADY | raised when a frame arrives at one of the links |
EV_KEYBOARDREADY | raised when an input line is entered from the keyboard |
EV_LINKSTATE | raised when a link changes state (either up or down) |
EV_DRAWFRAME | raised when a frame is to be drawn in 2-node world |
EV_DEBUG1..EV_DEBUG5 | raised when one of the debug buttons (under X-windows) is pressed |
EV_TIMER1..EV_TIMER10 | raised when a timer on any of the 10 timer queues expires |
if(CNET_write_application(msgbuffer, &msglength) != 0) { /* an error has occured */ if(cnet_errno == ER_BADSESSION) { /* handle this special case */ .... } else { cnet_perror("writing to application"); } }
CnetError | meaning |
---|---|
ER_OK | No error |
ER_BADARG | Invalid argument passed to a function |
ER_BADEVENT | Invalid event passed to a function |
ER_BADLINK | Invalid link number passed to a function |
ER_BADNODE | Invalid node passed to a function |
ER_BADSENDER | Application Layer given message from an unknown node |
ER_BADSESSION | Application Layer given message from incorrect session |
ER_BADSIZE | Indicated length is of incorrect size |
ER_BADTIMER | Invalid CnetTimer passed to a function |
ER_CORRUPTDATA | Attempt to transfer corrupt data (only seen if -e provided) |
ER_LINKDOWN | Attempt to transmit on a link which is down |
ER_NOTFORME | Application Layer given a message for another node |
ER_NOTREADY | Function called when service not available |
ER_NOTSUPPORTED | Invalid operation for this node type |
ER_OUTOFSEQ | Application Layer given message out of sequence |
ER_TOOBUSY | link is too busy/congested to handle request |
cnet was written and is maintained by Chris McDonald (chris@cs.uwa.edu.au) | ![]() |