From owner-svn-src-projects@freebsd.org Mon Sep 7 13:02:26 2015 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C7B99CB9EA for ; Mon, 7 Sep 2015 13:02:26 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D29E1642; Mon, 7 Sep 2015 13:02:26 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t87D2Q3p043599; Mon, 7 Sep 2015 13:02:26 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t87D2QAg043598; Mon, 7 Sep 2015 13:02:26 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201509071302.t87D2QAg043598@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 7 Sep 2015 13:02:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r287533 - projects/ifnet/sys/net X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:02:26 -0000 Author: glebius Date: Mon Sep 7 13:02:25 2015 New Revision: 287533 URL: https://svnweb.freebsd.org/changeset/base/287533 Log: Sort if.h to reduce ifdef mess: - POSIX declarations go first, then go BSD_VISIBLE ones: userland ones first, kernel ones the last. - Move IFCOUNTER enum into userland part, we plan to provide API to query particular counters. - Use C11 anonymous unions in if_data, to remove ifdefs. Sponsored by: Nginx, Inc. Modified: projects/ifnet/sys/net/if.h Modified: projects/ifnet/sys/net/if.h ============================================================================== --- projects/ifnet/sys/net/if.h Mon Sep 7 10:13:14 2015 (r287532) +++ projects/ifnet/sys/net/if.h Mon Sep 7 13:02:25 2015 (r287533) @@ -35,6 +35,24 @@ #include +/* + * Length of interface external name, including terminating '\0'. + * Note: this is the same size as a generic device's external name. + */ +#define IF_NAMESIZE 16 + +struct if_nameindex { + unsigned int if_index; /* 1, 2, ... */ + char *if_name; /* null terminated name: "le0", ... */ +}; + +__BEGIN_DECLS +void if_freenameindex(struct if_nameindex *); +char *if_indextoname(unsigned int, char *); +struct if_nameindex *if_nameindex(void); +unsigned int if_nametoindex(const char *); +__END_DECLS + #if __BSD_VISIBLE /* * does not depend on on most other systems. This @@ -45,23 +63,13 @@ #include #include #endif -#endif -/* - * Length of interface external name, including terminating '\0'. - * Note: this is the same size as a generic device's external name. - */ -#define IF_NAMESIZE 16 -#if __BSD_VISIBLE #define IFNAMSIZ IF_NAMESIZE #define IF_MAXUNIT 0x7fff /* historical value */ -#endif -#if __BSD_VISIBLE /* * Structure used to query names of interface cloners. */ - struct if_clonereq { int ifcr_total; /* total cloners (out) */ int ifcr_count; /* room for this many in user buffer */ @@ -101,21 +109,19 @@ struct if_data { /* Unions are here to make sizes MI. */ union { /* uptime at attach or stat reset */ - time_t tt; + time_t ifi_epoch; uint64_t ph; - } __ifi_epoch; -#define ifi_epoch __ifi_epoch.tt + }; union { /* time of last administrative change */ - struct timeval tv; + struct timeval ifi_lastchange; struct { uint64_t ph1; uint64_t ph2; - } ph; - } __ifi_lastchange; -#define ifi_lastchange __ifi_lastchange.tv + }; + }; }; -/*- +/* * Interface flags are of two types: network stack owned flags, and driver * owned flags. Historically, these values were stored in the same ifnet * flags field, but with the advent of fine-grained locking, they have been @@ -521,21 +527,21 @@ struct ifi2creq { uint8_t data[8]; /* read buffer */ }; -#endif /* __BSD_VISIBLE */ - -#ifndef _KERNEL -struct if_nameindex { - unsigned int if_index; /* 1, 2, ... */ - char *if_name; /* null terminated name: "le0", ... */ -}; - -__BEGIN_DECLS -void if_freenameindex(struct if_nameindex *); -char *if_indextoname(unsigned int, char *); -struct if_nameindex *if_nameindex(void); -unsigned int if_nametoindex(const char *); -__END_DECLS -#endif +typedef enum { + IFCOUNTER_IPACKETS = 0, + IFCOUNTER_IERRORS, + IFCOUNTER_OPACKETS, + IFCOUNTER_OERRORS, + IFCOUNTER_COLLISIONS, + IFCOUNTER_IBYTES, + IFCOUNTER_OBYTES, + IFCOUNTER_IMCASTS, + IFCOUNTER_OMCASTS, + IFCOUNTER_IQDROPS, + IFCOUNTER_OQDROPS, + IFCOUNTER_NOPROTO, + IFCOUNTERS /* Array size (used internally). */ +} ift_counter; #ifdef _KERNEL #include @@ -557,22 +563,6 @@ MALLOC_DECLARE(M_IFMADDR); #endif typedef enum { - IFCOUNTER_IPACKETS = 0, - IFCOUNTER_IERRORS, - IFCOUNTER_OPACKETS, - IFCOUNTER_OERRORS, - IFCOUNTER_COLLISIONS, - IFCOUNTER_IBYTES, - IFCOUNTER_OBYTES, - IFCOUNTER_IMCASTS, - IFCOUNTER_OMCASTS, - IFCOUNTER_IQDROPS, - IFCOUNTER_OQDROPS, - IFCOUNTER_NOPROTO, - IFCOUNTERS /* Array size (used internally). */ -} ift_counter; - -typedef enum { IF_NO_SOFTC = 0, IF_DRIVER_SOFTC, IF_LLADDR, @@ -799,4 +789,5 @@ if_name(if_t ifp) return ((char *)(if_getsoftc(ifp, IF_NAME))); } #endif /* _KERNEL */ +#endif /* __BSD_VISIBLE_ */ #endif /* !_NET_IF_H_ */