if.h
001: 
002: 
003: 
004: 
005: 
006: 
007: 
008: 
009: 
010: 
011: 
012: 
013: 
014: 
015: 
016: 
017: 
018: 
019: 
020: #ifndef _NET_IF_H
021: #define _NET_IF_H       1
022: 
023: #include <features.h>
024: 
025: #ifdef __USE_MISC
026: # include <sys/types.h>
027: # include <sys/socket.h>
028: #endif
029: 
030: 
031: 
032: #define IF_NAMESIZE     16
033: 
034: struct if_nameindex
035:   {
036:     unsigned int if_index;      
037:     char *if_name;              
038:   };
039: 
040: 
041: #ifdef __USE_MISC
042: 
043: enum
044:   {
045:     IFF_UP = 0x1,               
046: # define IFF_UP IFF_UP
047:     IFF_BROADCAST = 0x2,        
048: # define IFF_BROADCAST  IFF_BROADCAST
049:     IFF_DEBUG = 0x4,            
050: # define IFF_DEBUG      IFF_DEBUG
051:     IFF_LOOPBACK = 0x8,         
052: # define IFF_LOOPBACK   IFF_LOOPBACK
053:     IFF_POINTOPOINT = 0x10,     
054: # define IFF_POINTOPOINT IFF_POINTOPOINT
055:     IFF_NOTRAILERS = 0x20,      
056: # define IFF_NOTRAILERS IFF_NOTRAILERS
057:     IFF_RUNNING = 0x40,         
058: # define IFF_RUNNING    IFF_RUNNING
059:     IFF_NOARP = 0x80,           
060: # define IFF_NOARP      IFF_NOARP
061:     IFF_PROMISC = 0x100,        
062: # define IFF_PROMISC    IFF_PROMISC
063: 
064:     
065:     IFF_ALLMULTI = 0x200,       
066: # define IFF_ALLMULTI   IFF_ALLMULTI
067: 
068:     IFF_MASTER = 0x400,         
069: # define IFF_MASTER     IFF_MASTER
070:     IFF_SLAVE = 0x800,          
071: # define IFF_SLAVE      IFF_SLAVE
072: 
073:     IFF_MULTICAST = 0x1000,     
074: # define IFF_MULTICAST  IFF_MULTICAST
075: 
076:     IFF_PORTSEL = 0x2000,       
077: # define IFF_PORTSEL    IFF_PORTSEL
078:     IFF_AUTOMEDIA = 0x4000,     
079: # define IFF_AUTOMEDIA  IFF_AUTOMEDIA
080:     IFF_DYNAMIC = 0x8000        
081: # define IFF_DYNAMIC    IFF_DYNAMIC
082:   };
083: 
084: 
085: 
086: 
087: 
088: 
089: struct ifaddr
090:   {
091:     struct sockaddr ifa_addr;   
092:     union
093:       {
094:         struct sockaddr ifu_broadaddr;
095:         struct sockaddr ifu_dstaddr;
096:       } ifa_ifu;
097:     struct iface *ifa_ifp;      
098:     struct ifaddr *ifa_next;    
099:   };
100: 
101: # define ifa_broadaddr  ifa_ifu.ifu_broadaddr   
102: # define ifa_dstaddr    ifa_ifu.ifu_dstaddr     
103: 
104: 
105: 
106: 
107: 
108: 
109: 
110: 
111: 
112: struct ifmap
113:   {
114:     unsigned long int mem_start;
115:     unsigned long int mem_end;
116:     unsigned short int base_addr;
117:     unsigned char irq;
118:     unsigned char dma;
119:     unsigned char port;
120:     
121:   };
122: 
123: 
124: 
125: 
126: 
127: struct ifreq
128:   {
129: # define IFHWADDRLEN    6
130: # define IFNAMSIZ       IF_NAMESIZE
131:     union
132:       {
133:         char ifrn_name[IFNAMSIZ];       
134:       } ifr_ifrn;
135: 
136:     union
137:       {
138:         struct sockaddr ifru_addr;
139:         struct sockaddr ifru_dstaddr;
140:         struct sockaddr ifru_broadaddr;
141:         struct sockaddr ifru_netmask;
142:         struct sockaddr ifru_hwaddr;
143:         short int ifru_flags;
144:         int ifru_ivalue;
145:         int ifru_mtu;
146:         struct ifmap ifru_map;
147:         char ifru_slave[IFNAMSIZ];      
148:         char ifru_newname[IFNAMSIZ];
149:         __caddr_t ifru_data;
150:       } ifr_ifru;
151:   };
152: # define ifr_name       ifr_ifrn.ifrn_name      
153: # define ifr_hwaddr     ifr_ifru.ifru_hwaddr    
154: # define ifr_addr       ifr_ifru.ifru_addr      
155: # define ifr_dstaddr    ifr_ifru.ifru_dstaddr   
156: # define ifr_broadaddr  ifr_ifru.ifru_broadaddr 
157: # define ifr_netmask    ifr_ifru.ifru_netmask   
158: # define ifr_flags      ifr_ifru.ifru_flags     
159: # define ifr_metric     ifr_ifru.ifru_ivalue    
160: # define ifr_mtu        ifr_ifru.ifru_mtu       
161: # define ifr_map        ifr_ifru.ifru_map       
162: # define ifr_slave      ifr_ifru.ifru_slave     
163: # define ifr_data       ifr_ifru.ifru_data      
164: # define ifr_ifindex    ifr_ifru.ifru_ivalue    
165: # define ifr_bandwidth  ifr_ifru.ifru_ivalue    
166: # define ifr_qlen       ifr_ifru.ifru_ivalue    
167: # define ifr_newname    ifr_ifru.ifru_newname   
168: # define _IOT_ifreq     _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
169: # define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
170: # define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
171: 
172: 
173: 
174: 
175: 
176: 
177: struct ifconf
178:   {
179:     int ifc_len;                        
180:     union
181:       {
182:         __caddr_t ifcu_buf;
183:         struct ifreq *ifcu_req;
184:       } ifc_ifcu;
185:   };
186: # define ifc_buf        ifc_ifcu.ifcu_buf       
187: # define ifc_req        ifc_ifcu.ifcu_req       
188: # define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0) 
189: #endif  
190: 
191: __BEGIN_DECLS
192: 
193: 
194: extern unsigned int if_nametoindex (__const char *__ifname) __THROW;
195: extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
196: 
197: 
198: extern struct if_nameindex *if_nameindex (void) __THROW;
199: 
200: 
201: extern void if_freenameindex (struct if_nameindex *__ptr) __THROW;
202: 
203: __END_DECLS
204: 
205: #endif 
206: 
      
      
      
      
   
      
      
         
            
            © Andrew Scott 2006 -
            2025, 
            All Rights Reserved