The cnet network simulator - Event handling and tracing functions
Keywords: network simulator simulation protocol undergraduate teaching

### cnet's event handling and tracing functions

`

### Event handling functions

`int CNET_set_handler(CnetEvent ev, void (*func)(), CnetData data)`

  Register `func` as the void ``returning'' function to be invoked when the event `ev` occurs.

  Possible errors: `ER_BADEVENT, ER_NOTSUPPORTED.`

`int CNET_get_handler(CnetEvent ev, void (**handler)(), CnetData *data)`

  Obtains the address of the `void` ``returning'' function which will be invoked when the indicated event occurs, together with the user-specified data value that will be passed to the handler.

  Possible errors: `ER_BADEVENT, ER_NOTSUPPORTED.`

### Tracing functions

`int CNET_trace(const char *, ...)`

  If tracing is requested (globally, or for certain nodes) this `printf()`-like function will produce its output on the `stderr` stream.

  Possible errors: `ER_BADARG.`

`int CNET_trace_name(void *addr, const char *name)`

  If tracing is requested (globally, or for certain nodes) function parameters known to be addresses are annotated as (cryptic) hexademical values. By recording a name (string) with an address, the annotation is more meaningful.

  Possible errors: `ER_BADARG.`

`int CNET_set_trace(int eventmask)`

  Tracing is normally an ``all-or-nothing'' situation - if requested, all events are annotated. However, tracing may be requested programatically by providing an eventmask, such as `TE_APPLICATIONREADY|TE_PHYSICALREADY`, which will annotate just the requested events. The ``all-or-nothing'' default represents `CNET_set_trace(TE_ALLEVENTS)` or `CNET_set_trace(TE_NOEVENTS)`.

`int CNET_get_trace(void)`

  Returns an integer representing the eventmask of all events currently being traced.

cnet was written and is maintained by Chris McDonald (chris@cs.uwa.edu.au)

`