From glebius@cell.sick.ru  Sat Mar  6 17:36:13 2004
Return-Path: <glebius@cell.sick.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9A58D16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  6 Mar 2004 17:36:13 -0800 (PST)
Received: from cell.sick.ru (cell.sick.ru [217.72.144.68])
	by mx1.FreeBSD.org (Postfix) with ESMTP id DA5B543D1D
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  6 Mar 2004 17:36:12 -0800 (PST)
	(envelope-from glebius@cell.sick.ru)
Received: from cell.sick.ru (glebius@localhost [127.0.0.1])
	by cell.sick.ru (8.12.9/8.12.8) with ESMTP id i271aBQE060572
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 7 Mar 2004 04:36:11 +0300 (MSK)
	(envelope-from glebius@cell.sick.ru)
Received: (from glebius@localhost)
	by cell.sick.ru (8.12.9/8.12.6/Submit) id i271aBBx060571;
	Sun, 7 Mar 2004 04:36:11 +0300 (MSK)
Message-Id: <200403070136.i271aBBx060571@cell.sick.ru>
Date: Sun, 7 Mar 2004 04:36:11 +0300 (MSK)
From: Gleb Smirnoff <glebius@cell.sick.ru>
Reply-To: Gleb Smirnoff <glebius@cell.sick.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] new control message for ng_iface(4) - getifindex
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         63864
>Category:       kern
>Synopsis:       [patch] new control message for ng_iface(4) - getifindex
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 06 17:40:17 PST 2004
>Closed-Date:    Sun Mar 07 15:02:28 PST 2004
>Last-Modified:  Sun Mar 07 15:02:28 PST 2004
>Originator:     Gleb Smirnoff
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD morannon.bestcom.ru 5.2-CURRENT FreeBSD 5.2-CURRENT #3: Mon Mar  1 21:49:20 MSK 2004     glebius@morannon.bestcom.ru:/usr/obj/usr/src/sys/MORANNON  i386

>Description:

	Add support for message NGM_IFACE_GET_IFINDEX, which returns index number of the
	interface, node corresponds to.

>How-To-Repeat:
>Fix:

	The patch is trivial, code is same as in ng_ether(4), which already has
	support for this message.

--- ng_iface.h.orig	Sun Mar  7 04:13:43 2004
+++ ng_iface.h	Sun Mar  7 04:14:35 2004
@@ -69,6 +69,7 @@
 	NGM_IFACE_GET_IFNAME = 1,	/* returns struct ng_iface_ifname */
 	NGM_IFACE_POINT2POINT,
 	NGM_IFACE_BROADCAST,
+	NGM_IFACE_GET_IFINDEX
 };
 
 struct ng_iface_ifname {
--- ng_iface.c.orig	Sun Mar  7 04:12:32 2004
+++ ng_iface.c	Sun Mar  7 04:16:14 2004
@@ -186,6 +186,13 @@
 	  NULL,
 	  &ng_cisco_ipaddr_type
 	},
+        {
+          NGM_IFACE_COOKIE,
+          NGM_IFACE_GET_IFINDEX,
+          "getifindex",
+          NULL,
+          &ng_parse_int32_type
+        },
 	{ 0 }
 };
 
@@ -666,6 +673,15 @@
 			}
 			break;
 		    }
+
+                case NGM_IFACE_GET_IFINDEX:
+			NG_MKRESPONSE(resp, msg, sizeof(u_int32_t), M_NOWAIT);
+			if (resp == NULL) {
+				error = ENOMEM;
+				break;
+			}
+			*((u_int32_t *)resp->data) = priv->ifp->if_index;
+			break; 
 
 		default:
 			error = EINVAL;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Sun Mar 7 15:01:03 PST 2004 
State-Changed-Why:  
Committed with tiny modifications, thanks! 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Sun Mar 7 15:01:03 PST 2004 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=63864 
>Unformatted:
