/*
*/
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef _NET_IF_H
#define _NET_IF_H
/* if.h 1.26 90/05/29 SMI; from UCB 7.1 6/4/86 */
#include <sys/feature_tests.h>
#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
#if defined(_LP64)
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Structures defining a network interface, providing a packet
* transport mechanism (ala level 0 of the PUP protocols).
*
* Each interface accepts output datagrams of a specified maximum
* length, and provides higher level routines with input datagrams
* received from its medium.
*
* Output occurs when the routine if_output is called, with three parameters:
* (*ifp->if_output)(ifp, m, dst)
* Here m is the mbuf chain to be sent and dst is the destination address.
* The output routine encapsulates the supplied datagram if necessary,
* and then transmits it on its medium.
*
* On input, each interface unwraps the data received by it, and either
* places it on the input queue of a internetwork datagram routine
* and posts the associated software interrupt, or passes the datagram to a raw
* packet input routine.
*
* Routines exist for locating interfaces by their addresses
* or for locating a interface on a certain network, as well as more general
* routing and gateway routines maintaining information used to locate
*/
#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
/*
* Structure defining a queue for a network interface.
*
* (Would like to call this struct ``if'', but C isn't PL/1.)
*/
struct ifnet {
struct ifqueue {
int ifq_len;
int ifq_maxlen;
int ifq_drops;
/* procedure handles */
/* generic interface statistics */
/* end statistics */
};
/*
* NOTE : These flags are not directly used within IP.
* ip_if.h has definitions derived from this which is used within IP.
* If you define a flag here, you need to define one in ip_if.h before
* using the new flag in IP. Don't use these flags directly in IP.
*/
/*
* The IFF_MULTICAST flag indicates that the network can support the
* transmission and reception of higher-level (e.g., IP) multicast packets.
* It is independent of hardware support for multicasting; for example,
* point-to-point links or pure broadcast networks may well support
* higher-level multicasts.
*/
/*
* The following flags can't be grabbed or altered by SIOC[GS]IFFLAGS.
* Should use SIOC[GS]LIFFLAGS which has a larger flags field.
*/
/*
* The IFF_XRESOLV flag is an evolving interface and is subject
* to change without notice.
*/
/* flags that cannot be changed by userland on any interface */
#define IFF_CANTCHANGE \
/* flags that cannot be changed by userland on an IPMP interface */
/* flags that can never be set on an IPMP interface */
/*
* Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
* input routines have queues of messages stored on ifqueue structures
* (defined above). Entries are added to and deleted from these structures
* by these macros, which should be called with ipl raised to splimp().
*/
(m)->m_act = 0; \
else \
}
}
/*
* Packets destined for level-1 protocol input routines
* have a pointer to the receiving interface prepended to the data.
* IF_DEQUEUEIF extracts and returns this pointer when dequeuing the packet.
* IF_ADJ should be used otherwise to adjust for its presence.
*/
#define IF_ADJ(m) { \
if ((m)->m_len == 0) { \
struct mbuf *n; \
MFREE((m), n); \
(m) = n; \
} \
}
if (m) { \
(m)->m_act = 0; \
IF_ADJ(m); \
} \
}
if (m) { \
(m)->m_act = 0; \
} \
}
/*
* The ifaddr structure contains information about one address
* of an interface. They are maintained by the different address families,
* are allocated and attached when an address is set, and are linked
* together so all addresses for an interface can be located.
*/
struct ifaddr {
union {
} ifa_ifu;
};
/*
* For SIOCLIF*ND ioctls.
*
* The lnr_state_* fields use the ND_* neighbor reachability states.
* The 3 different fields are for use with SIOCLIFSETND to cover the cases
* when
* A new entry is created
* The entry already exists and the link-layer address is the same
* The entry already exists and the link-layer address differs
*
* Use ND_UNCHANGED to not change any state.
*/
typedef struct lif_nd_req {
int lnr_hdw_len;
/* padding because ia32 "long long"s are only 4-byte aligned. */
int lnr_pad0;
} lif_nd_req_t;
/*
* Neighbor reachability states
* Used with SIOCLIF*ND ioctls.
*/
#define ND_STATE_VALID_MIN 0
/*
* lnr_flags value of lif_nd_req.
* Used with SIOCLIF*ND ioctls.
*/
/*
* the NDF_STATIC entry ensures that an NCE will not be deleted, and is
* used by non-ON applications like IPv6 test suites.
*/
/* For SIOC[GS]LIFLNKINFO */
typedef struct lif_ifinfo_req {
#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
/*
* Maximum lengths of interface name and IPMP group name; these are the same
* for historical reasons. Note that the actual maximum length of a name is
* one byte less than these constants since the kernel always sets the final
* byte of lifr_name and lifr_groupname to NUL.
*/
#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
/*
* Interface request structure used for socket
* ioctl's. All interface ioctl's must have parameter
* definitions which begin with ifr_name. The
* remainder may be interface specific.
* Note: This data structure uses 64bit type uint64_t which is not
* Applications with ioctls using this structure that insist on
*/
#if defined(_INT64_TYPE)
struct lifreq {
union {
} lifr_lifru1;
union {
int lifru_metric;
} lifr_lifru;
};
#endif /* defined(_INT64_TYPE) */
/*
* Argument structure for SIOCT* address testing ioctls.
*/
struct sioc_addrreq {
int sa_pad;
};
/*
* Argument structure used by mrouted to get src-grp pkt counts using
* SIOCGETLSGCNT. See <netinet/ip_mroute.h>.
*/
struct sioc_lsg_req {
};
/* Argument structure for SIOCGLIFDADSTATE ioctl */
typedef enum {
/*
* OBSOLETE: Replaced by struct lifreq. Supported for compatibility.
*
* Interface request structure used for socket
* ioctl's. All interface ioctl's must have parameter
* definitions which begin with ifr_name. The
* remainder may be interface specific.
*/
struct ifreq {
union {
short ifru_flags;
int ifru_metric;
struct ifr_ppaflags {
short ifrup_filler;
/* Struct for FDDI ioctl's */
struct ifr_dnld_reqs {
/* Struct for FDDI stats */
struct ifr_fddi_stats {
struct ifr_netmapents {
/* Field for generic ioctl for fddi */
struct ifr_fddi_gen_struct {
} ifr_ifru;
/* For setting ppa */
/* FDDI specific */
};
/* Used by SIOCGLIFNUM. Uses same flags as in struct lifconf */
struct lifnum {
};
/*
* Structure used in SIOCGLIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible) for a given address family.
* Using AF_UNSPEC will retrieve all address families.
*/
struct lifconf {
union {
} lifc_lifcu;
};
/*
* Structure used in SIOCGLIFSRCOF to get the interface
* configuration list for those interfaces that use an address
* hosted on the interface (set in lifs_ifindex), as the source
* address.
*/
struct lifsrcof {
union {
} lifs_lifsu;
};
/* Flags */
/* be used to communicate outside the */
/* node (exclude interfaces which are */
/* IFF_NOXMIT, IFF_NOLOCAL, */
/* IFF_LOOPBACK, IFF_DEPRECATED, or */
/* not IFF_UP). Has priority over */
/* LIFC_NOXMIT. */
/* (must be issued from global zone) */
#if defined(_SYSCALL32)
struct lifconf32 {
union {
} lifc_lifcu;
};
struct lifsrcof32 {
union {
} lifs_lifsu;
};
#endif /* _SYSCALL32 */
/*
* IPMP group information, for use with SIOCGLIFGROUPINFO.
*/
typedef struct lifgroupinfo {
/*
* OBSOLETE: Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct ifconf {
union {
} ifc_ifcu;
};
#if defined(_SYSCALL32)
struct ifconf32 {
union {
} ifc_ifcu;
};
#endif /* _SYSCALL32 */
typedef struct if_data {
/* generic interface information */
/* volatile statistics */
#if defined(_LP64)
#else
#endif
} if_data_t;
/*
* Message format for use in obtaining information about interfaces
* from the routing socket
*/
typedef struct if_msghdr {
} if_msghdr_t;
/*
* Message format for use in obtaining information about interface addresses
* from the routing socket
*/
typedef struct ifa_msghdr {
} ifa_msghdr_t;
#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
/*
* The if_nameindex structure holds the interface index value about
* a single interface. An array of this structure is used to return
* all interfaces and indexes.
*/
struct if_nameindex {
};
/* Interface index identification API definitions */
extern unsigned if_nametoindex(const char *);
extern char *if_indextoname(unsigned, char *);
extern struct if_nameindex *if_nameindex(void);
extern void if_freenameindex(struct if_nameindex *);
/*
* If changing IF_MAX_INDEX to a value greater than UINT16_MAX, check if
* struct sockaddr_dl needs to be modified as the interface index is placed
* in this structure by the kernel.
*/
#ifdef __cplusplus
}
#endif
#endif /* _NET_IF_H */