Added ASCII version of the NGM_EIFACE_GET_IFNAME message, "getifname".

This commit is contained in:
Ruslan Ermilov 2005-02-03 11:52:42 +00:00
parent b26f9f6376
commit c60878f0d2
3 changed files with 13 additions and 17 deletions

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 9, 2004
.Dd February 3, 2005
.Dt NG_EIFACE 4
.Os
.Sh NAME
@ -64,7 +64,7 @@ packets received by any real Ethernet interface.
.Sh CONTROL MESSAGES
This node type supports the generic control messages, plus the following:
.Bl -tag -width indent
.It Dv NGM_EIFACE_SET
.It Dv NGM_EIFACE_SET Pq Li set
Set link-level address of the interface.
Requires
.Vt "struct ether_addr"
@ -76,7 +76,7 @@ version, called
which requires as an argument an
.Tn ASCII
string consisting of 6 colon-separated hex digits.
.It Dv NGM_EIFACE_GET_IFNAME
.It Dv NGM_EIFACE_GET_IFNAME Pq Li getifname
Return the name of the associated interface as a
.Dv NUL Ns -terminated
.Tn ASCII

View File

@ -56,6 +56,13 @@
#include <net/if_arp.h>
static const struct ng_cmdlist ng_eiface_cmdlist[] = {
{
NGM_EIFACE_COOKIE,
NGM_EIFACE_GET_IFNAME,
"getifname",
NULL,
&ng_parse_string_type
},
{
NGM_EIFACE_COOKIE,
NGM_EIFACE_SET,
@ -517,19 +524,13 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
}
case NGM_EIFACE_GET_IFNAME:
{
struct ng_eiface_ifname *arg;
NG_MKRESPONSE(resp, msg, sizeof(*arg), M_NOWAIT);
NG_MKRESPONSE(resp, msg, IFNAMSIZ + 1, 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));
strlcpy(resp->data, ifp->if_xname, IFNAMSIZ + 1);
break;
}
case NGM_EIFACE_GET_IFADDRS:
{

View File

@ -40,7 +40,6 @@
/* 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"
@ -52,13 +51,9 @@
/* Netgraph commands */
enum {
NGM_EIFACE_GET_IFNAME = 1, /* returns struct ng_eiface_ifname */
NGM_EIFACE_GET_IFNAME = 1, /* get the interface name */
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];
};
#endif /* _NETGRAPH_NG_EIFACE_H_ */