The cnet network simulator - checksum and miscellaneous functions
Keywords: network simulator simulation protocol undergraduate teaching

### cnet's checksum and miscellaneous functions

`

### Checksum functions

int checksum_internet(unsigned short *addr, int nbytes)`

`unsigned short checksum_ccitt(unsigned char *addr, int nbytes)`

`unsigned short checksum_crc16(unsigned char *addr, int nbytes)`

`unsigned int checksum_crc32(unsigned char *addr, int nbytes)`

  These four checksum functions each take a memory address and perform the specified checksum calculation on the indicated number of bytes starting from that address.

### Miscellaneous functions

`int CNET_read_keyboard(char *line, int *len)`

  Requests the specified maximum number of bytes from the keyboard buffer placing them in the address pointed to by `line`. On invocation, `len` will point to an integer indicating the maximum number of bytes that may be copied into `line`. On return, `line` will be NULL-byte terminated (and not include a newline) and the integer pointed to by `len` will contain `strlen(line)+1`.

  Possible errors: `ER_BADSIZE, ER_NOTREADY, ER_NOTSUPPORTED.`

`int CNET_set_debug_string(CnetEvent ev, char *str)`

  Change the string on the indicated windowing debug button (for `EV_DEBUG1..EV_DEBUG5`) to `str`. If `str` is `NULL` or the empty string, the indicated button is removed.

  Possible errors: `ER_BADEVENT.`

`int CNET_set_time_of_day(long newsec, long newms)`

  Change the node's notion of the wall-clock time of day. As nodeinfo should be considered a read-only structure, this is the only method to set `time_of_day.sec` and `time_of_day.ms` . (`time_of_day.sec` is the number of seconds since Jan. 1, 1970, and may be used in a call to ctime(3c)).

  Possible errors: `ER_BADARG.`

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