Implemented the "getifindex" control message.

PR:		kern/63864
Submitted by:	Gleb Smirnoff
This commit is contained in:
Ruslan Ermilov 2004-03-07 23:00:44 +00:00
parent 8c423a998e
commit 1164db57e4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=126730
2 changed files with 17 additions and 0 deletions

View File

@ -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;

View File

@ -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 {