Back to index

glibc  2.9
route.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997, 2002 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /* Based on the 4.4BSD and Linux version of this file.  */
00020 
00021 #ifndef _NET_ROUTE_H
00022 #define _NET_ROUTE_H 1
00023 
00024 #include <features.h>
00025 #include <sys/socket.h>
00026 #include <sys/types.h>
00027 #include <netinet/in.h>
00028 #include <bits/wordsize.h>
00029 
00030 
00031 /* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
00032 struct rtentry
00033   {
00034     unsigned long int rt_pad1;
00035     struct sockaddr rt_dst;        /* Target address.  */
00036     struct sockaddr rt_gateway;           /* Gateway addr (RTF_GATEWAY).  */
00037     struct sockaddr rt_genmask;           /* Target network mask (IP).  */
00038     unsigned short int rt_flags;
00039     short int rt_pad2;
00040     unsigned long int rt_pad3;
00041     unsigned char rt_tos;
00042     unsigned char rt_class;
00043 #if __WORDSIZE == 64
00044     short int rt_pad4[3];
00045 #else
00046     short int rt_pad4;
00047 #endif
00048     short int rt_metric;           /* +1 for binary compatibility!  */
00049     char *rt_dev;                  /* Forcing the device at add.  */
00050     unsigned long int rt_mtu;             /* Per route MTU/Window.  */
00051     unsigned long int rt_window;   /* Window clamping.  */
00052     unsigned short int rt_irtt;           /* Initial RTT.  */
00053   };
00054 /* Compatibility hack.  */
00055 #define rt_mss       rt_mtu
00056 
00057 
00058 struct in6_rtmsg
00059   {
00060     struct in6_addr rtmsg_dst;
00061     struct in6_addr rtmsg_src;
00062     struct in6_addr rtmsg_gateway;
00063     u_int32_t rtmsg_type;
00064     u_int16_t rtmsg_dst_len;
00065     u_int16_t rtmsg_src_len;
00066     u_int32_t rtmsg_metric;
00067     unsigned long int rtmsg_info;
00068     u_int32_t rtmsg_flags;
00069     int rtmsg_ifindex;
00070   };
00071 
00072 
00073 #define       RTF_UP        0x0001        /* Route usable.  */
00074 #define       RTF_GATEWAY   0x0002        /* Destination is a gateway.  */
00075 
00076 #define       RTF_HOST      0x0004        /* Host entry (net otherwise).  */
00077 #define RTF_REINSTATE       0x0008        /* Reinstate route after timeout.  */
00078 #define       RTF_DYNAMIC   0x0010        /* Created dyn. (by redirect).  */
00079 #define       RTF_MODIFIED  0x0020        /* Modified dyn. (by redirect).  */
00080 #define RTF_MTU             0x0040        /* Specific MTU for this route.  */
00081 #define RTF_MSS             RTF_MTU              /* Compatibility.  */
00082 #define RTF_WINDOW   0x0080        /* Per route window clamping.  */
00083 #define RTF_IRTT     0x0100        /* Initial round trip time.  */
00084 #define RTF_REJECT   0x0200        /* Reject route.  */
00085 #define       RTF_STATIC    0x0400        /* Manually injected route.  */
00086 #define       RTF_XRESOLVE  0x0800        /* External resolver.  */
00087 #define RTF_NOFORWARD   0x1000            /* Forwarding inhibited.  */
00088 #define RTF_THROW    0x2000        /* Go to next class.  */
00089 #define RTF_NOPMTUDISC  0x4000            /* Do not send packets with DF.  */
00090 
00091 /* for IPv6 */
00092 #define RTF_DEFAULT  0x00010000    /* default - learned via ND */
00093 #define RTF_ALLONLINK       0x00020000    /* fallback, no routers on link    */
00094 #define RTF_ADDRCONF 0x00040000    /* addrconf route - RA             */
00095 
00096 #define RTF_LINKRT   0x00100000    /* link specific - device match    */
00097 #define RTF_NONEXTHOP       0x00200000    /* route with no nexthop    */
00098 
00099 #define RTF_CACHE    0x01000000    /* cache entry                     */
00100 #define RTF_FLOW     0x02000000    /* flow significant route   */
00101 #define RTF_POLICY   0x04000000    /* policy route                    */
00102 
00103 #define RTCF_VALVE   0x00200000
00104 #define RTCF_MASQ    0x00400000
00105 #define RTCF_NAT     0x00800000
00106 #define RTCF_DOREDIRECT 0x01000000
00107 #define RTCF_LOG     0x02000000
00108 #define RTCF_DIRECTSRC      0x04000000
00109 
00110 #define RTF_LOCAL    0x80000000
00111 #define RTF_INTERFACE       0x40000000
00112 #define RTF_MULTICAST       0x20000000
00113 #define RTF_BROADCAST       0x10000000
00114 #define RTF_NAT             0x08000000
00115 
00116 #define RTF_ADDRCLASSMASK   0xF8000000
00117 #define RT_ADDRCLASS(flags) ((__u_int32_t) flags >> 23)
00118 
00119 #define RT_TOS(tos)         ((tos) & IPTOS_TOS_MASK)
00120 
00121 #define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \
00122                              == (RTF_LOCAL|RTF_INTERFACE))
00123 
00124 #define RT_CLASS_UNSPEC            0
00125 #define RT_CLASS_DEFAULT    253
00126 
00127 #define RT_CLASS_MAIN              254
00128 #define RT_CLASS_LOCAL             255
00129 #define RT_CLASS_MAX        255
00130 
00131 
00132 #define RTMSG_ACK           NLMSG_ACK
00133 #define RTMSG_OVERRUN              NLMSG_OVERRUN
00134 
00135 #define RTMSG_NEWDEVICE            0x11
00136 #define RTMSG_DELDEVICE            0x12
00137 #define RTMSG_NEWROUTE             0x21
00138 #define RTMSG_DELROUTE             0x22
00139 #define RTMSG_NEWRULE              0x31
00140 #define RTMSG_DELRULE              0x32
00141 #define RTMSG_CONTROL              0x40
00142 
00143 #define RTMSG_AR_FAILED            0x51   /* Address Resolution failed.  */
00144 
00145 #endif /* net/route.h */