home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / net / if.h < prev    next >
Text File  |  1999-05-11  |  12KB  |  313 lines

  1. /*
  2.  * Copyright (c) 1982, 1986, 1989, 1993
  3.  *      The Regents of the University of California.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *      This product includes software developed by the University of
  16.  *      California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *      @(#)if.h        8.3 (Berkeley) 2/9/95
  34.  */
  35.  
  36. #ifndef _NET_IF_H_
  37. #define _NET_IF_H_
  38.  
  39. #ifdef TCPV40HDRS
  40. #include <stack16\net\if.h>
  41. #else
  42. #ifndef _TIME_ /*  XXX fast fix for SNMP, going away soon */
  43. #include <sys/time.h>
  44. #endif
  45.  
  46. /*
  47.  * Structure describing information about an interface
  48.  * which may be of interest to management entities.
  49.  */
  50.  
  51. #ifndef IFMIB_ENTRIES
  52. #define IFMIB_ENTRIES 42
  53. #endif
  54.  
  55. #pragma pack(1) /* force on doubleword boundary */
  56. struct iftable {
  57.     short  iftIndex;        /* index of this interface */
  58.     char   iftDescr[45];    /* description             */
  59.     short  iftType;         /* type of the interface   */
  60.     short  iftMtu;          /* MTU of the interface   */
  61.     char   iftPhysAddr[6];  /* MTU of the interface   */
  62.     short  iftOperStatus;
  63.     u_long iftSpeed;
  64.     u_long iftLastChange;
  65.     u_long iftInOctets;
  66.     u_long iftOutOctets;
  67.     u_long iftOutDiscards;
  68.     u_long iftInDiscards;
  69.     u_long iftInErrors;
  70.     u_long iftOutErrors;
  71.     u_long iftInUnknownProtos;
  72.     u_long iftInUcastPkts;
  73.     u_long iftOutUcastPkts;
  74.     u_long iftInNUcastPkts;
  75.     u_long iftOutNUcastPkts;
  76. };
  77. struct ifmib {
  78.     short ifNumber;
  79.     struct iftable iftable[IFMIB_ENTRIES];
  80. };
  81. #pragma pack()   /* reset to default packing */
  82. #define IFC_ALLRTSBCAST    0x0001
  83. #define IFC_802_3          0x0002
  84. #define IFC_FDDI           0x0004
  85. #define IFC_NOREDIR        0x0010
  86.  
  87. #define OPERSTATUS_UP      0x1
  88. #define OPERSTATUS_DOWN    0x2
  89. #define OPERSTATUS_TESTING 0x3
  90.  
  91. #define IFF_UP          0x1             /* interface is up */
  92. #define IFF_BROADCAST   0x2             /* broadcast address valid */
  93. #define IFF_DEBUG       0x4             /* turn on debugging */
  94. #define IFF_LOOPBACK    0x8             /* is a loopback net */
  95. #define IFF_POINTOPOINT 0x10            /* interface is point-to-point link */
  96. #define IFF_LINK2       0x20            /* was trailers, not used */
  97. #define IFF_NOTRAILERS  IFF_LINK2
  98. #define IFF_RUNNING     0x40            /* resources allocated */
  99. #define IFF_NOARP       0x80            /* no address resolution protocol */
  100. #define IFF_PROMISC     0x100           /* receive all packets */
  101. #define IFF_ALLMULTI    0x200           /* receive all multicast packets */
  102. #define IFF_BRIDGE      0x1000          /* support token ring routine field */
  103. #define IFF_SNAP        0x2000          /* support extended SAP header */
  104. #define IFF_DEFMTU      0x400           /* default mtu of 1500 */
  105. #define IFF_RFC1469_BC  1               /* using broadcast */
  106. #define IFF_RFC1469_FA  2               /* using functional */
  107. #define IFF_RFC1469_MA  3               /* using multicast */
  108. #define IFF_ETHER       0x4000          /* Ethernet interface */
  109. #define IFF_LOOPBRD     0x8000          /* loop back broadcasts */
  110. #define IFF_MULTICAST   0x800           /* supports multicast */
  111.  
  112. #define IFF_SIMPLEX     0x10000         /* can't hear own transmissions */
  113. #define IFF_OACTIVE     0x20000         /* transmission in progress */
  114. #define IFF_802_3       0x40000         /* */
  115. #define IFF_CANONICAL   0x80000         /* */
  116. #define IFF_RUNNINGBLK  0x100000        /* threads waited for intf running */
  117.  
  118. #define IFFE_PKTTRACE   0x00000001      /* trace datalink where possible */
  119. #define IFFE_IPTRACE    0x00000002      /* trace ONLY IP packets */
  120.  
  121. /* flags set internally only: */
  122. #define IFF_CANTCHANGE \
  123.         (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
  124.             IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
  125.  
  126. #pragma pack(1)
  127. struct pkt_trace_hdr {
  128.    u_short  pt_htype;  /* header type */
  129.    u_short  pt_len;    /* in: pt_buf len, out: packet len */
  130.    caddr_t  pt_data;   /* packet */
  131.    u_long   pt_tstamp; /* time stamp in milliseconds */
  132. };
  133. #pragma pack()
  134.  
  135. #define HT_IP           0x01  /* IP */
  136. #define HT_ETHER        0x06  /* Ethernet */
  137. #define HT_ISO88023     0x07  /* CSMA CD */
  138. #define HT_ISO88025     0x09  /* Token Ring */
  139. #define HT_SLIP         0x1c  /* Serial Line IP */
  140. #define HT_PPP          0x18  /* PPP IP */
  141.  
  142.  
  143. #pragma pack(1)
  144.         struct  if_data {
  145. /* generic interface information */
  146.                 u_char  ifi_type;       /* ethernet, tokenring, etc */
  147.                 u_char  ifi_addrlen;    /* media address length */
  148.                 u_char  ifi_hdrlen;     /* media header length */
  149.                 u_long  ifi_mtu;        /* maximum transmission unit */
  150.                 u_long  ifi_metric;     /* routing metric (external only) */
  151.                 u_long  ifi_baudrate;   /* linespeed */
  152.                                         /* volatile statistics */
  153.                 u_long  ifi_collisions; /* collisions on csma interfaces */
  154.                 u_long  ifi_ibytes;     /* total number of octets received */
  155.                 u_long  ifi_obytes;     /* total number of octets sent */
  156.                 u_long  ifi_oqdrops;    /* dropped on output, this interface */
  157.                 u_long  ifi_iqdrops;    /* dropped on input, this interface */
  158.                 u_long  ifi_ierrors;    /* input errors on interface */
  159.                 u_long  ifi_oerrors;    /* output errors on interface */
  160.                 u_long  ifi_noproto;    /* destined for unsupported protocol */
  161.                 u_long  ifi_ipackets;   /* packets received on interface */
  162.                 u_long  ifi_opackets;   /* packets sent on interface */
  163.                 u_long  ifi_imcasts;    /* packets received via multicast */
  164.                 u_long  ifi_omcasts;    /* packets sent via multicast */
  165.                 short   ifi_OperStatus; /* SNMP Oper Status */
  166.                 struct  timeval ifi_lastchange;/* last updated */
  167.                 u_char  ifi_descr[45];  /* description of the interface */
  168.         };
  169. #pragma pack()
  170.  
  171. /*
  172.  * Message format for use in obtaining information about interfaces
  173.  * from getkerninfo and the routing socket
  174.  */
  175. #pragma pack(1)
  176. struct if_msghdr {
  177.         u_short ifm_msglen;     /* to skip over non-understood messages */
  178.         u_char  ifm_version;    /* future binary compatability */
  179.         u_char  ifm_type;       /* message type */
  180.         int     ifm_addrs;      /* like rtm_addrs */
  181.         int     ifm_flags;      /* value of if_flags */
  182.         u_short ifm_index;      /* index for associated ifp */
  183.         struct  if_data ifm_data;/* statistics and other data about if */
  184. };
  185. #pragma pack()
  186.  
  187. /*
  188.  * Message format for use in obtaining information about interface addresses
  189.  * from getkerninfo and the routing socket
  190.  */
  191. #pragma pack(1)
  192. struct ifa_msghdr {
  193.         u_short ifam_msglen;    /* to skip over non-understood messages */
  194.         u_char  ifam_version;   /* future binary compatability */
  195.         u_char  ifam_type;      /* message type */
  196.         int     ifam_addrs;     /* like rtm_addrs */
  197.         int     ifam_flags;     /* value of ifa_flags */
  198.         u_short ifam_index;     /* index for associated ifp */
  199.         int     ifam_metric;    /* value of ifa_metric */
  200. };
  201. #pragma pack()
  202.  
  203. /*
  204.  * Interface request structure used for socket
  205.  * ioctl's.  All interface ioctl's must have parameter
  206.  * definitions which begin with ifr_name.  The
  207.  * remainder may be interface specific.
  208.  */
  209. #pragma pack(1)
  210. struct  ifreq {
  211. #define IFNAMSIZ        16
  212.         char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
  213.         union {
  214.                 struct  sockaddr ifru_addr;
  215.                 struct  sockaddr ifru_dstaddr;
  216.                 struct  sockaddr ifru_broadaddr;
  217.                 long    ifru_flags;
  218.                 long_int ifru_metric;
  219.                 caddr_t ifru_data;
  220.         } ifr_ifru;
  221. #define ifr_addr        ifr_ifru.ifru_addr      /* address */
  222. #define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
  223. #define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
  224. #define ifr_flags       ifr_ifru.ifru_flags     /* flags */
  225. #define ifr_metric      ifr_ifru.ifru_metric    /* metric */
  226. #define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
  227. #define ifr_eflags      ifr_ifru.ifru_data      /* extended flags */
  228. };
  229. #pragma pack()
  230.  
  231. #pragma pack(1)
  232. struct ifaliasreq {
  233.         char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
  234.         struct  sockaddr ifra_addr;
  235.         struct  sockaddr ifra_broadaddr;
  236.         struct  sockaddr ifra_mask;
  237. };
  238.  
  239. #pragma pack()
  240.  
  241. /*
  242.  * Structure used in SIOCGIFCONF request.
  243.  * Used to retrieve interface configuration
  244.  * for machine (useful for programs which
  245.  * must know all networks accessible).
  246.  */
  247. #pragma pack(1)
  248. struct  ifconf {
  249.         long_int ifc_len;               /* size of associated buffer */
  250.         union {
  251.                 caddr_t ifcu_buf;
  252.                 struct  ifreq  *ifcu_req;
  253.         } ifc_ifcu;
  254. #define ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
  255. #define ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
  256. };
  257. #pragma pack()
  258.  
  259.  
  260. #ifdef KERNEL
  261. #include <private/if.h>
  262. #endif
  263.  
  264. #include <net/if_arp.h>
  265. #include <netinet/in.h>
  266.  
  267. #pragma pack(1)
  268. struct  in_aliasreq {
  269.         char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
  270.         struct  sockaddr_in ifra_addr;
  271.         struct  sockaddr_in ifra_broadaddr;
  272. #define ifra_dstaddr ifra_broadaddr
  273.         struct  sockaddr_in ifra_mask;
  274. };
  275. #pragma pack()
  276.  
  277. #pragma pack(1)
  278. struct  addrreq  {                              /* get multicast addresses */
  279.         char    ifr_name[IFNAMSIZ];
  280.         struct  sockaddr ifr_addrs;
  281.         u_long  maddr[MAX_IN_MULTI];
  282. };
  283. #pragma pack()
  284.  
  285. #pragma pack(1)
  286. struct  statatreq {
  287.         u_long addr;
  288.         short interface;
  289.         u_long mask;
  290.         u_long broadcast;
  291. };
  292. #pragma pack()
  293.  
  294. #endif /* TCPV40HDRS */
  295.  
  296. /* PPP statistics table. Moved here from previous ifstat.h */
  297. struct ifstat {
  298.     u_long iftLastChange;
  299.     u_long iftInOctets;
  300.     u_long iftOutOctets;
  301.     u_long iftOutDiscards;
  302.     u_long iftInDiscards;
  303.     u_long iftInErrors;
  304.     u_long iftOutErrors;
  305.     u_long iftInUnknownProtos;
  306.     u_long iftInUcastPkts;
  307.     u_long iftOutUcastPkts;
  308.     u_long iftInNUcastPkts;
  309.     u_long iftOutNUcastPkts;
  310. };
  311.  
  312. #endif /* _NET_IF_H_ */
  313.