From 1164db57e40de8efae073eba01ba85bb26ae5a8d Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Sun, 7 Mar 2004 23:00:44 +0000 Subject: [PATCH] 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(+) diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 430e0e650155..38845fc33298 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 98b9c7cdd48e..6c3bbbc56df0 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 {