|
DTS Application Library
0.2.3
Application library containing referenced objects and interfaces to common libraries
|
Utilities commonly used. More...
Modules | |
| Hashing and digest functions | |
| MD5/SHA1/SHA2(256/512) Hashing checking and HMAC Functions. | |
Files | |
| file | util.c |
| Utilities commonly used. | |
Functions | |
| void | seedrand (void) |
| Seed openssl random number generator. More... | |
| int | genrand (void *buf, int len) |
| Generate random sequence. More... | |
| int | strlenzero (const char *str) |
| Check if a string is zero length. More... | |
| char * | ltrim (char *str) |
| Trim white space at the begining of a string. More... | |
| char * | rtrim (const char *str) |
| Trim white space at the end of a string. More... | |
| char * | trim (const char *str) |
| Trim whitesapce from the beggining and end of a string. More... | |
| uint64_t | tvtontp64 (struct timeval *tv) |
| Convert a timeval struct to 64bit NTP time. More... | |
| uint16_t | checksum (const void *data, int len) |
| Obtain the checksum for a buffer. More... | |
| uint16_t | checksum_add (const uint16_t checksum, const void *data, int len) |
| Obtain the checksum for a buffer adding a checksum. More... | |
| uint16_t | verifysum (const void *data, int len, const uint16_t check) |
| Verify a checksum. More... | |
| void | touch (const char *filename, uid_t user, gid_t group) |
| Create a file and set user and group. More... | |
| char * | b64enc_buf (const char *message, uint32_t len, int nonl) |
| Base 64 encode a buffer. More... | |
| char * | b64enc (const char *message, int nonl) |
| Base 64 encode a string. More... | |
Utilities commonly used.
| char* b64enc | ( | const char * | message, |
| int | nonl | ||
| ) |
Base 64 encode a string.
| message | String to encode. |
| nonl | Encode the data all on one line if non zero. |
Definition at line 539 of file util.c.
References b64enc_buf().
| char* b64enc_buf | ( | const char * | message, |
| uint32_t | len, | ||
| int | nonl | ||
| ) |
Base 64 encode a buffer.
| message | Buffer to encode. |
| len | Length of the buffer. |
| nonl | Encode the data all on one line if non zero. |
Definition at line 506 of file util.c.
References objalloc().
Referenced by b64enc().
| uint16_t checksum | ( | const void * | data, |
| int | len | ||
| ) |
Obtain the checksum for a buffer.
| data | Buffer to create checksum of. |
| len | Buffer length. |
Definition at line 452 of file util.c.
Referenced by ipv4checksum(), ipv4icmpchecksum(), ipv4tcpchecksum(), ipv4udpchecksum(), and rfc6296_map_add().
| uint16_t checksum_add | ( | const uint16_t | checksum, |
| const void * | data, | ||
| int | len | ||
| ) |
Obtain the checksum for a buffer adding a checksum.
| checksum | Checksum to add to generated checksum. |
| data | Buffer to create checksum of. |
| len | Buffer length. |
Definition at line 463 of file util.c.
Referenced by ipv4tcpchecksum(), and ipv4udpchecksum().
| int genrand | ( | void * | buf, |
| int | len | ||
| ) |
Generate random sequence.
| buf | Buffer to write random data. |
| len | Length to write. |
Definition at line 82 of file util.c.
Referenced by mcast4_ip(), mcast6_ip(), new_radpacket(), randhwaddr(), and sslstartup().
| char* ltrim | ( | char * | str | ) |
Trim white space at the begining of a string.
| str | String to trim. |
Definition at line 353 of file util.c.
References strlenzero().
Referenced by trim().
| char* rtrim | ( | const char * | str | ) |
Trim white space at the end of a string.
| str | String to trim. |
Definition at line 372 of file util.c.
References strlenzero().
Referenced by trim().
| void seedrand | ( | void | ) |
Seed openssl random number generator.
This should be run at application startup
Definition at line 68 of file util.c.
Referenced by framework_init(), and mcast_socket().
| int strlenzero | ( | const char * | str | ) |
Check if a string is zero length.
strlen can not be used on a NULL string this is a quick and dirty util to check it.
| str | String to check. |
Definition at line 341 of file util.c.
Referenced by create_kernmac(), create_kernvlan(), get_category_next(), get_ifinfo(), get_ifipaddr(), ifhwaddr(), ltrim(), process_config(), rtrim(), and unixsocket_client().
| void touch | ( | const char * | filename, |
| uid_t | user, | ||
| gid_t | group | ||
| ) |
Create a file and set user and group.
| filename | File to create. |
| user | User ID to set ownership. |
| group | Group ID to set ownership. |
Definition at line 484 of file util.c.
References touch().
Referenced by touch(), and xslt_apply().
| char* trim | ( | const char * | str | ) |
Trim whitesapce from the beggining and end of a string.
| str | String to trim. |
Definition at line 393 of file util.c.
References ltrim(), and rtrim().
Referenced by process_config().
| uint64_t tvtontp64 | ( | struct timeval * | tv | ) |
Convert a timeval struct to 64bit NTP time.
| tv | Timeval struct to convert. |
Definition at line 405 of file util.c.
Referenced by get_ip6_addrprefix().