4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
12 #include <arpa/inet.h>
15 #define sysinfo kernel_sysinfo
16 #include <linux/if_arp.h>
22 const char *ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen)
28 (type == ARPHRD_TUNNEL || type == ARPHRD_SIT || type == ARPHRD_IPGRE)) {
29 return inet_ntop(AF_INET, addr, buf, blen);
32 for (i=0; i<alen; i++) {
34 snprintf(buf+l, blen, "%02x", addr[i]);
38 snprintf(buf+l, blen, ":%02x", addr[i]);
46 int ll_addr_a2n(unsigned char *lladdr, int len, char *arg)
48 if (strchr(arg, '.')) {
50 if (get_addr_1(&pfx, arg, AF_INET)) {
51 error_msg("\"%s\" is invalid lladdr.", arg);
57 memcpy(lladdr, pfx.data, 4);
62 for (i=0; i<len; i++) {
64 char *cp = strchr(arg, ':');
69 if (sscanf(arg, "%x", &temp) != 1) {
70 error_msg("\"%s\" is invalid lladdr.", arg);
73 if (temp < 0 || temp > 255) {
74 error_msg("\"%s\" is invalid lladdr.", arg);