cnet v4.0.4  

home topology files command‑line options the core API FAQ download and install

cnet's Application Programming Interface

NAME
CNET_write_physical, CNET_write_physical_reliable - write data frames to the Physical Layer

SYNOPSIS
#include <cnet.h> int CNET_write_physical(int link, const void *frame, size_t *length); int CNET_write_physical_reliable(int link, const void *frame, size_t *length);

DESCRIPTION
CNET_write_physical requests that the indicated number of bytes, pointed to by frame, be written "down to" the Physical Layer. If accepted, the Physical Layer will attempt to transmit the data frame on the indicated link, which can be of type LT_LOOPBACK, LT_WAN, LT_LAN, or LT_WLAN. Depending on the characteristics of the link, the data frame may be subject to corruption, loss, or collisions.

Each node has a fixed number of links, the first available physical link is number 1, the second is number 2, and so on. As a special case, a node may reliably transmit a frame to itself by requesting the LOOPBACK(=0) link.

On invocation, length must point to an integer indicating the number of bytes to be copied from frame. On return, the integer pointed to by length will now contain the number of bytes accepted by the Physical Layer.

CNET_write_physical_reliable performs identically to CNET_write_physical except that the written data frame will not suffer any corruption, loss, or collisions in the Physical Layer. In addition, CNET_write_physical_reliable permits new frames to be written to a link while the previous one is still being transmitted.

RETURN VALUE
The value 0 is returned on success. On failure, the value -1 is returned, and the global variable cnet_errno is set to one of the following values to describe the error:

ER_BADARG
Either frame is a NULL pointer, or length is equal to zero.
ER_BADLINK
The value of link is less than zero, or greater than the number of physical links of the current node.
ER_BADSIZE
The value of length exceeds the capacity of the Physical Layer link being written to.
ER_LINKDOWN
The link being written to is currently down.
ER_NOBATTERY
The current mobile node's battery is exhausted.
ER_NOTREADY
The current node has not yet finished rebooting, the indicated WLAN link is in sleep mode, or the link has not yet completed transmitting the previous frame.
ER_TOOBUSY
The link has not yet completed transmitting the previous frame, or an attempt has been made to write more than 1000 frames to the indicated link before any of them have been read by the receiving node (this restriction is imposed to trap obvious errors in protocols).
SEE ALSO
CNET_write_direct and CNET_read_physical

cnet v4.0.4 - [email protected]