📄 if.h
字号:
/***************************************************************************
*
* Copyright (c) 1993 READY SYSTEMS CORPORATION.
*
* All rights reserved. READY SYSTEMS' source code is an unpublished
* work and the use of a copyright notice does not imply otherwise.
* This source code contains confidential, trade secret material of
* READY SYSTEMS. Any attempt or participation in deciphering, decoding,
* reverse engineering or in any way altering the source code is
* strictly prohibited, unless the prior written consent of
* READY SYSTEMS is obtained.
*
*
* Module Name: if.h
*
* Identification: @(#) 1.5 if.h
*
* Date: 1/12/94 09:45:07
*
****************************************************************************
*/
/*
RCS header identifier - $Id: if.h,v 1.4 1995/04/23 03:30:38 sriram Exp $
*/
/*
* Copyrighted as an unpublished work.
* (c) Copyright 1987-1993 Lachman Technology, Incorporated
* All rights reserved.
*
* RESTRICTED RIGHTS
*
* These programs are supplied under a license. They may be used,
* disclosed, and/or copied only as permitted under such license
* agreement. Any copy must contain the above copyright notice and
* this restricted rights notice. Use, copying, and/or disclosure
* of the programs is strictly prohibited unless otherwise provided
* in the license agreement.
*/
/*
* Copyright (c) 1985 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* **********************************************************************
*
* CHANGE HISTORY:
*
* ----------------------------------------------------------------------
* DATE CHANGES
* ----------------------------------------------------------------------
*
* 12/14/94 Included the Version 5 TCP compatible code for SNMP_V2.
* Check for #ifdef VER5_COMPAT.
*
* ********************************************************************* */
#ifdef SNX
#ifndef VER5_COMPAT
#define VER5_COMPAT /* This needs to be compiled, SNX */
#endif
#endif
#ifndef __STREAM_H
#include "sys/stream.h"
#endif
#ifndef if_h
#define if_h
#ifdef __cplusplus
extern "C" {
#endif
/* flags for interface status (should be common among protos */
#define IFF_UP 0x1 /* interface is up */
#define IFF_BROADCAST 0x2 /* broadcast address valid */
#define IFF_DEBUG 0x4 /* turn on debugging */
#define IFF_LOOPBACK 0x8 /* is a loopback net */
#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
#define IFF_RUNNING 0x40 /* resources allocated */
#define IFF_NOARP 0x80 /* no address resolution protocol */
/* next two not supported now, but reserved: */
#define IFF_PROMISC 0x100 /* receive all packets */
#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
/* Convergent intelligent board support code */
#define IFF_INTELLIGENT 0x400 /* protocol code on board */
#define IFF_ONEPACKET 0x800 /* one-packet mode */
/* flags set internally only: */
#define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
/* macros used to set, clear and verify interface flags */
/* macros to check if a particular flag is set or not */
#define UP_ISSET(flag) (flag & IFF_UP)
#define NOTRAIL_ISSET(flag) (flag & IFF_NOTRAILERS)
#define NOARP_ISSET(flag) (flag & IFF_NOARP)
#define DEBUG_ISSET(flag) (flag & IFF_DEBUG)
/* macros to set a particular flag */
#define UP_SET(flag) (*(flag) |= IFF_UP)
#define NOTRAIL_SET(flag) (*(flag) |= IFF_NOTRAILERS)
#define NOARP_SET(flag) (*(flag) |= IFF_NOARP)
#define DEBUG_SET(flag) (*(flag) |= IFF_DEBUG)
/* macros to clear a particular flag */
#define UP_CLEAR(flag) (*(flag) &= ~(IFF_UP))
#define NOTRAIL_CLEAR(flag) (*(flag) &= ~(IFF_NOTRAILERS))
#define NOARP_CLEAR(flag) (*(flag) &= ~(IFF_NOARP))
#define DEBUG_CLEAR(flag) (*(flag) &= ~(IFF_DEBUG))
/*
* Struct used for one-packet mode params in if ioctls
*/
struct onepacket {
int spsize; /* short packet size */
int spthresh; /* short packet threshold */
};
/*
* 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 {
#define IFNAMSIZ 16
char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
short ifru_flags;
int ifru_metric;
int ifru_muxid;
caddr_t ifru_data;
char ifru_enaddr[6];
struct onepacket ifru_onepacket;
} ifr_ifru;
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_muxid ifr_ifru.ifru_muxid /* muxid */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
#define ifr_enaddr ifr_ifru.ifru_enaddr /* ethernet address */
#define ifr_onepacket ifr_ifru.ifru_onepacket /* one-packet mode params */
};
/*
* Structure used in SIOCGIFCONF request. Used to retrieve interface
* configuration for machine (useful for programs which must know all
* networks accessible).
*/
struct ifconf {
int ifc_len;/* size of associated buffer */
union {
caddr_t ifcu_buf;
struct ifreq *ifcu_req;
} ifc_ifcu;
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
};
/*
* The ifstats structures are linked by each unit into a chain. Note that
* interfaces have to know their own name to play this game.
*/
struct ifstats {
struct ifstats *ifs_next; /* next if on chain */
char *ifs_name; /* interface name */
short ifs_unit; /* unit number */
short ifs_active; /* non-zero if this if is running */
struct ifaddr *ifs_addrs; /* list of addresses */
short ifs_mtu;/* Maximum transmission unit */
/* generic interface statistics */
u_long ifs_ipackets; /* packets received on interface */
u_long ifs_ierrors; /* input errors on interface */
u_long ifs_opackets; /* packets sent on interface */
u_long ifs_oerrors; /* output errors on interface */
u_long ifs_collisions; /* collisions on csma interfaces */
/* end statistics */
/* MIB-II */
struct ifs_mib {
int if_type;
# define IFOTHER 1
# define IFDDN_X25 4
# define IFRFC877_X25 5
# define IFETHERNET_CSMACD 6
# define IFISO88023_CSMACD 7
# define IFISO88025_TOKENRING 9
# define IFFDDI 15
# define IFPPP 23
# define IFLOOPBACK 24
# define IFSLIP 28
int if_speed;
struct ifs_ins {
unsigned long if_inoctets;
unsigned long if_inucastpkts;
unsigned long if_innucastpkts;
unsigned long if_indiscards;
unsigned long if_inunkprotos;
} ifs_ins;
struct ifs_outs {
unsigned long if_outoctets;
unsigned long if_outucastpkts;
unsigned long if_outnucastpkts;
unsigned long if_outdiscards;
} ifs_outs;
} ifs_mib;
# define iftype ifs_mib.if_type
# define ifspeed ifs_mib.if_speed
# define ifinoctets ifs_mib.ifs_ins.if_inoctets
# define ifinucastpkts ifs_mib.ifs_ins.if_inucastpkts
# define ifinnucastpkts ifs_mib.ifs_ins.if_innucastpkts
# define ifindiscards ifs_mib.ifs_ins.if_indiscards
# define ifinunkprotos ifs_mib.ifs_ins.if_inunkprotos
# define ifoutoctets ifs_mib.ifs_outs.if_outoctets
# define ifoutucastpkts ifs_mib.ifs_outs.if_outucastpkts
# define ifoutnucastpkts ifs_mib.ifs_outs.if_outnucastpkts
# define ifoutdiscards ifs_mib.ifs_outs.if_outdiscards
/* MIB-II */
};
/*
* 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 {
struct sockaddr ifa_addr; /* address of interface */
union {
struct sockaddr ifu_broadaddr;
struct sockaddr ifu_dstaddr;
} ifa_ifu;
#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */
#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */
struct ifnet *ifa_ifp; /* back-pointer to interface */
struct ifstats *ifa_ifs; /* back-pointer to interface stats */
struct ifaddr *ifa_next; /* next address for interface */
#ifdef VER5_COMPAT
u_short ifa_flags; /* mostly rt_flags for cloning */
#endif
};
#define SLIPDISC 3 /* serial line discipline for IP */
#ifdef __cplusplus
}
#endif
#ifdef VER5_COMPAT
#if !defined __P
#define __P(x) ()
#endif
/* Structures not defined or changed from Version 4 -> 5. */
/* These are actually Version 5 TCP structures. */
/* mgmt. ioctls and related structures */
#define IF_MAXADDRS 10
struct all_addrs {
struct sockaddr addr;
struct sockaddr dstaddr;
struct sockaddr netmask;
u_short flags;
u_long multi[IF_MAXADDRS]; /* XXX should be in_addr */
};
/*
* Interface specific tuning information that TCP can use to its
* advantage.
*/
struct ifperf {
u_short ip_recvspace; /* Receive window to use */
u_short ip_sendspace; /* Send window to use */
u_short ip_fullsize; /* use full-size frames */
};
/*
* The interface structure, formerly known as ip_provider.
*/
typedef struct ifnet {
char if_name[IFNAMSIZ]; /* provider name (e.g., en0) */
struct ifnet *if_next; /* next in the chain */
queue_t *if_qbot; /* lower write queue */
int if_lindex; /* unique ID of lower stream */
u_long if_flags; /* up/down, broadcast, etc. */
int if_metric; /* routing metric (external only) */
int if_maxtu; /* maximum transmission unit */
int if_mintu; /* minimum transmission unit */
struct ifaddr *if_addrlist; /* address chain maintained by if */
/*
* The following stuff is used for interfaces that can't handle
* back-to-back packets combined with systems that don't send
* packets as big as the MSS. These values are actually used
* by TCP, but are kept here since they are set by ifconfig.
*/
int if_spsize; /* short packet size to watch for */
int if_spthresh; /* short packet threshold */
/* should be a real timeval, but too many programs won't compile */
struct if_timeval {
u_long tv_sec;
u_long tv_usec;
} if_lastchange; /* time of status change for SNMP */
struct ifstats *if_ifs; /* pointer to ifstats structure */
/*
* ARP devices are cross-linked with IP via the SIOCSIFNAME ioctl.
* It is the responsibility of the ARP device to find the right
* ifnet and update if_arp and if_arpresolve.
*/
struct arp_pcb *if_arp; /* pointer to cross-linked arp dev */
/*
* if_arpresolve is called to resolve a MAC level address if
* necessary.
*/
int (*if_arpresolve) __P((struct ifnet *, mblk_t *, struct rtentry *));
int if_addrlen; /* address length for this medium */
int if_type; /* type of interface */
int (*if_ioctl) __P((struct ifnet *, u_long, caddr_t)); /* process ioctls */
u_short if_noq; /* queue on input or not */
u_long if_refcnt; /* reference count */
u_long if_index; /* SNMP index */
u_short if_dl_version; /* DLPI version */
u_short if_debuglevel; /* Debug level */
struct ifperf if_perf; /* Performance information */
} ifnet_t;
struct ifreq_all
{
#define if_number if_entry.if_index
ifnet_t if_entry; /* if_index = -1 => get # of interfaces */
/* = 0 => get interface from if_lindex */
/* = other => get req. interface data */
int if_statsavail; /* indicates if stats are avail. */
struct ifstats if_stats;
int if_outqlen; /* # of packets in the out queue */
int if_naddr; /* indicates # of addrs returned */
struct all_addrs addrs[IF_MAXADDRS];
};
#endif
#endif /* if_h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -