|
Lines 157-162
Link Here
|
| 157 |
void tunnel_status __P((int s)); |
157 |
void tunnel_status __P((int s)); |
| 158 |
void usage __P((void)); |
158 |
void usage __P((void)); |
| 159 |
void ifmaybeload __P((char *name)); |
159 |
void ifmaybeload __P((char *name)); |
|
|
160 |
struct ether_addr *generic_aton __P((const char *a, int *cnt)); |
| 160 |
|
161 |
|
| 161 |
#ifdef INET6 |
162 |
#ifdef INET6 |
| 162 |
void in6_fillscopeid __P((struct sockaddr_in6 *sin6)); |
163 |
void in6_fillscopeid __P((struct sockaddr_in6 *sin6)); |
|
Lines 292-298
Link Here
|
| 292 |
typedef void af_getprefix __P((const char *, int)); |
293 |
typedef void af_getprefix __P((const char *, int)); |
| 293 |
|
294 |
|
| 294 |
af_status in_status, at_status, ether_status; |
295 |
af_status in_status, at_status, ether_status; |
| 295 |
af_getaddr in_getaddr, at_getaddr, ether_getaddr; |
296 |
af_getaddr in_getaddr, at_getaddr, ether_getaddr, arc_getaddr; |
| 296 |
|
297 |
|
| 297 |
#ifndef NO_IPX |
298 |
#ifndef NO_IPX |
| 298 |
af_status ipx_status; |
299 |
af_status ipx_status; |
|
Lines 342-347
Link Here
|
| 342 |
#endif |
343 |
#endif |
| 343 |
{ "ether", AF_LINK, ether_status, ether_getaddr, NULL, |
344 |
{ "ether", AF_LINK, ether_status, ether_getaddr, NULL, |
| 344 |
0, SIOCSIFLLADDR, NULL, C(ridreq) }, |
345 |
0, SIOCSIFLLADDR, NULL, C(ridreq) }, |
|
|
346 |
{ "arc", AF_LINK, ether_status, arc_getaddr, NULL, |
| 347 |
0, SIOCSIFLLADDR, NULL, C(ridreq) }, |
| 345 |
#if 0 /* XXX conflicts with the media command */ |
348 |
#if 0 /* XXX conflicts with the media command */ |
| 346 |
#ifdef USE_IF_MEDIA |
349 |
#ifdef USE_IF_MEDIA |
| 347 |
{ "media", AF_UNSPEC, media_status, NULL, NULL, }, /* XXX not real!! */ |
350 |
{ "media", AF_UNSPEC, media_status, NULL, NULL, }, /* XXX not real!! */ |
|
Lines 1059-1064
Link Here
|
| 1059 |
warn("ioctl (set mtu)"); |
1062 |
warn("ioctl (set mtu)"); |
| 1060 |
} |
1063 |
} |
| 1061 |
|
1064 |
|
|
|
1065 |
/* |
| 1066 |
* generic_aton() converts up to ETHER_ADDR_LEN ASCII hexadecimal strings |
| 1067 |
* seperated by colons into a ether_addr structure. |
| 1068 |
* generic_aton(a, NULL) is the same as ether_aton(a) |
| 1069 |
* Return values: |
| 1070 |
* function returns converted input from a as an ether_addr structure |
| 1071 |
* cnt returns the number of entries found. |
| 1072 |
*/ |
| 1073 |
struct ether_addr * |
| 1074 |
generic_aton(a, cnt) |
| 1075 |
const char *a; |
| 1076 |
int *cnt; |
| 1077 |
{ |
| 1078 |
int i; |
| 1079 |
char *s, *e; |
| 1080 |
static struct ether_addr o; |
| 1081 |
|
| 1082 |
i = 0; |
| 1083 |
|
| 1084 |
s = (char *) a; |
| 1085 |
while ((*s == ':' || ishexnumber(*s)) && i < ETHER_ADDR_LEN) { |
| 1086 |
o.octet[i] = strtol(s, &e, 16); |
| 1087 |
s = e; |
| 1088 |
if (*s == ':') { |
| 1089 |
i++; |
| 1090 |
s++; |
| 1091 |
} |
| 1092 |
} |
| 1093 |
|
| 1094 |
++i; /* complete last item */ |
| 1095 |
|
| 1096 |
if (cnt != NULL) { |
| 1097 |
if ((i == 1 && o.octet[0] == 0) || *s != '\0') { |
| 1098 |
*cnt = 0; |
| 1099 |
return (NULL); /* no info, or too long */ |
| 1100 |
} else |
| 1101 |
*cnt = i; /* save number of entries */ |
| 1102 |
} else if (i != ETHER_ADDR_LEN) |
| 1103 |
return (NULL); |
| 1104 |
|
| 1105 |
|
| 1106 |
/* empty unused part of structure */ |
| 1107 |
for (; i < ETHER_ADDR_LEN; i++) |
| 1108 |
o.octet[i] = 0; |
| 1109 |
|
| 1110 |
return ((struct ether_addr *)&o); |
| 1111 |
} |
| 1112 |
|
| 1062 |
void |
1113 |
void |
| 1063 |
setiflladdr(val, dummy, s, afp) |
1114 |
setiflladdr(val, dummy, s, afp) |
| 1064 |
const char *val; |
1115 |
const char *val; |
|
Lines 1066-1082
Link Here
|
| 1066 |
int s; |
1117 |
int s; |
| 1067 |
const struct afswtch *afp; |
1118 |
const struct afswtch *afp; |
| 1068 |
{ |
1119 |
{ |
|
|
1120 |
int i; |
| 1069 |
struct ether_addr *ea; |
1121 |
struct ether_addr *ea; |
| 1070 |
|
1122 |
|
| 1071 |
ea = ether_aton(val); |
1123 |
ea = generic_aton(val, &i); |
| 1072 |
if (ea == NULL) { |
1124 |
if (ea == NULL) { |
| 1073 |
warn("malformed link-level address"); |
1125 |
warn("malformed link-level address"); |
| 1074 |
return; |
1126 |
return; |
| 1075 |
} |
1127 |
} |
| 1076 |
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); |
1128 |
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); |
| 1077 |
ifr.ifr_addr.sa_len = ETHER_ADDR_LEN; |
1129 |
ifr.ifr_addr.sa_len = i; |
| 1078 |
ifr.ifr_addr.sa_family = AF_LINK; |
1130 |
ifr.ifr_addr.sa_family = AF_LINK; |
| 1079 |
bcopy(ea, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); |
1131 |
bcopy(ea, ifr.ifr_addr.sa_data, i); |
| 1080 |
if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) |
1132 |
if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) |
| 1081 |
warn("ioctl (set lladdr)"); |
1133 |
warn("ioctl (set lladdr)"); |
| 1082 |
|
1134 |
|
|
Lines 1773-1778
Link Here
|
| 1773 |
sea->sa_family = AF_LINK; |
1825 |
sea->sa_family = AF_LINK; |
| 1774 |
sea->sa_len = ETHER_ADDR_LEN; |
1826 |
sea->sa_len = ETHER_ADDR_LEN; |
| 1775 |
bcopy(ea, sea->sa_data, ETHER_ADDR_LEN); |
1827 |
bcopy(ea, sea->sa_data, ETHER_ADDR_LEN); |
|
|
1828 |
} |
| 1829 |
|
| 1830 |
void |
| 1831 |
arc_getaddr(addr, which) |
| 1832 |
const char *addr; |
| 1833 |
int which; |
| 1834 |
{ |
| 1835 |
struct ether_addr *la; |
| 1836 |
struct sockaddr *sea = &ridreq.ifr_addr; |
| 1837 |
int i; |
| 1838 |
|
| 1839 |
la = generic_aton(addr, &i); |
| 1840 |
if (la == NULL || i != 1) |
| 1841 |
errx(1, "malformed arc address"); |
| 1842 |
if (which == MASK) |
| 1843 |
errx(1, "Arcnet does not use netmasks"); |
| 1844 |
sea->sa_family = AF_LINK; |
| 1845 |
sea->sa_len = 1; |
| 1846 |
bcopy(la, sea->sa_data, 1); |
| 1776 |
} |
1847 |
} |
| 1777 |
|
1848 |
|
| 1778 |
/* XXX FIXME -- should use strtoul for better parsing. */ |
1849 |
/* XXX FIXME -- should use strtoul for better parsing. */ |