Improve link up/down behaviour
This commit is contained in:
parent
1eae59103d
commit
e8c8c3eabb
|
@ -3,20 +3,19 @@
|
|||
<require-service <milestone network>>
|
||||
<depends-on <milestone network> <service-state <daemon interface-monitor> ready>>
|
||||
|
||||
<configure-interface "lo" <static "127.0.0.1">>
|
||||
<configure-interface "lo" <static "127.0.0.1/8">>
|
||||
|
||||
? <configure-interface ?ifname <static ?ipaddr>> [
|
||||
! <run-oneshot ["ifconfig" $ifname $ipaddr "up"]>
|
||||
?- ! <run-oneshot ["ifconfig" $ifname "down"] never>
|
||||
! <run-oneshot ["ip" "address" "add" "dev" $ifname $ipaddr]>
|
||||
?- ! <run-oneshot ["ip" "address" "del" "dev" $ifname $ipaddr] never>
|
||||
]
|
||||
|
||||
? <configure-interface ?ifname <dhcp>> [
|
||||
! <run-oneshot ["ifconfig" $ifname "up"]>
|
||||
?- ! <run-oneshot ["ifconfig" $ifname "down"] never>
|
||||
<require-service <daemon <udhcpc $ifname>>>
|
||||
]
|
||||
|
||||
? <run-service <daemon <udhcpc ?ifname>>> [
|
||||
; We use a custom script that gives mobile-data devices a sensible routing metric
|
||||
<daemon <udhcpc $ifname> ["udhcpc" "-i" $ifname "-fR" "-s" "/usr/lib/synit/udhcpc.script"]>
|
||||
]
|
||||
|
||||
|
@ -32,11 +31,19 @@
|
|||
}
|
||||
]
|
||||
|
||||
$machine ? <interface ?ifname _ normal _ _ carrier _> [
|
||||
$machine ? <interface ?ifname _ _ _ _ _ _> [
|
||||
$log ! <log "-" { saw-machine-interface: $ifname }>
|
||||
$config [
|
||||
! <run-oneshot ["ip" "link" "set" $ifname "up"]>
|
||||
?- ! <run-oneshot ["ip" "link" "set" $ifname "down"] never>
|
||||
]
|
||||
]
|
||||
|
||||
$machine ? <interface ?ifname _ normal up up carrier _> [
|
||||
$config <configure-interface $ifname <dhcp>>
|
||||
]
|
||||
|
||||
$machine ? <route ?af default _ _ _ _> [
|
||||
$config <default-route $af>
|
||||
$machine ? <route ?addressFamily default _ _ _ _> [
|
||||
$config <default-route $addressFamily>
|
||||
]
|
||||
]
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
argv: "/usr/lib/synit/wifi-daemon"
|
||||
protocol: application/syndicate
|
||||
}>
|
||||
|
||||
? <machine-dataspace ?machine> [
|
||||
? <service-object <daemon <wifi-daemon $ifname>> ?cap> [
|
||||
$cap {
|
||||
|
|
|
@ -57,7 +57,7 @@ class WPASupplicantClient:
|
|||
self.sock.settimeout(timeout_sec)
|
||||
try:
|
||||
reply = self.sock.recv(65536)
|
||||
self.log.info(f'Raw input: {repr(reply)}')
|
||||
self.log.debug(f'Raw input: {repr(reply)}')
|
||||
return reply.strip().decode('utf-8')
|
||||
except TimeoutError:
|
||||
return None
|
||||
|
@ -89,7 +89,6 @@ def main(args):
|
|||
|
||||
client = WPASupplicantClient(ifname, turn.log)
|
||||
commands = []
|
||||
active_network_id = None
|
||||
|
||||
def send_next_command():
|
||||
while len(commands) > 0:
|
||||
|
@ -113,17 +112,12 @@ def main(args):
|
|||
continue
|
||||
turn.log.info(f'Cleaning out old network: {repr(line)}')
|
||||
send_command('REMOVE_NETWORK ' + line.split('\t')[0])
|
||||
send_command('ADD_NETWORK', remember_network_id)
|
||||
|
||||
def remember_network_id(netid):
|
||||
nonlocal active_network_id
|
||||
active_network_id = netid
|
||||
turn.log.info(f'Network ID: {active_network_id}')
|
||||
def handle_scan_failure(reply):
|
||||
if reply == 'FAIL':
|
||||
send_command('TERMINATE')
|
||||
send_command('SCAN', handle_scan_failure)
|
||||
|
||||
def handle_scan_failure(reply):
|
||||
if reply == 'FAIL':
|
||||
send_command('TERMINATE')
|
||||
|
||||
send_command('LEVEL 3')
|
||||
send_command('LIST_NETWORKS', cleanout_networks)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ horizontal
|
|||
WidgetType´³orµµ±NodeType´³refµ„³NodeType„„µ±LeafType´³refµ„³LeafType„„„„³WindowTitle´³rec´³lit³window-title„´³tupleµ´³named³title´³atom³String„„„„„³WidgetInstance´³rec´³lit³widget-instance„´³tupleµ´³named³id´³refµ„³WidgetId„„´³named³instance´³embedded³any„„„„„³WindowCloseable´³rec´³lit³window-closeable„´³tupleµ„„„„³embeddedType€„„µ³mime„´³schema·³version‘³definitions·³Value´³rec´³lit³mime„´³tupleµ´³named³type´³atom³Symbol„„´³named³data´³atom³
|
||||
ByteString„„„„„„³embeddedType€„„µ³time„´³schema·³version‘³definitions·³Stamp´³rec´³lit³rfc3339„´³tupleµ´³named³value´³atom³String„„„„„„³embeddedType€„„µ³audio„´³schema·³version‘³definitions·³Sink´³orµµ±speaker´³lit³speaker„„µ±headset´³lit³headset„„µ±earpiece´³lit³earpiece„„„„³Source´³orµµ±speakerphone´³lit³speakerphone„„µ±headset´³lit³headset„„µ±handset´³lit³handset„„„„³SinkMapping´³rec´³lit³alsa-sink-mapping„´³tupleµ´³named³abstract´³refµ„³Sink„„´³named³concrete´³atom³String„„„„„³HeadsetSpeakerPresent´³rec´³lit³headset-speaker-present„´³tupleµ„„„³HeadsetMicrophonePresent´³rec´³lit³headset-microphone-present„´³tupleµ„„„„³embeddedType€„„µ³hayes„´³schema·³version‘³definitions·³Result´³rec´³lit³result„´³tupleµ´³named³text´³atom³String„„´³named³tag´³refµ„³MaybeString„„´³named³fields´³refµ„³MaybeStrings„„„„„³MaybeString´³orµµ±present´³atom³String„„µ±absent´³lit€„„„„³MaybeStrings´³orµµ±present´³seqof´³atom³String„„„µ±absent´³lit€„„„„³ModemPresent´³rec´³lit³modem„´³tupleµ´³lit³hayes„´³named³
|
||||
devicePath´³atom³String„„´³named³ dataspace´³embedded´³refµ„³InternalProtocol„„„„„„³
CommandResult´³rec´³lit³command-result„´³tupleµ´³named³commandText´³atom³String„„´³named³results´³seqof´³refµ„³Result„„„´³named³finalResult´³atom³String„„„„„³ExecuteCommand´³rec´³lit³execute-command„´³tupleµ´³named³commandText´³atom³String„„´³named³replyTo´³refµ„³CommandContinuation„„„„„³InternalProtocol³any³CommandContinuation´³orµµ±replyWanted´³embedded´³refµ„³
CommandResult„„„µ±
fireAndForget´³lit€„„„„³UnsolicitedResultCode´³rec´³lit³unsolicited„´³tupleµ´³named³result´³refµ„³Result„„„„„„³embeddedType€„„µ³network„´³schema·³version‘³definitions·³Route´³rec´³lit³route„´³tupleµ´³named³
addressFamily´³refµ„³
AddressFamily„„´³named³destination´³refµ„³RouteDestination„„´³named³priority´³atom³
SignedInteger„„´³named³
typeOfService´³atom³
SignedInteger„„´³named³
interfaceName´³refµ„³RouteInterface„„´³named³gateway´³refµ„³Gateway„„„„„³Gateway´³orµµ±addr´³atom³String„„µ±none´³lit€„„„„³Hotspot´³rec´³lit³hotspot„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„´³named³authentication´³refµ„³WifiAuthentication„„„„„³ Interface´³rec´³lit³ interface„´³tupleµ´³named³name´³atom³String„„´³named³index´³atom³
SignedInteger„„´³named³type´³refµ„³
InterfaceType„„´³named³administrativeState´³refµ„³AdministrativeState„„´³named³operationalState´³refµ„³OperationalState„„´³named³carrier´³refµ„³CarrierState„„´³named³linkAddr´³atom³String„„„„„³CarrierState´³orµµ± noCarrier´³lit³
|
||||
no-carrier„„µ±carrier´³lit³carrier„„„„³DefaultRoute´³rec´³lit³
default-route„´³tupleµ´³named³
addressFamily´³refµ„³
AddressFamily„„„„„³HotspotState´³rec´³lit³
hotspot-state„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„´³named³stationCount´³atom³
SignedInteger„„„„„³
AddressFamily´³orµµ±ipv4´³lit³ipv4„„µ±ipv6´³lit³ipv6„„µ±other´³atom³
SignedInteger„„„„³
InterfaceType´³orµµ±loopback´³lit³loopback„„µ±normal´³lit³normal„„µ±wireless´³lit³wireless„„„„³
MobileDataApn´³rec´³lit³mobile-data-apn„´³tupleµ´³named³apn´³atom³String„„„„„³RouteInterface´³orµµ±name´³atom³String„„µ±none´³lit€„„„„³WifiAssociation´³rec´³lit³wifi-association„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„´³named³state´³refµ„³WifiAssociationState„„„„„³OperationalState´³orµµ±unknown´³lit³unknown„„µ±down´³lit³down„„µ±lowerLayerDown´³lit³lower-layer-down„„µ±testing´³lit³testing„„µ±dormant´³lit³dormant„„µ±up´³lit³up„„„„³RouteDestination´³orµµ±default´³lit³default„„µ±prefix´³rec´³lit³prefix„´³tupleµ´³named³net´³atom³String„„´³named³bits´³atom³
SignedInteger„„„„„„„„³SavedWifiNetwork´³rec´³lit³saved-wifi-network„´³tupleµ´³named³ssid´³atom³String„„´³named³authentication´³refµ„³WifiAuthentication„„´³named³priority´³atom³Double„„„„„³WifiAuthentication´³orµµ±open´³lit³open„„µ±psk´³rec´³lit³psk„´³tupleµ´³named³password´³atom³String„„„„„„µ±other³any„„„³AdministrativeState´³orµµ±unknown´³lit³unknown„„µ±down´³lit³down„„µ±up´³lit³up„„„„³SelectedWifiNetwork´³rec´³lit³selected-wifi-network„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„´³named³authentication´³refµ„³WifiAuthentication„„„„„³AvailableAccessPoint´³rec´³lit³available-ap„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„„„„³WifiAssociationState´³orµµ±
|
||||
no-carrier„„µ±carrier´³lit³carrier„„„„³DefaultRoute´³rec´³lit³
default-route„´³tupleµ´³named³
addressFamily´³refµ„³
AddressFamily„„„„„³HotspotState´³rec´³lit³
hotspot-state„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„´³named³stationCount´³atom³
SignedInteger„„„„„³
AddressFamily´³orµµ±ipv4´³lit³ipv4„„µ±ipv6´³lit³ipv6„„µ±other´³atom³
SignedInteger„„„„³
InterfaceType´³orµµ±loopback´³lit³loopback„„µ±normal´³lit³normal„„µ±wireless´³lit³wireless„„„„³
MobileDataApn´³rec´³lit³mobile-data-apn„´³tupleµ´³named³apn´³atom³String„„„„„³RouteInterface´³orµµ±name´³atom³String„„µ±none´³lit€„„„„³WifiAssociation´³rec´³lit³wifi-association„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„´³named³state´³refµ„³WifiAssociationState„„„„„³OperationalState´³orµµ±unknown´³lit³unknown„„µ±down´³lit³down„„µ±lowerLayerDown´³lit³lower-layer-down„„µ±testing´³lit³testing„„µ±dormant´³lit³dormant„„µ±up´³lit³up„„„„³RouteDestination´³orµµ±default´³lit³default„„µ±prefix´³rec´³lit³prefix„´³tupleµ´³named³net´³atom³String„„´³named³bits´³atom³
SignedInteger„„„„„„„„³SavedWifiNetwork´³rec´³lit³saved-wifi-network„´³tupleµ´³named³ssid´³atom³String„„´³named³authentication´³refµ„³WifiAuthentication„„´³named³priority´³atom³Double„„„„„³MobileDataEnabled´³rec´³lit³mobile-data-enabled„´³tupleµ„„„³WifiAuthentication´³orµµ±open´³lit³open„„µ±psk´³rec´³lit³psk„´³tupleµ´³named³password´³atom³String„„„„„„µ±other³any„„„³AdministrativeState´³orµµ±unknown´³lit³unknown„„µ±down´³lit³down„„µ±up´³lit³up„„„„³SelectedWifiNetwork´³rec´³lit³selected-wifi-network„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„´³named³authentication´³refµ„³WifiAuthentication„„„„„³AvailableAccessPoint´³rec´³lit³available-ap„´³tupleµ´³named³
interfaceName´³atom³String„„´³named³ssid´³atom³String„„„„„³WifiAssociationState´³orµµ±
|
||||
inProgress´³lit³in-progress„„µ±ready´³lit³ready„„„„„³embeddedType€„„µ³ telephony„´³schema·³version‘³definitions·³CallId´³atom³
SignedInteger„³Address´³rec´³lit³address„´³tupleµ´³named³
|
||||
numberType´³refµ„³
|
||||
NumberType„„´³named³number´³atom³String„„„„„³CallType´³orµµ±voice´³lit³voice„„µ±data´³lit³data„„µ±fax´³lit³fax„„„„³ CallState´³orµµ±hold´³lit³hold„„µ±original´³lit³original„„µ±connect´³lit³connect„„µ±incoming´³lit³incoming„„µ±waiting´³lit³waiting„„µ±end´³lit³end„„µ±alerting´³lit³alerting„„„„³ PlaceCall´³rec´³lit³
|
||||
|
|
|
@ -76,9 +76,6 @@ AvailableAccessPoint = <available-ap @interfaceName string @ssid string> .
|
|||
WifiAssociation = <wifi-association @interfaceName string @ssid string @state WifiAssociationState> .
|
||||
WifiAssociationState = @inProgress =in-progress / =ready .
|
||||
|
||||
SelectedWifiNetwork = <selected-wifi-network @interfaceName string @ssid string @authentication WifiAuthentication> .
|
||||
|
||||
Hotspot = <hotspot @interfaceName string @ssid string @authentication WifiAuthentication> .
|
||||
HotspotState = <hotspot-state @interfaceName string @ssid string @stationCount int> .
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
|
@ -86,6 +83,8 @@ HotspotState = <hotspot-state @interfaceName string @ssid string @stationCount i
|
|||
|
||||
MobileDataApn = <mobile-data-apn @apn string> .
|
||||
|
||||
MobileDataEnabled = <mobile-data-enabled> .
|
||||
|
||||
SavedWifiNetwork = <saved-wifi-network
|
||||
@ssid string
|
||||
@authentication WifiAuthentication
|
||||
|
@ -98,3 +97,13 @@ WifiAuthentication =
|
|||
/ ; Other, not-yet-implemented
|
||||
@other any
|
||||
.
|
||||
|
||||
SelectedWifiNetwork = <selected-wifi-network
|
||||
@interfaceName string
|
||||
@ssid string
|
||||
@authentication WifiAuthentication> .
|
||||
|
||||
Hotspot = <hotspot
|
||||
@interfaceName string
|
||||
@ssid string
|
||||
@authentication WifiAuthentication> .
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<require-service <daemon squeak>>
|
||||
|
||||
<daemon squeak {
|
||||
argv: "exec squeak -vm-display-fbdev -msdev /dev/null -kbdev /dev/input/event2"
|
||||
argv: "exec squeak -vm-display-fbdev -msdev /dev/null -kbdev /dev/null"
|
||||
dir: "/home/user"
|
||||
protocol: application/syndicate
|
||||
}>
|
||||
|
@ -12,8 +12,6 @@
|
|||
}
|
||||
]
|
||||
|
||||
; <depends-on <daemon squeak> <default-route ipv4>>
|
||||
|
||||
<depends-on <daemon squeak> <service-state <daemon fbdev-setup> complete>>
|
||||
<daemon fbdev-setup <one-shot "echo 1 > /sys/class/graphics/fb0/state">>
|
||||
|
||||
|
|
Loading…
Reference in New Issue