FreeBSD Bugzilla – Attachment 17327 Details for
Bug 31476
ifconfig's lladdr is ethernet specific
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.33 KB, created by
tinguely
on 2001-10-24 16:10:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
tinguely
Created:
2001-10-24 16:10:00 UTC
Size:
3.33 KB
patch
obsolete
>diff -ur ifconfig.orig/ifconfig.c ifconfig/ifconfig.c >--- ifconfig.orig/ifconfig.c Mon Aug 20 13:38:41 2001 >+++ ifconfig/ifconfig.c Wed Oct 24 09:29:11 2001 >@@ -157,6 +157,7 @@ > void tunnel_status __P((int s)); > void usage __P((void)); > void ifmaybeload __P((char *name)); >+struct ether_addr *generic_aton __P((const char *a, int *cnt)); > > #ifdef INET6 > void in6_fillscopeid __P((struct sockaddr_in6 *sin6)); >@@ -292,7 +293,7 @@ > typedef void af_getprefix __P((const char *, int)); > > af_status in_status, at_status, ether_status; >-af_getaddr in_getaddr, at_getaddr, ether_getaddr; >+af_getaddr in_getaddr, at_getaddr, ether_getaddr, arc_getaddr; > > #ifndef NO_IPX > af_status ipx_status; >@@ -342,6 +343,8 @@ > #endif > { "ether", AF_LINK, ether_status, ether_getaddr, NULL, > 0, SIOCSIFLLADDR, NULL, C(ridreq) }, >+ { "arc", AF_LINK, ether_status, arc_getaddr, NULL, >+ 0, SIOCSIFLLADDR, NULL, C(ridreq) }, > #if 0 /* XXX conflicts with the media command */ > #ifdef USE_IF_MEDIA > { "media", AF_UNSPEC, media_status, NULL, NULL, }, /* XXX not real!! */ >@@ -1059,6 +1062,54 @@ > warn("ioctl (set mtu)"); > } > >+/* >+ * generic_aton() converts up to ETHER_ADDR_LEN ASCII hexadecimal strings >+ * seperated by colons into a ether_addr structure. >+ * generic_aton(a, NULL) is the same as ether_aton(a) >+ * Return values: >+ * function returns converted input from a as an ether_addr structure >+ * cnt returns the number of entries found. >+ */ >+struct ether_addr * >+generic_aton(a, cnt) >+ const char *a; >+ int *cnt; >+{ >+ int i; >+ char *s, *e; >+ static struct ether_addr o; >+ >+ i = 0; >+ >+ s = (char *) a; >+ while ((*s == ':' || ishexnumber(*s)) && i < ETHER_ADDR_LEN) { >+ o.octet[i] = strtol(s, &e, 16); >+ s = e; >+ if (*s == ':') { >+ i++; >+ s++; >+ } >+ } >+ >+ ++i; /* complete last item */ >+ >+ if (cnt != NULL) { >+ if ((i == 1 && o.octet[0] == 0) || *s != '\0') { >+ *cnt = 0; >+ return (NULL); /* no info, or too long */ >+ } else >+ *cnt = i; /* save number of entries */ >+ } else if (i != ETHER_ADDR_LEN) >+ return (NULL); >+ >+ >+ /* empty unused part of structure */ >+ for (; i < ETHER_ADDR_LEN; i++) >+ o.octet[i] = 0; >+ >+ return ((struct ether_addr *)&o); >+} >+ > void > setiflladdr(val, dummy, s, afp) > const char *val; >@@ -1066,17 +1117,18 @@ > int s; > const struct afswtch *afp; > { >+ int i; > struct ether_addr *ea; > >- ea = ether_aton(val); >+ ea = generic_aton(val, &i); > if (ea == NULL) { > warn("malformed link-level address"); > return; > } > strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); >- ifr.ifr_addr.sa_len = ETHER_ADDR_LEN; >+ ifr.ifr_addr.sa_len = i; > ifr.ifr_addr.sa_family = AF_LINK; >- bcopy(ea, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); >+ bcopy(ea, ifr.ifr_addr.sa_data, i); > if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) > warn("ioctl (set lladdr)"); > >@@ -1773,6 +1825,25 @@ > sea->sa_family = AF_LINK; > sea->sa_len = ETHER_ADDR_LEN; > bcopy(ea, sea->sa_data, ETHER_ADDR_LEN); >+} >+ >+void >+arc_getaddr(addr, which) >+ const char *addr; >+ int which; >+{ >+ struct ether_addr *la; >+ struct sockaddr *sea = &ridreq.ifr_addr; >+ int i; >+ >+ la = generic_aton(addr, &i); >+ if (la == NULL || i != 1) >+ errx(1, "malformed arc address"); >+ if (which == MASK) >+ errx(1, "Arcnet does not use netmasks"); >+ sea->sa_family = AF_LINK; >+ sea->sa_len = 1; >+ bcopy(la, sea->sa_data, 1); > } > > /* XXX FIXME -- should use strtoul for better parsing. */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 31476
: 17327