wpa_supplicant / hostapd
2.5
|
wpa_supplicant/hostapd / common helper functions, etc. More...
Functions | |
int | hex2byte (const char *hex) |
int | hwaddr_aton (const char *txt, u8 *addr) |
Convert ASCII string to MAC address (colon-delimited format) More... | |
int | hwaddr_masked_aton (const char *txt, u8 *addr, u8 *mask, u8 maskable) |
Convert ASCII string with optional mask to MAC address (colon-delimited format) More... | |
int | hwaddr_compact_aton (const char *txt, u8 *addr) |
Convert ASCII string to MAC address (no colon delimitors format) More... | |
int | hwaddr_aton2 (const char *txt, u8 *addr) |
Convert ASCII string to MAC address (in any known format) More... | |
int | hexstr2bin (const char *hex, u8 *buf, size_t len) |
Convert ASCII hex string into binary data. More... | |
int | hwaddr_mask_txt (char *buf, size_t len, const u8 *addr, const u8 *mask) |
void | inc_byte_array (u8 *counter, size_t len) |
Increment arbitrary length byte array by one. More... | |
void | wpa_get_ntp_timestamp (u8 *buf) |
int | wpa_scnprintf (char *buf, size_t size, const char *fmt,...) |
Simpler-to-use snprintf function. More... | |
int | wpa_snprintf_hex_sep (char *buf, size_t buf_size, const u8 *data, size_t len, char sep) |
int | wpa_snprintf_hex (char *buf, size_t buf_size, const u8 *data, size_t len) |
Print data as a hex string into a buffer. More... | |
int | wpa_snprintf_hex_uppercase (char *buf, size_t buf_size, const u8 *data, size_t len) |
Print data as a upper case hex string into buf. More... | |
void | printf_encode (char *txt, size_t maxlen, const u8 *data, size_t len) |
size_t | printf_decode (u8 *buf, size_t maxlen, const char *str) |
const char * | wpa_ssid_txt (const u8 *ssid, size_t ssid_len) |
Convert SSID to a printable string. More... | |
void * | __hide_aliasing_typecast (void *foo) |
char * | wpa_config_parse_string (const char *value, size_t *len) |
int | is_hex (const u8 *data, size_t len) |
size_t | merge_byte_arrays (u8 *res, size_t res_len, const u8 *src1, size_t src1_len, const u8 *src2, size_t src2_len) |
char * | dup_binstr (const void *src, size_t len) |
int | freq_range_list_parse (struct wpa_freq_range_list *res, const char *value) |
int | freq_range_list_includes (const struct wpa_freq_range_list *list, unsigned int freq) |
char * | freq_range_list_str (const struct wpa_freq_range_list *list) |
int | int_array_len (const int *a) |
void | int_array_concat (int **res, const int *a) |
void | int_array_sort_unique (int *a) |
void | int_array_add_unique (int **res, int a) |
void | str_clear_free (char *str) |
void | bin_clear_free (void *bin, size_t len) |
int | random_mac_addr (u8 *addr) |
int | random_mac_addr_keep_oui (u8 *addr) |
const char * | cstr_token (const char *str, const char *delim, const char **last) |
Get next token from const char string. More... | |
char * | str_token (char *str, const char *delim, char **context) |
Get next token from a string. More... | |
size_t | utf8_unescape (const char *inp, size_t in_size, char *outp, size_t out_size) |
size_t | utf8_escape (const char *inp, size_t in_size, char *outp, size_t out_size) |
int | is_ctrl_char (char c) |
wpa_supplicant/hostapd / common helper functions, etc.
const char* cstr_token | ( | const char * | str, |
const char * | delim, | ||
const char ** | last | ||
) |
Get next token from const char string.
str | a constant string to tokenize |
delim | a string of delimiters |
last | a pointer to a character following the returned token It has to be set to NULL for the first call and passed for any futher call. |
This function is similar to str_token, but it can be used with both char and const char strings. Differences:
int hexstr2bin | ( | const char * | hex, |
u8 * | buf, | ||
size_t | len | ||
) |
Convert ASCII hex string into binary data.
hex | ASCII hex string (e.g., "01ab") |
buf | Buffer for the binary data |
len | Length of the text to convert in bytes (of buf); hex will be double this size |
int hwaddr_aton | ( | const char * | txt, |
u8 * | addr | ||
) |
Convert ASCII string to MAC address (colon-delimited format)
txt | MAC address as a string (e.g., "00:11:22:33:44:55") |
addr | Buffer for the MAC address (ETH_ALEN = 6 bytes) |
int hwaddr_aton2 | ( | const char * | txt, |
u8 * | addr | ||
) |
Convert ASCII string to MAC address (in any known format)
txt | MAC address as a string (e.g., 00:11:22:33:44:55 or 0011.2233.4455) |
addr | Buffer for the MAC address (ETH_ALEN = 6 bytes) |
int hwaddr_compact_aton | ( | const char * | txt, |
u8 * | addr | ||
) |
Convert ASCII string to MAC address (no colon delimitors format)
txt | MAC address as a string (e.g., "001122334455") |
addr | Buffer for the MAC address (ETH_ALEN = 6 bytes) |
int hwaddr_masked_aton | ( | const char * | txt, |
u8 * | addr, | ||
u8 * | mask, | ||
u8 | maskable | ||
) |
Convert ASCII string with optional mask to MAC address (colon-delimited format)
txt | MAC address with optional mask as a string (e.g., "00:11:22:33:44:55/ff:ff:ff:ff:00:00") |
addr | Buffer for the MAC address (ETH_ALEN = 6 bytes) |
mask | Buffer for the MAC address mask (ETH_ALEN = 6 bytes) |
maskable | Flag to indicate whether a mask is allowed |
void inc_byte_array | ( | u8 * | counter, |
size_t | len | ||
) |
Increment arbitrary length byte array by one.
counter | Pointer to byte array |
len | Length of the counter in bytes |
This function increments the last byte of the counter by one and continues rolling over to more significant bytes if the byte was incremented from 0xff to 0x00.
char* str_token | ( | char * | str, |
const char * | delim, | ||
char ** | context | ||
) |
Get next token from a string.
buf | String to tokenize. Note that the string might be modified. |
delim | String of delimiters |
context | Pointer to save our context. Should be initialized with NULL on the first call, and passed for any further call. |
int wpa_scnprintf | ( | char * | buf, |
size_t | size, | ||
const char * | fmt, | ||
... | |||
) |
Simpler-to-use snprintf function.
buf | Output buffer |
size | Buffer size |
fmt | format |
Simpler snprintf version that doesn't require further error checks - the return value only indicates how many bytes were actually written, excluding the NULL byte (i.e., 0 on error, size-1 if buffer is not big enough).
int wpa_snprintf_hex | ( | char * | buf, |
size_t | buf_size, | ||
const u8 * | data, | ||
size_t | len | ||
) |
Print data as a hex string into a buffer.
buf | Memory area to use as the output buffer |
buf_size | Maximum buffer size in bytes (should be at least 2 * len + 1) |
data | Data to be printed |
len | Length of data in bytes |
int wpa_snprintf_hex_uppercase | ( | char * | buf, |
size_t | buf_size, | ||
const u8 * | data, | ||
size_t | len | ||
) |
Print data as a upper case hex string into buf.
buf | Memory area to use as the output buffer |
buf_size | Maximum buffer size in bytes (should be at least 2 * len + 1) |
data | Data to be printed |
len | Length of data in bytes |
const char* wpa_ssid_txt | ( | const u8 * | ssid, |
size_t | ssid_len | ||
) |
Convert SSID to a printable string.
ssid | SSID (32-octet string) |
ssid_len | Length of ssid in octets |
This function can be used to convert SSIDs into printable form. In most cases, SSIDs do not use unprintable characters, but IEEE 802.11 standard does not limit the used character set, so anything could be used in an SSID.
This function uses a static buffer, so only one call can be used at the time, i.e., this is not re-entrant and the returned buffer must be used before calling this again.