On 2012-05-31 9:56 AM, Roberto Riggio wrote: > On 05/30/2012 04:09 PM, Felix Fietkau wrote: >> Do you have any call to proto_init_update/proto_send_update in there, >> similar to what the dhcp script does when it has acquired a lease? > > Hi, thanks for the feedback. I'm making some progresses now. This is the > current script: > > #!/bin/sh > > [ -n "$INCLUDE_ONLY" ] || { > . /etc/functions.sh > . ../netifd-proto.sh > init_proto "$@" > } > > proto_wing_init_config() { > no_device=1 > available=1 > proto_config_add_string "ipaddr" > } > > proto_wing_teardown() { > local config="$1" > local link="wing-$config" > [ -f "/var/run/$link.pid" ] && { > kill -9 $(cat /var/run/$link.pid) > rm /var/run/$link.pid > } > } > > proto_wing_setup() { > > local config="$1" > local link="wing-$config" > > # here I start the routing daemon which creates a TUN interface called > $link > > proto_init_update "$link" 1 > proto_add_ipv4_address "$ipaddr" "$netmasj" > > route -n | grep -q '^0.0.0.0' || { > proto_add_ipv4_route "0.0.0.0" 0 > } > > proto_send_update "$config" > > } > > [ -n "$INCLUDE_ONLY" ] || { > add_protocol wing > } > > I have one major problem. The mesh works correctly if I call ifup mesh > AFTER the boot. The problem is that at bootstrap openwrt tries to bring > this interface up before the wifi. Is there a way to tell openwrt to > bring this interface up after wifi (or after all the other interface are up) > > Could you explain briefly when to use the following constructs: > > - no_device=1, this should be for case where the device is created at > run time like a tunnel or my mesh protocol That means the interface is not bound to a specific device (e.g. eth0, wlan0, etc.). If a wing instance is bound to one specific wifi device, you may want to leave out no_device and configure wing like static/dhcp/pppoe.
> - available=1 ??? available=1 means that the interface can be brought up immediately instead of having to wait for an external trigger (usually only used together with no_device; if the interface is bound to a device, device presence controls interface availability). > - proto_config_add_ ??? Registers config variables that this module is interested in. > - json_get_var / json_add Between netifd and the scripts, data is exchanged in json format, there's a shell library that's being used for that. In the _setup function you can use json_get_var <destination_variable> <json_field_name> to get a specific config parameter that was registered in _init_config. json_add gets used if you want to build a json string from the shell. json_init initializes a new message, you can use json_add_{array,string,table,int,boolean} to add fields. - Felix _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel