Commit ff148e90 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add EUI-64 parsing and formatting.

parent 489454e8
......@@ -264,6 +264,18 @@ format_prefix(const unsigned char *prefix, unsigned char plen)
return buf[i];
}
const char *
format_eui64(const unsigned char *eui)
{
static char buf[4][28];
static int i = 0;
i = (i + 1) % 4;
snprintf(buf[i], 28, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
eui[0], eui[1], eui[2], eui[3],
eui[4], eui[5], eui[6], eui[7]);
return buf[i];
}
int
parse_address(const char *address, unsigned char *addr_r, int *af_r)
{
......@@ -346,6 +358,18 @@ parse_net(const char *net, unsigned char *prefix_r, unsigned char *plen_r,
return 0;
}
int
parse_eui64(const char *eui, unsigned char *eui_r)
{
int n;
n = sscanf(eui, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
&eui_r[0], &eui_r[1], &eui_r[2], &eui_r[3],
&eui_r[4], &eui_r[5], &eui_r[6], &eui_r[7]);
if(n != 8)
return -1;
return 0;
}
int
wait_for_fd(int direction, int fd, int msecs)
{
......
......@@ -65,9 +65,11 @@ const unsigned char *mask_prefix(unsigned char *ret,
unsigned char plen);
const char *format_address(const unsigned char *address);
const char *format_prefix(const unsigned char *address, unsigned char prefix);
const char * format_eui64(const unsigned char *eui);
int parse_address(const char *address, unsigned char *addr_r, int *af_r);
int parse_net(const char *net, unsigned char *prefix_r, unsigned char *plen_r,
int *af_r);
int parse_eui64(const char *eui, unsigned char *eui_r);
int wait_for_fd(int direction, int fd, int msecs);
int martian_prefix(const unsigned char *prefix, int plen) ATTRIBUTE ((pure));
int v4mapped(const unsigned char *address) ATTRIBUTE ((pure));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment