home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / net / h / if
Encoding:
Text File  |  2006-09-17  |  7.3 KB  |  222 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/net/if.h,v $
  4.  * $Date: 2003/11/18 23:35:57 $
  5.  * $Revision: 1.4 $
  6.  * $State: Exp $
  7.  * $Author: joty $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /*
  12.  * File taken from glibc 2.2.5.
  13.  * Following changes were made:
  14.  *  - Commented out the if_*() routines because these are not implemented.
  15.  */
  16.  
  17. /* net/if.h -- declarations for inquiring about network interfaces
  18.    Copyright (C) 1997,98,99,2000,2001 Free Software Foundation, Inc.
  19.    This file is part of the GNU C Library.
  20.  
  21.    The GNU C Library is free software; you can redistribute it and/or
  22.    modify it under the terms of the GNU Lesser General Public
  23.    License as published by the Free Software Foundation; either
  24.    version 2.1 of the License, or (at your option) any later version.
  25.  
  26.    The GNU C Library is distributed in the hope that it will be useful,
  27.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  28.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  29.    Lesser General Public License for more details.
  30.  
  31.    You should have received a copy of the GNU Lesser General Public
  32.    License along with the GNU C Library; if not, write to the Free
  33.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  34.    02111-1307 USA.  */
  35.  
  36. #ifndef _NET_IF_H
  37. #define _NET_IF_H    1
  38.  
  39. #include <features.h>
  40.  
  41. #ifdef __USE_MISC
  42. # include <sys/types.h>
  43. # include <sys/socket.h>
  44. #endif
  45.  
  46.  
  47. /* Length of interface name.  */
  48. #define IF_NAMESIZE    16
  49.  
  50. struct if_nameindex
  51.   {
  52.     unsigned int if_index;    /* 1, 2, ... */
  53.     char *if_name;        /* null terminated name: "eth0", ... */
  54.   };
  55.  
  56.  
  57. #ifdef __USE_MISC
  58. /* Standard interface flags. */
  59. enum
  60.   {
  61.     IFF_UP = 0x1,        /* Interface is up.  */
  62. # define IFF_UP    IFF_UP
  63.     IFF_BROADCAST = 0x2,    /* Broadcast address valid.  */
  64. # define IFF_BROADCAST    IFF_BROADCAST
  65.     IFF_DEBUG = 0x4,        /* Turn on debugging.  */
  66. # define IFF_DEBUG    IFF_DEBUG
  67.     IFF_LOOPBACK = 0x8,        /* Is a loopback net.  */
  68. # define IFF_LOOPBACK    IFF_LOOPBACK
  69.     IFF_POINTOPOINT = 0x10,    /* Interface is point-to-point link.  */
  70. # define IFF_POINTOPOINT IFF_POINTOPOINT
  71.     IFF_NOTRAILERS = 0x20,    /* Avoid use of trailers.  */
  72. # define IFF_NOTRAILERS    IFF_NOTRAILERS
  73.     IFF_RUNNING = 0x40,        /* Resources allocated.  */
  74. # define IFF_RUNNING    IFF_RUNNING
  75.     IFF_NOARP = 0x80,        /* No address resolution protocol.  */
  76. # define IFF_NOARP    IFF_NOARP
  77.     IFF_PROMISC = 0x100,    /* Receive all packets.  */
  78. # define IFF_PROMISC    IFF_PROMISC
  79.  
  80.     /* Not supported */
  81.     IFF_ALLMULTI = 0x200,    /* Receive all multicast packets.  */
  82. # define IFF_ALLMULTI    IFF_ALLMULTI
  83.  
  84.     IFF_MASTER = 0x400,        /* Master of a load balancer.  */
  85. # define IFF_MASTER    IFF_MASTER
  86.     IFF_SLAVE = 0x800,        /* Slave of a load balancer.  */
  87. # define IFF_SLAVE    IFF_SLAVE
  88.  
  89.     IFF_MULTICAST = 0x1000,    /* Supports multicast.  */
  90. # define IFF_MULTICAST    IFF_MULTICAST
  91.  
  92.     IFF_PORTSEL = 0x2000,    /* Can set media type.  */
  93. # define IFF_PORTSEL    IFF_PORTSEL
  94.     IFF_AUTOMEDIA = 0x4000    /* Auto media select active.  */
  95. # define IFF_AUTOMEDIA    IFF_AUTOMEDIA
  96.   };
  97.  
  98. /* The ifaddr structure contains information about one address of an
  99.    interface.  They are maintained by the different address families,
  100.    are allocated and attached when an address is set, and are linked
  101.    together so all addresses for an interface can be located.  */
  102.  
  103. struct ifaddr
  104.   {
  105.     struct sockaddr ifa_addr;    /* Address of interface.  */
  106.     union
  107.       {
  108.     struct sockaddr    ifu_broadaddr;
  109.     struct sockaddr    ifu_dstaddr;
  110.       } ifa_ifu;
  111.     struct iface *ifa_ifp;    /* Back-pointer to interface.  */
  112.     struct ifaddr *ifa_next;    /* Next address for interface.  */
  113.   };
  114.  
  115. # define ifa_broadaddr    ifa_ifu.ifu_broadaddr    /* broadcast address    */
  116. # define ifa_dstaddr    ifa_ifu.ifu_dstaddr    /* other end of link    */
  117.  
  118. /* Device mapping structure. I'd just gone off and designed a
  119.    beautiful scheme using only loadable modules with arguments for
  120.    driver options and along come the PCMCIA people 8)
  121.  
  122.    Ah well. The get() side of this is good for WDSETUP, and it'll be
  123.    handy for debugging things. The set side is fine for now and being
  124.    very small might be worth keeping for clean configuration.  */
  125.  
  126. struct ifmap
  127.   {
  128.     unsigned long int mem_start;
  129.     unsigned long int mem_end;
  130.     unsigned short int base_addr;
  131.     unsigned char irq;
  132.     unsigned char dma;
  133.     unsigned char port;
  134.     /* 3 bytes spare */
  135.   };
  136.  
  137. /* Interface request structure used for socket ioctl's.  All interface
  138.    ioctl's must have parameter definitions which begin with ifr_name.
  139.    The remainder may be interface specific.  */
  140.  
  141. struct ifreq
  142.   {
  143. # define IFHWADDRLEN    6
  144. # define IFNAMSIZ    IF_NAMESIZE
  145.     union
  146.       {
  147.     char ifrn_name[IFNAMSIZ];    /* Interface name, e.g. "en0".  */
  148.       } ifr_ifrn;
  149.  
  150.     union
  151.       {
  152.     struct sockaddr ifru_addr;
  153.     struct sockaddr ifru_dstaddr;
  154.     struct sockaddr ifru_broadaddr;
  155.     struct sockaddr ifru_netmask;
  156.     struct sockaddr ifru_hwaddr;
  157.     short int ifru_flags;
  158.     int ifru_ivalue;
  159.     int ifru_mtu;
  160.     struct ifmap ifru_map;
  161.     char ifru_slave[IFNAMSIZ];    /* Just fits the size */
  162.     char ifru_newname[IFNAMSIZ];
  163.     __caddr_t ifru_data;
  164.       } ifr_ifru;
  165.   };
  166. # define ifr_name    ifr_ifrn.ifrn_name    /* interface name     */
  167. # define ifr_hwaddr    ifr_ifru.ifru_hwaddr    /* MAC address         */
  168. # define ifr_addr    ifr_ifru.ifru_addr    /* address        */
  169. # define ifr_dstaddr    ifr_ifru.ifru_dstaddr    /* other end of p-p lnk    */
  170. # define ifr_broadaddr    ifr_ifru.ifru_broadaddr    /* broadcast address    */
  171. # define ifr_netmask    ifr_ifru.ifru_netmask    /* interface net mask    */
  172. # define ifr_flags    ifr_ifru.ifru_flags    /* flags        */
  173. # define ifr_metric    ifr_ifru.ifru_ivalue    /* metric        */
  174. # define ifr_mtu    ifr_ifru.ifru_mtu    /* mtu            */
  175. # define ifr_map    ifr_ifru.ifru_map    /* device map        */
  176. # define ifr_slave    ifr_ifru.ifru_slave    /* slave device        */
  177. # define ifr_data    ifr_ifru.ifru_data    /* for use by interface    */
  178. # define ifr_ifindex    ifr_ifru.ifru_ivalue    /* interface index      */
  179. # define ifr_bandwidth    ifr_ifru.ifru_ivalue    /* link bandwidth    */
  180. # define ifr_qlen    ifr_ifru.ifru_ivalue    /* queue length        */
  181. # define ifr_newname    ifr_ifru.ifru_newname    /* New name        */
  182. # define _IOT_ifreq    _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
  183. # define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
  184. # define _IOT_ifreq_int    _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
  185.  
  186.  
  187. /* Structure used in SIOCGIFCONF request.  Used to retrieve interface
  188.    configuration for machine (useful for programs which must know all
  189.    networks accessible).  */
  190.  
  191. struct ifconf
  192.   {
  193.     int    ifc_len;            /* Size of buffer.  */
  194.     union
  195.       {
  196.     __caddr_t ifcu_buf;
  197.     struct ifreq *ifcu_req;
  198.       } ifc_ifcu;
  199.   };
  200. # define ifc_buf    ifc_ifcu.ifcu_buf    /* Buffer address.  */
  201. # define ifc_req    ifc_ifcu.ifcu_req    /* Array of structures.  */
  202. # define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0) /* not right */
  203. #endif    /* Misc.  */
  204.  
  205. __BEGIN_DECLS
  206.  
  207. #if 0
  208. /* Convert an interface name to an index, and vice versa.  */
  209. extern unsigned int if_nametoindex (__const char *__ifname) __THROW;
  210. extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
  211.  
  212. /* Return a list of all interfaces and their indices.  */
  213. extern struct if_nameindex *if_nameindex (void) __THROW;
  214.  
  215. /* Free the data returned from if_nameindex.  */
  216. extern void if_freenameindex (struct if_nameindex *__ptr) __THROW;
  217. #endif
  218.  
  219. __END_DECLS
  220.  
  221. #endif /* net/if.h */
  222.