Hide 'struct ifaddr' definition from userland. Two tools left that use it,

namely ipftest(1) and ifmcstat(1). These sniff structure definition using
_WANT_IFADDR define.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
This commit is contained in:
Gleb Smirnoff 2013-10-15 10:19:24 +00:00
parent 3fa98cf9ac
commit 6ed910fabe
6 changed files with 14 additions and 4 deletions

View File

@ -42,9 +42,10 @@ struct file;
#include <sys/time.h>
#include <sys/socket.h>
#include <net/if.h>
#if __FreeBSD_version >= 300000
# include <net/if_var.h>
#endif
#define _WANT_IFADDR
#include <net/if_var.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>

View File

@ -788,6 +788,7 @@ drbr_inuse(struct ifnet *ifp, struct buf_ring *br)
* chunk of malloc'ed memory, where we store the three addresses
* (ifa_addr, ifa_dstaddr and ifa_netmask) referenced here.
*/
#if defined(_KERNEL) || defined(_WANT_IFADDR)
struct ifaddr {
struct sockaddr *ifa_addr; /* address of interface */
struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */
@ -806,6 +807,8 @@ struct ifaddr {
(struct ifaddr *, struct sockaddr *);
struct mtx ifa_mtx;
};
#endif
#define IFA_ROUTE RTF_UP /* route installed */
#define IFA_RTSELF RTF_HOST /* loopback route to self installed */

View File

@ -50,6 +50,7 @@ struct in_ifinfo {
struct in_multi *ii_allhosts; /* 224.0.0.1 membership */
};
#if defined(_KERNEL) || defined(_WANT_IFADDR)
/*
* Interface address, Internet version. One of these structures
* is allocated for each Internet address on an interface.
@ -70,6 +71,7 @@ struct in_ifaddr {
#define ia_broadaddr ia_dstaddr
struct sockaddr_in ia_sockmask; /* reserve space for general netmask */
};
#endif
struct in_aliasreq {
char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */

View File

@ -110,6 +110,7 @@ struct in6_ifextra {
#define LLTABLE6(ifp) (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable)
#if defined(_KERNEL) || defined(_WANT_IFADDR)
struct in6_ifaddr {
struct ifaddr ia_ifa; /* protocol-independent info */
#define ia_ifp ia_ifa.ifa_ifp
@ -140,6 +141,7 @@ struct in6_ifaddr {
/* List of in6_ifaddr's. */
TAILQ_HEAD(in6_ifaddrhead, in6_ifaddr);
LIST_HEAD(in6_ifaddrlisthead, in6_ifaddr);
#endif
/* control structure to manage address selection policy */
struct in6_addrpolicy {

View File

@ -70,7 +70,7 @@
* The ifaddr structure contains the protocol-independent part
* of the structure and is assumed to be first.
*/
#ifdef _KERNEL
struct ipx_ifaddr {
struct ifaddr ia_ifa; /* protocol-independent info */
#define ia_ifp ia_ifa.ifa_ifp
@ -81,6 +81,7 @@ struct ipx_ifaddr {
#define ia_broadaddr ia_dstaddr
struct sockaddr_ipx ia_netmask; /* space for my network mask */
};
#endif /* _KERNEL */
struct ipx_aliasreq {
char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */

View File

@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/tree.h>
#include <net/if.h>
#define _WANT_IFADDR
#include <net/if_var.h>
#include <net/if_types.h>
#include <net/if_dl.h>