Header file for common utility functions. More...
Go to the source code of this file.
Macros | |
#define | XSTR(a) #a |
Internal to the STR macro. More... | |
#define | STR(a) XSTR(a) |
Stringify a macro value. More... | |
#define | ARR_CNT(a) (sizeof(a) / sizeof(a[0])) |
Count the number of elements in an arbitrary array. More... | |
#define | ntohll(x) |
Byte-swap a 64-bit integer. More... | |
#define | htonll(x) ntohll(x) |
Byte-swap a 64-bit integer. More... | |
Functions | |
void | bytes_htons (uint8_t *bytes, uint16_t u16) |
Convert a host ordered short to a network ordered byte array. More... | |
void | bytes_htonl (uint8_t *bytes, uint32_t u32) |
Convert a host ordered long to a network ordered byte array. More... | |
void | bytes_htonll (uint8_t *bytes, uint64_t u64) |
Convert a host ordered long-long (64 bit) to a network ordered byte array. More... | |
void | gettimeofday_wrap (struct timeval *tv) |
Convenience function to get the current time of day. More... | |
void * | malloc_zero (const size_t size) |
Allocate memory and set it to zero. More... | |
int | timeval_subtract (struct timeval *result, const struct timeval *x, const struct timeval *y) |
Find the delta between two timevals. More... | |
void | chomp (char *line) |
Remove a newline from the given string. More... | |
Header file for common utility functions.
Definition in file utils.h.
#define ARR_CNT | ( | a | ) | (sizeof(a) / sizeof(a[0])) |
Count the number of elements in an arbitrary array.
Definition at line 60 of file utils.h.
Referenced by corsaro_geo_get_provider_name(), and corsaro_geo_get_provider_names().
#define htonll | ( | x | ) | ntohll(x) |
#define ntohll | ( | x | ) |
Byte-swap a 64-bit integer.
Definition at line 66 of file utils.h.
Referenced by validate_attack_vector().
#define STR | ( | a | ) | XSTR(a) |
Stringify a macro value.
Definition at line 57 of file utils.h.
Referenced by corsaro_init(), and usage().
void bytes_htonl | ( | uint8_t * | bytes, |
uint32_t | u32 | ||
) |
Convert a host ordered long to a network ordered byte array.
[out] | bytes | The converted byte array |
u32 | The host-ordered long |
Definition at line 57 of file utils.c.
Referenced by binary_dump(), and corsaro_dos_end_interval().
void bytes_htonll | ( | uint8_t * | bytes, |
uint64_t | u64 | ||
) |
Convert a host ordered long-long (64 bit) to a network ordered byte array.
[out] | bytes | The converted byte array |
u64 | The host-ordered long-long (64 bit) |
Definition at line 64 of file utils.c.
References htonll.
Referenced by binary_dump().
void bytes_htons | ( | uint8_t * | bytes, |
uint16_t | u16 | ||
) |
Convert a host ordered short to a network ordered byte array.
[out] | bytes | The converted byte array |
u16 | The host-ordered short |
Definition at line 50 of file utils.c.
Referenced by binary_dump().
void chomp | ( | char * | line | ) |
Remove a newline from the given string.
line | A pointer to the string to be chomped |
Definition at line 114 of file utils.c.
Referenced by read_country_file(), read_pfx_file(), and read_routeviews().
void gettimeofday_wrap | ( | struct timeval * | tv | ) |
Convenience function to get the current time of day.
[out] | tv | A pointer to a timeval containing the time of day |
Definition at line 71 of file utils.c.
Referenced by corsaro_init().
void* malloc_zero | ( | const size_t | size | ) |
Allocate memory and set it to zero.
size | The size of memory to allocate |
Definition at line 78 of file utils.c.
Referenced by attack_vector_init(), corsaro_anon_init_output(), corsaro_dos_init_input(), corsaro_dos_init_output(), corsaro_filtergeo_init_output(), corsaro_filterpfx_init_output(), corsaro_flowtuple_init_input(), corsaro_flowtuple_init_output(), corsaro_geo_init_provider(), corsaro_geo_init_record(), corsaro_geodb_init_output(), corsaro_in_init(), corsaro_init(), corsaro_packet_alloc(), corsaro_pcap_init_output(), corsaro_pfx2as_init_output(), and corsaro_smee_init_output().
int timeval_subtract | ( | struct timeval * | result, |
const struct timeval * | x, | ||
const struct timeval * | y | ||
) |
Find the delta between two timevals.
[out] | result | A pointer to a timeval containing the delta |
x | The start timeval | |
y | The end timeval |
Definition at line 88 of file utils.c.
Referenced by attack_vector_is_attack().