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