airutil.h File Reference

Airframe utility functions. More...

#include <airframe/autoinc.h>

Go to the source code of this file.

Defines

#define AIR_TIME_BUF_MINSZ   20
 Minimum buffer size for air_time_buf_print().
#define AIR_IPADDR_BUF_MINSZ   16
 Minimum buffer size for air_ipaddr_buf_print().

Typedefs

typedef enum air_timefmt_en AirTimeFormat
 Time format description for air_time_* functions.

Enumerations

enum  air_timefmt_en { AIR_TIME_ISO8601, AIR_TIME_ISO8601_NS, AIR_TIME_SQUISHED, AIR_TIME_ISO8601_HMS }
 Time format description for air_time_* functions. More...

Functions

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.
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.
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.
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.
void air_ipaddr_buf_print (char *buf, uint32_t ipaddr)
 Write the dotted quad format of an IPv4 address to a given buffer.
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.
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.
gboolean air_sock_maxrcvbuf (int sock, int *size)
 Maximize socket receive buffer size.
gboolean air_sock_maxsndbuf (int sock, int *size)
 Maximize socket send buffer size.


Detailed Description

Airframe utility functions.

A home for utility functions that have no other.


Enumeration Type Documentation

enum 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.


Function Documentation

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

void air_ipaddr_buf_print char *  buf,
uint32_t  ipaddr
 

Write the dotted quad format of an IPv4 address to a given buffer.

Parameters:
buf buffer to write to
ipaddr address to print

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:
pfx prefix length (0-32)
Returns:
network-part mask bits

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

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.

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.

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

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

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


© 2005-2006 Carnegie Mellon University
Generated Thu Jun 15 10:08:41 2006 for Airframe 0.6.2 by Doxygen 1.4.5.