Hi, in my use-case urndis is likely never there at boot, and while i've been aware of ifstated(8) all the time, the relevant man pages have felt dry w/regards giving something trivial/!carp, to make me skip setting this up again for far too long:)
/etc/examples/ifstated.conf also supported my previous view, that this wasn't the tool i was looking for. english, and all that + manpage diff, so i'll show everything necessary for the simple use-case, instead of trying to add bits here and there.. originally i intended to just make it clearer that the "For example:" under "STATE DEFINITIONS" was not about: "It is also possible to write multiple nested if blocks.", and iirc. in my quick testing i found out i actually needed the nesting below in the auto state, to allow auto->running when starting ifstated while urndis0 is already set up&working. -Artturi diff --git a/usr.sbin/ifstated/ifstated.conf.5 b/usr.sbin/ifstated/ifstated.conf.5 index 2721871926c..554ea043c5f 100644 --- a/usr.sbin/ifstated/ifstated.conf.5 +++ b/usr.sbin/ifstated/ifstated.conf.5 @@ -136,20 +136,49 @@ blocks. .Pp For example: .Bd -literal -offset indent -state one { +urndis_up = "urndis0.link.up" +_avail_fast = '( "ifconfig urndis0 -debug 2> /dev/null" every 5)' +_avail_init = '( "ifconfig urndis0 -debug 2> /dev/null" every 15)' +_avail_slow = '( "ifconfig urndis0 -debug 2> /dev/null" every 30)' + +# The ip address below is the address of the android peer +peer = '( "ping -q -c 1 -w 1 192.168.42.129 > /dev/null" every 5)' + +state auto { + if $urndis_up + set-state running + + if ! $urndis_up + if $_avail_init + set-state bringup +} + +state absent { + if $_avail_fast + set-state bringup +} + +state bringup { init { - run "ifconfig carp0 advskew 10" - run "ifconfig carp1 advskew 10" + run "ksh /etc/netstart urndis0" + run "sleep 2" } + if $peer + set-state running +} - if ! $net - set-state two +state lost { + if $urndis_up && $peer + set-state running + if ! $_avail_fast + set-state absent +} - if ! $carp_up { - run "ifconfig carp0 advskew 254" - run "ifconfig carp1 advskew 254" - set-state three - } +state running { + if ! $urndis_up + set-state lost + if ! $_avail_slow + set-state absent } .Ed .Sh GRAMMAR