Home | History | Annotate | Download | only in net
      1 /* Copyright (C) 1997, 2002 Free Software Foundation, Inc.
      2    This file is part of the GNU C Library.
      3 
      4    The GNU C Library is free software; you can redistribute it and/or
      5    modify it under the terms of the GNU Lesser General Public
      6    License as published by the Free Software Foundation; either
      7    version 2.1 of the License, or (at your option) any later version.
      8 
      9    The GNU C Library is distributed in the hope that it will be useful,
     10    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12    Lesser General Public License for more details.
     13 
     14    You should have received a copy of the GNU Lesser General Public
     15    License along with the GNU C Library; if not, write to the Free
     16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     17    02111-1307 USA.  */
     18 
     19 /* Based on the 4.4BSD and Linux version of this file.  */
     20 
     21 #ifndef _NET_ROUTE_H
     22 #define _NET_ROUTE_H	1
     23 
     24 #include <features.h>
     25 #include <sys/socket.h>
     26 #include <sys/types.h>
     27 #include <netinet/in.h>
     28 #include <bits/wordsize.h>
     29 
     30 
     31 /* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
     32 struct rtentry
     33   {
     34     unsigned long int rt_pad1;
     35     struct sockaddr rt_dst;		/* Target address.  */
     36     struct sockaddr rt_gateway;		/* Gateway addr (RTF_GATEWAY).  */
     37     struct sockaddr rt_genmask;		/* Target network mask (IP).  */
     38     unsigned short int rt_flags;
     39     short int rt_pad2;
     40     unsigned long int rt_pad3;
     41     unsigned char rt_tos;
     42     unsigned char rt_class;
     43 #if __WORDSIZE == 64
     44     short int rt_pad4[3];
     45 #else
     46     short int rt_pad4;
     47 #endif
     48     short int rt_metric;		/* +1 for binary compatibility!  */
     49     char *rt_dev;			/* Forcing the device at add.  */
     50     unsigned long int rt_mtu;		/* Per route MTU/Window.  */
     51     unsigned long int rt_window;	/* Window clamping.  */
     52     unsigned short int rt_irtt;		/* Initial RTT.  */
     53   };
     54 /* Compatibility hack.  */
     55 #define rt_mss	rt_mtu
     56 
     57 
     58 struct in6_rtmsg
     59   {
     60     struct in6_addr rtmsg_dst;
     61     struct in6_addr rtmsg_src;
     62     struct in6_addr rtmsg_gateway;
     63     u_int32_t rtmsg_type;
     64     u_int16_t rtmsg_dst_len;
     65     u_int16_t rtmsg_src_len;
     66     u_int32_t rtmsg_metric;
     67     unsigned long int rtmsg_info;
     68     u_int32_t rtmsg_flags;
     69     int rtmsg_ifindex;
     70   };
     71 
     72 
     73 #define	RTF_UP		0x0001		/* Route usable.  */
     74 #define	RTF_GATEWAY	0x0002		/* Destination is a gateway.  */
     75 
     76 #define	RTF_HOST	0x0004		/* Host entry (net otherwise).  */
     77 #define RTF_REINSTATE	0x0008		/* Reinstate route after timeout.  */
     78 #define	RTF_DYNAMIC	0x0010		/* Created dyn. (by redirect).  */
     79 #define	RTF_MODIFIED	0x0020		/* Modified dyn. (by redirect).  */
     80 #define RTF_MTU		0x0040		/* Specific MTU for this route.  */
     81 #define RTF_MSS		RTF_MTU		/* Compatibility.  */
     82 #define RTF_WINDOW	0x0080		/* Per route window clamping.  */
     83 #define RTF_IRTT	0x0100		/* Initial round trip time.  */
     84 #define RTF_REJECT	0x0200		/* Reject route.  */
     85 #define	RTF_STATIC	0x0400		/* Manually injected route.  */
     86 #define	RTF_XRESOLVE	0x0800		/* External resolver.  */
     87 #define RTF_NOFORWARD   0x1000		/* Forwarding inhibited.  */
     88 #define RTF_THROW	0x2000		/* Go to next class.  */
     89 #define RTF_NOPMTUDISC  0x4000		/* Do not send packets with DF.  */
     90 
     91 /* for IPv6 */
     92 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
     93 #define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
     94 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
     95 
     96 #define RTF_LINKRT	0x00100000	/* link specific - device match	*/
     97 #define RTF_NONEXTHOP	0x00200000	/* route with no nexthop	*/
     98 
     99 #define RTF_CACHE	0x01000000	/* cache entry			*/
    100 #define RTF_FLOW	0x02000000	/* flow significant route	*/
    101 #define RTF_POLICY	0x04000000	/* policy route			*/
    102 
    103 #define RTCF_VALVE	0x00200000
    104 #define RTCF_MASQ	0x00400000
    105 #define RTCF_NAT	0x00800000
    106 #define RTCF_DOREDIRECT 0x01000000
    107 #define RTCF_LOG	0x02000000
    108 #define RTCF_DIRECTSRC	0x04000000
    109 
    110 #define RTF_LOCAL	0x80000000
    111 #define RTF_INTERFACE	0x40000000
    112 #define RTF_MULTICAST	0x20000000
    113 #define RTF_BROADCAST	0x10000000
    114 #define RTF_NAT		0x08000000
    115 
    116 #define RTF_ADDRCLASSMASK	0xF8000000
    117 #define RT_ADDRCLASS(flags)	((__u_int32_t) flags >> 23)
    118 
    119 #define RT_TOS(tos)		((tos) & IPTOS_TOS_MASK)
    120 
    121 #define RT_LOCALADDR(flags)	((flags & RTF_ADDRCLASSMASK) \
    122 				 == (RTF_LOCAL|RTF_INTERFACE))
    123 
    124 #define RT_CLASS_UNSPEC		0
    125 #define RT_CLASS_DEFAULT	253
    126 
    127 #define RT_CLASS_MAIN		254
    128 #define RT_CLASS_LOCAL		255
    129 #define RT_CLASS_MAX		255
    130 
    131 
    132 #define RTMSG_ACK		NLMSG_ACK
    133 #define RTMSG_OVERRUN		NLMSG_OVERRUN
    134 
    135 #define RTMSG_NEWDEVICE		0x11
    136 #define RTMSG_DELDEVICE		0x12
    137 #define RTMSG_NEWROUTE		0x21
    138 #define RTMSG_DELROUTE		0x22
    139 #define RTMSG_NEWRULE		0x31
    140 #define RTMSG_DELRULE		0x32
    141 #define RTMSG_CONTROL		0x40
    142 
    143 #define RTMSG_AR_FAILED		0x51	/* Address Resolution failed.  */
    144 
    145 #endif /* net/route.h */
    146