bcm53xx: fix ASUS firmwares to use vendor format
[openwrt/staging/jogo.git] / package / network / config / netifd / files / etc / init.d / network
1 #!/bin/sh /etc/rc.common
2
3 START=20
4 STOP=90
5
6 USE_PROCD=1
7
8 init_switch() {
9 setup_switch() { return 0; }
10
11 include /lib/network
12 setup_switch
13 }
14
15 start_service() {
16 init_switch
17
18 procd_open_instance
19 procd_set_param command /sbin/netifd
20 procd_set_param respawn
21 procd_set_param watch network.interface
22 [ -e /proc/sys/kernel/core_pattern ] && {
23 procd_set_param limits core="unlimited"
24 }
25 procd_close_instance
26 }
27
28 reload_service() {
29 local rv=0
30
31 init_switch
32 ubus call network reload || rv=1
33 /sbin/wifi reload_legacy
34 return $rv
35 }
36
37 stop_service() {
38 /sbin/wifi down
39 ifdown -a
40 sleep 1
41 }
42
43 validate_atm_bridge_section()
44 {
45 uci_validate_section network "atm-bridge" "${1}" \
46 'unit:uinteger:0' \
47 'vci:range(32, 65535):35' \
48 'vpi:range(0, 255):8' \
49 'atmdev:uinteger:0' \
50 'encaps:or("llc", "vc"):llc' \
51 'payload:or("bridged", "routed"):bridged'
52 }
53
54 validate_route_section()
55 {
56 uci_validate_section network route "${1}" \
57 'interface:string' \
58 'target:cidr4' \
59 'netmask:netmask4' \
60 'gateway:ip4addr' \
61 'metric:uinteger' \
62 'mtu:uinteger' \
63 'table:or(range(0,65535),string)'
64 }
65
66 validate_route6_section()
67 {
68 uci_validate_section network route6 "${1}" \
69 'interface:string' \
70 'target:cidr6' \
71 'gateway:ip6addr' \
72 'metric:uinteger' \
73 'mtu:uinteger' \
74 'table:or(range(0,65535),string)'
75 }
76
77 validate_rule_section()
78 {
79 uci_validate_section network rule "${1}" \
80 'in:string' \
81 'out:string' \
82 'src:cidr4' \
83 'dest:cidr4' \
84 'tos:range(0,31)' \
85 'mark:string' \
86 'invert:bool' \
87 'lookup:or(range(0,65535),string)' \
88 'goto:range(0,65535)' \
89 'action:or("prohibit", "unreachable", "blackhole", "throw")'
90 }
91
92 validate_rule6_section()
93 {
94 uci_validate_section network rule6 "${1}" \
95 'in:string' \
96 'out:string' \
97 'src:cidr6' \
98 'dest:cidr6' \
99 'tos:range(0,31)' \
100 'mark:string' \
101 'invert:bool' \
102 'lookup:or(range(0,65535),string)' \
103 'goto:range(0,65535)' \
104 'action:or("prohibit", "unreachable", "blackhole", "throw")'
105 }
106
107 validate_switch_section()
108 {
109 uci_validate_section network switch "${1}" \
110 'name:string' \
111 'enable:bool' \
112 'enable_vlan:bool' \
113 'reset:bool' \
114 'ar8xxx_mib_poll_interval:uinteger' \
115 'ar8xxx_mib_type:range(0,1)'
116 }
117
118 validate_switch_vlan()
119 {
120 uci_validate_section network switch_vlan "${1}" \
121 'device:string' \
122 'vlan:uinteger' \
123 'ports:list(ports)'
124 }
125
126 service_triggers()
127 {
128 procd_add_reload_trigger network wireless
129
130 procd_open_validate
131 validate_atm_bridge_section
132 validate_route_section
133 [ -e /proc/sys/net/ipv6 ] && validate_route6_section
134 validate_rule_section
135 [ -e /proc/sys/net/ipv6 ] && validate_rule6_section
136 validate_switch_section
137 validate_switch_vlan
138 procd_close_validate
139 }
140
141 shutdown() {
142 ifdown -a
143 sleep 1
144 }