base-files: the initial hotplug2 instance sometimes misses a few relevant events...
[openwrt.git] / package / netifd / files / lib / network / config.sh
1 #!/bin/sh
2 # Copyright (C) 2011 OpenWrt.org
3
4 . /usr/share/libubox/jshn.sh
5
6 find_config() {
7 return
8 }
9
10 unbridge() {
11 return
12 }
13
14 ubus_call() {
15 json_init
16 local _data="$(ubus call "$1" "$2")"
17 [ $? -ne 0 ] && return "$?"
18 json_load "$_data"
19 return 0
20 }
21
22
23 fixup_interface() {
24 local config="$1"
25 local ifname
26
27 config_get type "$config" type
28 config_get ifname "$config" ifname
29 [ "bridge" = "$type" ] && ifname="br-$config"
30 config_set "$config" device "$ifname"
31 ubus_call "network.interface.$config" status
32 json_get_var l3dev l3_device
33 [ -n "$l3dev" ] && ifname="$l3dev"
34 json_init
35 config_set "$config" ifname "$ifname"
36 }
37
38 scan_interfaces() {
39 config_load network
40 config_foreach fixup_interface interface
41 }
42
43 prepare_interface_bridge() {
44 local config="$1"
45
46 [ -n "$config" ] || return 0
47 ubus call network.interface."$config" prepare
48 }
49
50 setup_interface() {
51 local iface="$1"
52 local config="$2"
53
54 [ -n "$config" ] || return 0
55 ubus call network.interface."$config" add_device "{ \"name\": \"$iface\" }"
56 }
57
This page took 0.057284 seconds and 5 git commands to generate.