Bring RCNG in from 5.x and adjust config files and scripts accordingly.
[dragonfly.git] / etc / rc.d / routing
1 #!/bin/sh
2 #
3 # Configure routing and miscellaneous network tunables
4 #
5 # $FreeBSD: src/etc/rc.d/routing,v 1.138 2003/06/29 17:59:09 mtm Exp $
6 # $DragonFly: src/etc/rc.d/routing,v 1.1 2003/07/24 06:35:37 dillon Exp $
7 #
8
9 # PROVIDE: routing
10 # REQUIRE: netif ppp-user
11 # KEYWORD: DragonFly FreeBSD
12
13 . /etc/rc.subr
14
15 name="routing"
16 start_cmd="routing_start"
17 stop_cmd="routing_stop"
18 extra_commands="options static"
19 static_cmd="static_start"
20 options_cmd="options_start"
21
22 routing_start()
23 {
24         static_start
25         options_start
26 }
27
28 routing_stop()
29 {
30         route -n flush
31 }
32
33 static_start()
34 {
35         case ${defaultrouter} in
36         [Nn][Oo] | '')
37                 ;;
38         *)
39                 static_routes="default ${static_routes}"
40                 route_default="default ${defaultrouter}"
41                 ;;
42         esac
43
44         # Setup static routes. This should be done before router discovery.
45         #
46         if [ -n "${static_routes}" ]; then
47                 for i in ${static_routes}; do
48                         eval route_args=\$route_${i}
49                         route add ${route_args}
50                 done
51         fi
52 }
53
54 options_start()
55 {
56         echo -n 'Additional routing options:'
57         case ${tcp_extensions} in
58         [Yy][Ee][Ss] | '')
59                 ;;
60         *)
61                 echo -n ' tcp extensions=NO'
62                 sysctl net.inet.tcp.rfc1323=0 >/dev/null
63                 ;;
64         esac
65
66         case ${icmp_bmcastecho} in
67         [Yy][Ee][Ss])
68                 echo -n ' broadcast ping responses=YES'
69                 sysctl net.inet.icmp.bmcastecho=1 >/dev/null
70                 ;;
71         esac
72
73         case ${icmp_drop_redirect} in
74         [Yy][Ee][Ss])
75                 echo -n ' ignore ICMP redirect=YES'
76                 sysctl net.inet.icmp.drop_redirect=1 >/dev/null
77                 ;;
78         esac
79
80         case ${icmp_log_redirect} in
81         [Yy][Ee][Ss])
82                 echo -n ' log ICMP redirect=YES'
83                 sysctl net.inet.icmp.log_redirect=1 >/dev/null
84                 ;;
85         esac
86
87         case ${gateway_enable} in
88         [Yy][Ee][Ss])
89                 echo -n ' IP gateway=YES'
90                 sysctl net.inet.ip.forwarding=1 >/dev/null
91                 ;;
92         esac
93
94         case ${forward_sourceroute} in
95         [Yy][Ee][Ss])
96                 echo -n ' do source routing=YES'
97                 sysctl net.inet.ip.sourceroute=1 >/dev/null
98                 ;;
99         esac
100
101         case ${accept_sourceroute} in
102         [Yy][Ee][Ss])
103                 echo -n ' accept source routing=YES'
104                 sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
105                 ;;
106         esac
107
108         case ${tcp_keepalive} in
109         [Nn][Oo])
110                 echo -n ' TCP keepalive=NO'
111                 sysctl net.inet.tcp.always_keepalive=0 >/dev/null
112                 ;;
113         esac
114
115         case ${tcp_drop_synfin} in
116         [Yy][Ee][Ss])
117                 echo -n ' drop SYN+FIN packets=YES'
118                 sysctl net.inet.tcp.drop_synfin=1 >/dev/null
119                 ;;
120         esac
121
122         case ${ipxgateway_enable} in
123         [Yy][Ee][Ss])
124                 echo -n ' IPX gateway=YES'
125                 sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
126                 ;;
127         esac
128
129         case ${arpproxy_all} in
130         [Yy][Ee][Ss])
131                 echo -n ' ARP proxyall=YES'
132                 sysctl net.link.ether.inet.proxyall=1 >/dev/null
133                 ;;
134         esac
135
136         case ${ip_portrange_first} in
137         [Nn][Oo] | '')
138                 ;;
139         *)
140                 echo -n " ip_portrange_first=$ip_portrange_first"
141                 sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
142                 ;;
143         esac
144
145         case ${ip_portrange_last} in
146         [Nn][Oo] | '')
147                 ;;
148         *)
149                 echo -n " ip_portrange_last=$ip_portrange_last"
150                 sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
151                 ;;
152         esac
153
154         echo '.'
155 }
156
157 load_rc_config $name
158 run_rc_command "$1"