From owner-svn-src-all@FreeBSD.ORG Sat May 19 02:39:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3ADC6106564A; Sat, 19 May 2012 02:39:44 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C91D8FC08; Sat, 19 May 2012 02:39:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4J2dhbC094646; Sat, 19 May 2012 02:39:43 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4J2dhA7094639; Sat, 19 May 2012 02:39:43 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201205190239.q4J2dhA7094639@svn.freebsd.org> From: Marcel Moolenaar Date: Sat, 19 May 2012 02:39:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235640 - in head: lib/libc/net sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 May 2012 02:39:44 -0000 Author: marcel Date: Sat May 19 02:39:43 2012 New Revision: 235640 URL: http://svn.freebsd.org/changeset/base/235640 Log: Use the LLINDEX macro to access the link-level I/F index. This makes it possible to work with a different type for the sdl_index field -- it only requires a recompile. Obtained from: Juniper Networks, Inc. Modified: head/lib/libc/net/if_indextoname.c head/lib/libc/net/if_nameindex.c head/lib/libc/net/if_nametoindex.c head/lib/libc/net/sourcefilter.c head/sys/net/if_dl.h Modified: head/lib/libc/net/if_indextoname.c ============================================================================== --- head/lib/libc/net/if_indextoname.c Sat May 19 02:31:38 2012 (r235639) +++ head/lib/libc/net/if_indextoname.c Sat May 19 02:39:43 2012 (r235640) @@ -70,7 +70,7 @@ if_indextoname(unsigned int ifindex, cha for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_LINK && - ifindex == ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index) + ifindex == LLINDEX((struct sockaddr_dl*)ifa->ifa_addr)) break; } Modified: head/lib/libc/net/if_nameindex.c ============================================================================== --- head/lib/libc/net/if_nameindex.c Sat May 19 02:31:38 2012 (r235639) +++ head/lib/libc/net/if_nameindex.c Sat May 19 02:39:43 2012 (r235640) @@ -123,7 +123,7 @@ if_nameindex(void) if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_LINK) { ifni2->if_index = - ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index; + LLINDEX((struct sockaddr_dl*)ifa->ifa_addr); ifni2->if_name = cp; strcpy(cp, ifa->ifa_name); ifni2++; Modified: head/lib/libc/net/if_nametoindex.c ============================================================================== --- head/lib/libc/net/if_nametoindex.c Sat May 19 02:31:38 2012 (r235639) +++ head/lib/libc/net/if_nametoindex.c Sat May 19 02:39:43 2012 (r235640) @@ -90,7 +90,7 @@ if_nametoindex(const char *ifname) if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_LINK && strcmp(ifa->ifa_name, ifname) == 0) { - ni = ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index; + ni = LLINDEX((struct sockaddr_dl*)ifa->ifa_addr); break; } } Modified: head/lib/libc/net/sourcefilter.c ============================================================================== --- head/lib/libc/net/sourcefilter.c Sat May 19 02:31:38 2012 (r235639) +++ head/lib/libc/net/sourcefilter.c Sat May 19 02:39:43 2012 (r235640) @@ -120,7 +120,7 @@ __inaddr_to_index(in_addr_t ifaddr) psu = (sockunion_t *)ifa->ifa_addr; if (psu && psu->ss.ss_family == AF_LINK && strcmp(ifa->ifa_name, ifname) == 0) { - ifindex = psu->sdl.sdl_index; + ifindex = LLINDEX(&psu->sdl); break; } } Modified: head/sys/net/if_dl.h ============================================================================== --- head/sys/net/if_dl.h Sat May 19 02:31:38 2012 (r235639) +++ head/sys/net/if_dl.h Sat May 19 02:39:43 2012 (r235640) @@ -67,6 +67,7 @@ struct sockaddr_dl { }; #define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen)) +#define LLINDEX(s) ((s)->sdl_index) #ifndef _KERNEL