common.c File Reference
#include "includes.h"
#include "common.h"
#include "os.h"
#include <stdint.h>
Go to the source code of this file.
Functions |
void * | __hide_aliasing_typecast (void *foo) |
static int | _wpa_snprintf_hex (char *buf, size_t buf_size, const u8 *data, size_t len, int uppercase) |
static int | hex2byte (const char *hex) |
static int | hex2num (char c) |
int | hexstr2bin (const char *hex, u8 *buf, size_t len) |
int | hwaddr_aton (const char *txt, u8 *addr) |
int | hwaddr_aton2 (const char *txt, u8 *addr) |
void | inc_byte_array (u8 *counter, size_t len) |
void | wpa_get_ntp_timestamp (u8 *buf) |
int | wpa_snprintf_hex (char *buf, size_t buf_size, const u8 *data, size_t len) |
int | wpa_snprintf_hex_uppercase (char *buf, size_t buf_size, const u8 *data, size_t len) |
const char * | wpa_ssid_txt (const u8 *ssid, size_t ssid_len) |
Function Documentation
void* __hide_aliasing_typecast |
( |
void * |
foo |
) |
|
static int _wpa_snprintf_hex |
( |
char * |
buf, |
|
|
size_t |
buf_size, |
|
|
const u8 * |
data, |
|
|
size_t |
len, |
|
|
int |
uppercase | |
|
) |
| | [inline, static] |
static int hex2byte |
( |
const char * |
hex |
) |
[static] |
static int hex2num |
( |
char |
c |
) |
[static] |
int hexstr2bin |
( |
const char * |
hex, |
|
|
u8 * |
buf, |
|
|
size_t |
len | |
|
) |
| | |
hexstr2bin - Convert ASCII hex string into binary data : ASCII hex string (e.g., "01ab") : Buffer for the binary data : Length of the text to convert in bytes (of buf); hex will be double this size Returns: 0 on success, -1 on failure (invalid hex string)
Definition at line 111 of file common.c.
int hwaddr_aton |
( |
const char * |
txt, |
|
|
u8 * |
addr | |
|
) |
| | |
hwaddr_aton - Convert ASCII string to MAC address (colon-delimited format) : MAC address as a string (e.g., "00:11:22:33:44:55") : Buffer for the MAC address (ETH_ALEN = 6 bytes) Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
Definition at line 51 of file common.c.
int hwaddr_aton2 |
( |
const char * |
txt, |
|
|
u8 * |
addr | |
|
) |
| | |
hwaddr_aton2 - Convert ASCII string to MAC address (in any known format) : MAC address as a string (e.g., 00:11:22:33:44:55 or 0011.2233.4455) : Buffer for the MAC address (ETH_ALEN = 6 bytes) Returns: Characters used (> 0) on success, -1 on failure
Definition at line 79 of file common.c.
void inc_byte_array |
( |
u8 * |
counter, |
|
|
size_t |
len | |
|
) |
| | |
inc_byte_array - Increment arbitrary length byte array by one : Pointer to byte array : 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.
Definition at line 138 of file common.c.
void wpa_get_ntp_timestamp |
( |
u8 * |
buf |
) |
|
int wpa_snprintf_hex |
( |
char * |
buf, |
|
|
size_t |
buf_size, |
|
|
const u8 * |
data, |
|
|
size_t |
len | |
|
) |
| | |
wpa_snprintf_hex - Print data as a hex string into a buffer : Memory area to use as the output buffer : Maximum buffer size in bytes (should be at least 2 * len + 1) : Data to be printed : Length of data in bytes Returns: Number of bytes written
Definition at line 198 of file common.c.
int wpa_snprintf_hex_uppercase |
( |
char * |
buf, |
|
|
size_t |
buf_size, |
|
|
const u8 * |
data, |
|
|
size_t |
len | |
|
) |
| | |
wpa_snprintf_hex_uppercase - Print data as a upper case hex string into buf : Memory area to use as the output buffer : Maximum buffer size in bytes (should be at least 2 * len + 1) : Data to be printed : Length of data in bytes Returns: Number of bytes written
Definition at line 212 of file common.c.
const char* wpa_ssid_txt |
( |
const u8 * |
ssid, |
|
|
size_t |
ssid_len | |
|
) |
| | |
wpa_ssid_txt - Convert SSID to a printable string : SSID (32-octet string) : Length of ssid in octets Returns: Pointer to a printable string
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.
Definition at line 343 of file common.c.