FreeBSD Bugzilla – Attachment 42466 Details for
Bug 66225
[netgraph] [patch] extend ng_eiface(4) control messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
ng_eiface.diff
ng_eiface.diff (text/plain), 5.70 KB, created by
Robin Breathe
on 2004-05-03 22:00:38 UTC
(
hide
)
Description:
ng_eiface.diff
Filename:
MIME Type:
Creator:
Robin Breathe
Created:
2004-05-03 22:00:38 UTC
Size:
5.70 KB
patch
obsolete
>diff -ruN share/man/man4/ng_eiface.4 share/man/man4/ng_eiface.4.ori >--- share/man/man4/ng_eiface.4.ori Mon May 3 20:23:57 2004 >+++ share/man/man4/ng_eiface.4 Mon May 3 20:35:27 2004 >@@ -65,25 +65,21 @@ > .Sh CONTROL MESSAGES > This node type supports the generic control messages, plus the following: > .Bl -tag -width indent >-.It Dv NGM_EIFACE_SET >-Set link-level address of the interface. >-Requires >-.Vt "struct ether_addr" >-as an argument. >-This message also has an >-.Tn ASCII >-version, called >-.Dq Li set , >-which requires as an argument an >-.Tn ASCII >-string consisting of 6 colon-separated hex digits. >-.It Dv NGM_EIFACE_GET_IFNAME >-Return the name of the associated interface as a >+.It Dv NGM_EIFACE_GET_IFNAME Pq Li getifname >+Returns the name of the associated interface as a > .Dv NUL Ns -terminated > .Tn ASCII > string. >-.It Dv NGM_EIFACE_GET_IFADDRS >-Return the list of link-level addresses associated with the node. >+.It DV NGM_EIFACE_GET_IFINDEX Pq Li getifindex >+Returns the global index of the associated inteface as a 32-bit integer. >+.It DV NGM_EIFACE_GET_ENADDR Pq Li getenaddr >+Returns the associated interface's unique six-byte Ethernet address. >+.It Dv NGM_EIFACE_SET_ENADDR Pq Li setenaddr >+Sets the associated interface's unique six-byte Ethernet address. >+This control message is equivalent to using the >+.Dv SIOCIFLLADDR >+.Xr ioctl 2 >+system call. > .El > .Sh SHUTDOWN > This node shuts down upon receipt of a >diff -ruN sys/netgraph/ng_eiface.c sys/netgraph/ng_eiface.c.ori >--- sys/netgraph/ng_eiface.c.ori Thu Apr 22 19:11:57 2004 >+++ sys/netgraph/ng_eiface.c Mon May 3 20:16:06 2004 >@@ -60,8 +60,29 @@ > static const struct ng_cmdlist ng_eiface_cmdlist[] = { > { > NGM_EIFACE_COOKIE, >- NGM_EIFACE_SET, >- "set", >+ NGM_EIFACE_GET_IFNAME, >+ "getifname", >+ NULL, >+ &ng_parse_string_type >+ }, >+ { >+ NGM_EIFACE_COOKIE, >+ NGM_EIFACE_GET_IFINDEX, >+ "getifindex", >+ NULL, >+ &ng_parse_int32_type >+ }, >+ { >+ NGM_EIFACE_COOKIE, >+ NGM_EIFACE_GET_ENADDR, >+ "getenaddr", >+ NULL, >+ &ng_parse_enaddr_type >+ }, >+ { >+ NGM_EIFACE_COOKIE, >+ NGM_EIFACE_SET_ENADDR, >+ "setenaddr", > &ng_parse_enaddr_type, > NULL > }, >@@ -486,80 +507,42 @@ > switch (msg->header.typecookie) { > case NGM_EIFACE_COOKIE: > switch (msg->header.cmd) { >- case NGM_EIFACE_SET: >- { >- struct ether_addr *eaddr; >- struct ifaddr *ifa; >- struct sockaddr_dl *sdl; >- >- if (msg->header.arglen != sizeof(struct ether_addr)){ >- error = EINVAL; >+ case NGM_EIFACE_GET_IFNAME: >+ NG_MKRESPONSE(resp, msg, IFNAMSIZ + 1, M_NOWAIT); >+ if (resp == NULL) { >+ error = ENOMEM; > break; > } >- eaddr = (struct ether_addr *)(msg->data); >- bcopy(eaddr, priv->arpcom.ac_enaddr, ETHER_ADDR_LEN); >- >- /* And put it in the ifaddr list */ >- TAILQ_FOREACH(ifa, &(ifp->if_addrhead), ifa_link) { >- sdl = (struct sockaddr_dl *)ifa->ifa_addr; >- if (sdl->sdl_type == IFT_ETHER) { >- bcopy((IFP2AC(ifp))->ac_enaddr, >- LLADDR(sdl), ifp->if_addrlen); >- break; >- } >- } >+ strlcpy(resp->data, ifp->if_xname, IFNAMSIZ + 1); > break; >- } > >- case NGM_EIFACE_GET_IFNAME: >- { >- struct ng_eiface_ifname *arg; >- >- NG_MKRESPONSE(resp, msg, sizeof(*arg), M_NOWAIT); >+ case NGM_EIFACE_GET_IFINDEX: >+ NG_MKRESPONSE(resp, msg, sizeof(u_int32_t), M_NOWAIT); > if (resp == NULL) { > error = ENOMEM; > break; > } >- arg = (struct ng_eiface_ifname *)resp->data; >- strlcpy(arg->ngif_name, ifp->if_xname, >- sizeof(arg->ngif_name)); >+ *((u_int32_t *)resp->data) = ifp->if_index; > break; >- } > >- case NGM_EIFACE_GET_IFADDRS: >- { >- struct ifaddr *ifa; >- caddr_t ptr; >- int buflen; >- >-#define SA_SIZE(s) ((s)->sa_len<sizeof(*(s))? sizeof(*(s)):(s)->sa_len) >- >- /* Determine size of response and allocate it */ >- buflen = 0; >- TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) >- buflen += SA_SIZE(ifa->ifa_addr); >- NG_MKRESPONSE(resp, msg, buflen, M_NOWAIT); >+ case NGM_EIFACE_GET_ENADDR: >+ NG_MKRESPONSE(resp, msg, ETHER_ADDR_LEN, M_NOWAIT); > if (resp == NULL) { > error = ENOMEM; > break; > } >- /* Add addresses */ >- ptr = resp->data; >- TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { >- const int len = SA_SIZE(ifa->ifa_addr); >- >- if (buflen < len) { >- log(LOG_ERR, "%s: len changed?\n", >- ifp->if_xname); >- break; >- } >- bcopy(ifa->ifa_addr, ptr, len); >- ptr += len; >- buflen -= len; >+ bcopy((IFP2AC(ifp))->ac_enaddr, >+ resp->data, ETHER_ADDR_LEN); >+ break; >+ >+ case NGM_EIFACE_SET_ENADDR: >+ if (msg->header.arglen != ETHER_ADDR_LEN){ >+ error = EINVAL; >+ break; > } >+ error = if_setlladdr(ifp, >+ (u_char *)msg->data, ETHER_ADDR_LEN); > break; >-#undef SA_SIZE >- } > > default: > error = EINVAL; >diff -ruN sys/netgraph/ng_eiface.h sys/netgraph/ng_eiface.h.ori >--- sys/netgraph/ng_eiface.h.ori Wed Dec 17 13:03:32 2003 >+++ sys/netgraph/ng_eiface.h Mon May 3 20:16:06 2004 >@@ -38,25 +38,21 @@ > > /* Interface base name */ > #define NG_EIFACE_EIFACE_NAME "ngeth" >-#define NG_EIFACE_EIFACE_NAME_MAX 15 > > /* My hook names */ > #define NG_EIFACE_HOOK_ETHER "ether" > > /* MTU bounds */ > #define NG_EIFACE_MTU_MIN 72 >-#define NG_EIFACE_MTU_MAX 2312 >+#define NG_EIFACE_MTU_MAX 9000 > #define NG_EIFACE_MTU_DEFAULT 1500 > > /* Netgraph commands */ > enum { >- NGM_EIFACE_GET_IFNAME = 1, /* returns struct ng_eiface_ifname */ >- NGM_EIFACE_GET_IFADDRS, /* returns list of addresses */ >- NGM_EIFACE_SET, /* set ethernet address */ >-}; >- >-struct ng_eiface_ifname { >- char ngif_name[NG_EIFACE_EIFACE_NAME_MAX + 1]; >+ NGM_EIFACE_GET_IFNAME = 1, /* get the interface name */ >+ NGM_EIFACE_GET_IFINDEX, /* get the interface global index # */ >+ NGM_EIFACE_GET_ENADDR, /* get Ethernet address */ >+ NGM_EIFACE_SET_ENADDR, /* set Ethernet address */ > }; > > #endif /* _NETGRAPH_NG_EIFACE_H_ */
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 66225
: 42466