From bf23ea37e6288cf0227dab4c910f8cde345cd140 Mon Sep 17 00:00:00 2001 From: ru Date: Sun, 7 Mar 2004 23:00:44 +0000 Subject: Implemented the "getifindex" control message. PR: kern/63864 Submitted by: Gleb Smirnoff --- sys/netgraph/ng_iface.c | 16 ++++++++++++++++ sys/netgraph/ng_iface.h | 1 + 2 files changed, 17 insertions(+) (limited to 'sys') diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 430e0e6..38845fc 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -186,6 +186,13 @@ static const struct ng_cmdlist ng_iface_cmds[] = { NULL, &ng_cisco_ipaddr_type }, + { + NGM_IFACE_COOKIE, + NGM_IFACE_GET_IFINDEX, + "getifindex", + NULL, + &ng_parse_uint32_type + }, { 0 } }; @@ -667,6 +674,15 @@ ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook) break; } + case NGM_IFACE_GET_IFINDEX: + NG_MKRESPONSE(resp, msg, sizeof(uint32_t), M_NOWAIT); + if (resp == NULL) { + error = ENOMEM; + break; + } + *((uint32_t *)resp->data) = priv->ifp->if_index; + break; + default: error = EINVAL; break; diff --git a/sys/netgraph/ng_iface.h b/sys/netgraph/ng_iface.h index 98b9c7c..6c3bbbc 100644 --- a/sys/netgraph/ng_iface.h +++ b/sys/netgraph/ng_iface.h @@ -69,6 +69,7 @@ enum { NGM_IFACE_GET_IFNAME = 1, /* returns struct ng_iface_ifname */ NGM_IFACE_POINT2POINT, NGM_IFACE_BROADCAST, + NGM_IFACE_GET_IFINDEX, }; struct ng_iface_ifname { -- cgit v1.1