1 # setup entry in /etc/config/network for a interface
2 # Argument $1: network interface
8 # Setup a (new) interface section for $net
10 ipaddr=$(uci -q get meshwizard.netconfig.$net\_ip4addr)
11 ip6addr=$(uci -q get meshwizard.netconfig.$net\_ip6addr)
12 [ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr
14 netmask=$(uci -q get meshwizard.netconfig.$net\_netmask)
15 [ -z "$netmask" ] && netmask="$interface_netmask"
16 [ -z "$netmask" ] && netmask="255.255.0.0"
18 uci set network.$netrenamed="interface"
19 set_defaults "interface_" network.$netrenamed
22 set network.$netrenamed.proto="static"
23 set network.$netrenamed.ipaddr="$ipaddr"
24 set network.$netrenamed.netmask="$netmask"
27 # Setup IPv6 for the interface
29 if [ "$profile_ipv6" = 1 ]; then
30 if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
31 ip6addr="$($dir/helpers/gen_auto-ipv6-dhcpv6-ip.sh $netrenamed)"
32 uci set network.$netrenamed.ip6addr="${ip6addr}/112"
34 if [ "$profile_ipv6_config" = "static" ] && [ -n "$ip6addr" ]; then
35 uci set network.$netrenamed.ip6addr="$ip6addr"
39 uci_commitverbose "Setup interface $netrenamed" network
41 # setup dhcp alias/interface
43 net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
44 if [ "$net_dhcp" == 1 ]; then
46 # Load meshwizard_settings
47 dhcprange="$(uci -q get meshwizard.netconfig.${net}_dhcprange)"
48 interface_ip="$(uci -q get meshwizard.netconfig.${net}_ip4addr)"
49 vap=$(uci -q get meshwizard.netconfig.${net}_vap)
53 config_get interface "$1" interface
54 if [ "$interface" == "$netrenamed" ]; then
55 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
56 section_rename network $1 ${netrenamed}dhcp
61 config_foreach handle_dhcpalias alias
63 # Get IP/netmask and start-ip for $net dhcp
64 # If no dhcprange is given in /etc/config/meshwizard we autogenerate one
66 if [ -z "$dhcprange" ]; then
67 dhcprange="$($dir/helpers/gen_dhcp_ip.sh $interface_ip)/24"
68 uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
70 eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
72 # setup wifi-dhcp interface or alias
74 # Setup alias for $net
76 if [ "$vap" == 1 ]; then
77 uci set network.${netrenamed}dhcp=interface
79 uci set network.${netrenamed}dhcp=alias
80 uci set network.${netrenamed}dhcp.interface="$netrenamed"
84 set network.${netrenamed}dhcp.proto=static
85 set network.${netrenamed}dhcp.ipaddr="$START"
86 set network.${netrenamed}dhcp.netmask="$NETMASK"
88 uci_commitverbose "Setup interface for ${netrenamed}dhcp" network