Airframe utility functions.
More...
#include <airframe/autoinc.h>
Go to the source code of this file.
|
| void | air_time_g_string_append (GString *str, time_t time, AirTimeFormat fmtid) |
| | Append a string format of a time to a given GString in a given format. More...
|
| |
| void | air_mstime_g_string_append (GString *str, uint64_t mstime, AirTimeFormat fmtid) |
| | Append a string format of a time in epoch milliseconds to a given GString in a given format. More...
|
| |
| void | air_time_buf_print (char *buf, time_t time, AirTimeFormat fmtid) |
| | Write a string format of a time to a given buffer in a given format. More...
|
| |
| time_t | air_time_gm (uint32_t year, uint32_t mon, uint32_t day, uint32_t hour, uint32_t min, uint32_t sec) |
| | Portable, less unix-ish timegm() implementation. More...
|
| |
| void | air_ipaddr_buf_print (char *buf, uint32_t ipaddr) |
| | Write the dotted quad format of an IPv4 address to a given buffer. More...
|
| |
| void | air_ip6addr_buf_print (char *buf, uint8_t *ipaddr) |
| | Write the presentation format of an IPv6 address to a given buffer. More...
|
| |
| uint32_t | air_mask_from_prefix (uint32_t pfx) |
| | Given a CIDR prefix length, return a mask for extracting the network part of the address. More...
|
| |
| void | air_hexdump_g_string_append (GString *str, char *lpfx, uint8_t *buf, uint32_t len) |
| | Append a given binary buffer as a hex + ASCII dump with 16 bytes per line to the given GString. More...
|
| |
| gboolean | air_sock_maxrcvbuf (int sock, int *size) |
| | Maximize socket receive buffer size. More...
|
| |
| gboolean | air_sock_maxsndbuf (int sock, int *size) |
| | Maximize socket send buffer size. More...
|
| |
|
void | air_ignore_sigpipe (void) |
| | Ignore SIGPIPE, so that failed pipe writes or TCP writes on reset sockets will return EPIPE instead of terminating the application.
|
| |
Airframe utility functions.
A home for utility functions that have no other.
◆ air_timefmt_en
Time format description for air_time_* functions.
| Enumerator |
|---|
| AIR_TIME_ISO8601 | ISO8601 format with space between date and time.
|
| AIR_TIME_ISO8601_NS | ISO8601 format with T between date and time.
|
| AIR_TIME_SQUISHED | Time format squished into single string for ASCII sort by time.
|
| AIR_TIME_ISO8601_HMS | ISO8601 format with time only.
|
◆ air_hexdump_g_string_append()
| void air_hexdump_g_string_append |
( |
GString * |
str, |
|
|
char * |
lpfx, |
|
|
uint8_t * |
buf, |
|
|
uint32_t |
len |
|
) |
| |
Append a given binary buffer as a hex + ASCII dump with 16 bytes per line to the given GString.
- Parameters
-
| str | string to append to |
| lpfx | string to prefix each line of output with. Use for indentation and labeling. |
| buf | Buffer to dump to GString |
| len | Length of buf |
◆ air_ip6addr_buf_print()
| void air_ip6addr_buf_print |
( |
char * |
buf, |
|
|
uint8_t * |
ipaddr |
|
) |
| |
Write the presentation format of an IPv6 address to a given buffer.
The buffer must be at least AIR_IP6ADDR_BUF_MINSZ (40) bytes long.
- Parameters
-
| buf | buffer to write to |
| ipaddr | address to print |
◆ air_ipaddr_buf_print()
| void air_ipaddr_buf_print |
( |
char * |
buf, |
|
|
uint32_t |
ipaddr |
|
) |
| |
Write the dotted quad format of an IPv4 address to a given buffer.
The buffer must be at least AIR_IPADDR_BUF_MINSZ (16) bytes long.
- Parameters
-
| buf | buffer to write to |
| ipaddr | address to print |
◆ air_mask_from_prefix()
| uint32_t air_mask_from_prefix |
( |
uint32_t |
pfx | ) |
|
Given a CIDR prefix length, return a mask for extracting the network part of the address.
- Parameters
-
- Returns
- network-part mask bits
◆ air_mstime_g_string_append()
| void air_mstime_g_string_append |
( |
GString * |
str, |
|
|
uint64_t |
mstime, |
|
|
AirTimeFormat |
fmtid |
|
) |
| |
Append a string format of a time in epoch milliseconds to a given GString in a given format.
- Parameters
-
| str | string to append to |
| mstime | time to append in epoch milliseconds |
| fmtid | time format description |
◆ air_sock_maxrcvbuf()
| gboolean air_sock_maxrcvbuf |
( |
int |
sock, |
|
|
int * |
size |
|
) |
| |
Maximize socket receive buffer size.
Sets the socket's receive buffer to the highest available size less than or equal to the given size.
- Parameters
-
| sock | socket to increase buffer size of |
| size | pointer to maximum size to set. Returns actually set size. |
- Returns
- TRUE on success, FALSE otherwise.
◆ air_sock_maxsndbuf()
| gboolean air_sock_maxsndbuf |
( |
int |
sock, |
|
|
int * |
size |
|
) |
| |
Maximize socket send buffer size.
Sets the socket's receive buffer to the highest available size less than or equal to the given size.
- Parameters
-
| sock | socket to increase buffer size of |
| size | pointer to maximum size to set. Returns actually set size. |
- Returns
- TRUE on success, FALSE otherwise.
◆ air_time_buf_print()
| void air_time_buf_print |
( |
char * |
buf, |
|
|
time_t |
time, |
|
|
AirTimeFormat |
fmtid |
|
) |
| |
Write a string format of a time to a given buffer in a given format.
- Parameters
-
| buf | buffer to write to |
| time | time to print in epoch seconds |
| fmtid | time format description |
◆ air_time_g_string_append()
| void air_time_g_string_append |
( |
GString * |
str, |
|
|
time_t |
time, |
|
|
AirTimeFormat |
fmtid |
|
) |
| |
Append a string format of a time to a given GString in a given format.
- Parameters
-
| str | string to append to |
| time | time to append in epoch seconds |
| fmtid | time format description |
◆ air_time_gm()
| time_t air_time_gm |
( |
uint32_t |
year, |
|
|
uint32_t |
mon, |
|
|
uint32_t |
day, |
|
|
uint32_t |
hour, |
|
|
uint32_t |
min, |
|
|
uint32_t |
sec |
|
) |
| |
Portable, less unix-ish timegm() implementation.
Converts a UTC year, month, day, hour, minute, and second into a time in epoch seconds. Handles leap years but not leap seconds. mon is 1-based (as in English representations), and year is CE, not 1900-based.
- Parameters
-
| year | year of date to convert (year CE) |
| mon | month of date to convert (1-12) |
| day | day of date to convert (1-31) |
| hour | hour of date to convert (0-23) |
| min | minute of date to convert (0-59) |
| sec | second of date to convert (0-59) |
- Returns
- epoch seconds