diff --git a/ieee1905/files/etc/init.d/ieee1905 b/ieee1905/files/etc/init.d/ieee1905 index 22b14dadd..8d643c664 100755 --- a/ieee1905/files/etc/init.d/ieee1905 +++ b/ieee1905/files/etc/init.d/ieee1905 @@ -5,7 +5,82 @@ STOP=21 USE_PROCD=1 +IS_CFG_VALID=1 + +validate_ieee1905_section() { + uci_validate_section ieee1905 ieee1905 "ieee1905" \ + 'enabled:bool:true' \ + 'macaddress:or("auto",macaddr)' \ + 'registrar:string' \ + 'extension:bool:false' \ + 'extmodule:list(string)' \ + + [ "$?" -ne 0 ] && { + logger -s -t "ieee1905" "Validation of ieee1905 section failed" + IS_CFG_VALID=0 + return 1 + } + return 0 +} + +validate_ali_section() { + local section="$1" + + uci_validate_section ieee1905 $section "${1}" \ + 'ifname:string' \ + 'type:or("bridge",string)' + + [ "$?" -ne 0 ] && { + logger -s -t "ieee1905" "Validation of al-iface section $section failed" + IS_CFG_VALID=0 + return 1 + } + return 0 +} + +validate_ap_section() { + local section="$1" + + uci_validate_section ieee1905 $section "${1}" \ + 'band:or("2", "5", "60")' \ + 'ssid:string' \ + 'encryption:or("psk2", "sae-mixed", "sae", string)' \ + 'key:string' \ + 'uuid:string' \ + 'manufacturer:string' \ + 'model_name:string' \ + 'device_name:string' \ + 'model_number:string' \ + 'serial_number:string' \ + 'device_type:string' \ + 'os_version:uinteger' + + [ "$?" -ne 0 ] && { + logger -s -t "ieee1905" "Validation of ap section $section failed" + IS_CFG_VALID=0 + return 1 + } + return 0 +} + +validate_ieee1905_config() { + IS_CFG_VALID=1 + + validate_ieee1905_section && + config_foreach validate_ali_section "al-iface" && + config_foreach validate_ap_section ap + + [ "$IS_CFG_VALID" -ne 1 ] && { + logger -s -t "ieee1905" "Validation of ieee1905 UCI file failed" + return 1 + } + return 0 +} + start_service() { + config_load "ieee1905" + validate_ieee1905_config || return 1; + procd_open_instance procd_set_param command "/usr/sbin/ieee1905d" procd_set_param respawn