Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/networking/libiproute/ll_addr.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/networking/libiproute/ll_addr.c
r1765 r2725 1 1 /* vi: set sw=4 ts=4: */ 2 2 /* 3 * ll_addr.c 3 * This program is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU General Public License 5 * as published by the Free Software Foundation; either version 6 * 2 of the License, or (at your option) any later version. 4 7 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 8 * 2 of the License, or (at your option) any later version. 9 * 10 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 11 9 */ 12 10 … … 18 16 19 17 20 const char *ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen)18 const char* FAST_FUNC ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen) 21 19 { 22 20 int i; 23 21 int l; 24 22 25 if (alen == 4 && 26 (type == ARPHRD_TUNNEL || type == ARPHRD_SIT || type == ARPHRD_IPGRE)) { 23 if (alen == 4 24 && (type == ARPHRD_TUNNEL || type == ARPHRD_SIT || type == ARPHRD_IPGRE) 25 ) { 27 26 return inet_ntop(AF_INET, addr, buf, blen); 28 27 } 29 28 l = 0; 30 for (i =0; i<alen; i++) {31 if (i ==0) {32 snprintf(buf +l, blen, ":%02x"+1, addr[i]);29 for (i = 0; i < alen; i++) { 30 if (i == 0) { 31 snprintf(buf + l, blen, ":%02x"+1, addr[i]); 33 32 blen -= 2; 34 33 l += 2; 35 34 } else { 36 snprintf(buf +l, blen, ":%02x", addr[i]);35 snprintf(buf + l, blen, ":%02x", addr[i]); 37 36 blen -= 3; 38 37 l += 3; … … 42 41 } 43 42 44 int ll_addr_a2n(unsigned char *lladdr, int len, char *arg)43 int FAST_FUNC ll_addr_a2n(unsigned char *lladdr, int len, char *arg) 45 44 { 45 int i; 46 46 47 if (strchr(arg, '.')) { 47 48 inet_prefix pfx; … … 55 56 memcpy(lladdr, pfx.data, 4); 56 57 return 4; 57 } else { 58 int i; 58 } 59 59 60 for (i=0; i<len; i++) { 61 int temp; 62 char *cp = strchr(arg, ':'); 63 if (cp) { 64 *cp = 0; 65 cp++; 66 } 67 if (sscanf(arg, "%x", &temp) != 1) { 68 bb_error_msg("\"%s\" is invalid lladdr", arg); 69 return -1; 70 } 71 if (temp < 0 || temp > 255) { 72 bb_error_msg("\"%s\" is invalid lladdr", arg); 73 return -1; 74 } 75 lladdr[i] = temp; 76 if (!cp) { 77 break; 78 } 79 arg = cp; 60 for (i = 0; i < len; i++) { 61 int temp; 62 char *cp = strchr(arg, ':'); 63 if (cp) { 64 *cp = 0; 65 cp++; 80 66 } 81 return i+1; 67 if (sscanf(arg, "%x", &temp) != 1 || (temp < 0 || temp > 255)) { 68 bb_error_msg("\"%s\" is invalid lladdr", arg); 69 return -1; 70 } 71 lladdr[i] = temp; 72 if (!cp) { 73 break; 74 } 75 arg = cp; 82 76 } 77 return i+1; 83 78 }
Note:
See TracChangeset
for help on using the changeset viewer.