From ffe48c93e57dcdbdc95b15d09bad904782543da6 Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Thu, 11 Feb 2021 11:41:02 +0200 Subject: [PATCH] WS management: domain configuration functions implemented (#2567) * WS management: domain configuration functions implemented * Renamed params to make Doxygen happy * Allow reading domain parameters separately --- CHANGELOG.md | 2 +- nanostack/ws_management_api.h | 189 ++++++++++++------------- source/6LoWPAN/ws/ws_empty_functions.c | 45 ++---- source/6LoWPAN/ws/ws_management_api.c | 123 +++++----------- 4 files changed, 142 insertions(+), 217 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd32820b6d26..95933afec730 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Changes * Added throttling of number of simultaneous EAPOL authentications based on Border Router TX queue size -* Get and validate API for PHY mode ID and Channel plan ID. +* Domain configuration functions implemented. Replacing existing PHY mode ID and channel plan ID set functions. ### Bugfix * All MAC TX failure causes now trigger target change on supplicant EAPOL inititial-key sending diff --git a/nanostack/ws_management_api.h b/nanostack/ws_management_api.h index a8f113cc1a83..f506c379953a 100644 --- a/nanostack/ws_management_api.h +++ b/nanostack/ws_management_api.h @@ -95,6 +95,30 @@ extern "C" { */ #define WS_MANAGEMENT_API_VER_2 /**< Management API version */ +/** + * Deprecated! + * Configure PHY mode ID of Wi-SUN stack as defined by Wi-SUN FAN 1.1. + * + * \param interface_id Network interface ID. + * \param phy_mode_id PHY mode ID. Default 255 (not used). + * + * \return 0, Init OK. + * \return <0 Init fail. + */ +#define ws_management_phy_mode_id_set(interface_id, phy_mode_id) ws_management_domain_configuration_set(interface_id, 0, phy_mode_id, 0) + +/** + * Deprecated! + * Configure Channel plan ID of Wi-SUN stack as defined by Wi-SUN FAN 1.1. + * + * \param interface_id Network interface ID. + * \param channel_plan_id Channel plan ID. Default 255 (not used). + * + * \return 0, Init OK. + * \return <0 Init fail. + */ +#define ws_management_channel_plan_id_set(interface_id, channel_plan_id) ws_management_domain_configuration_set(interface_id, 0, 0, channel_plan_id) + /** * \brief Struct ws_statistics defines the Wi-SUN statistics storage structure. */ @@ -187,134 +211,107 @@ int ws_management_network_name_validate( char *network_name_ptr); /** - * Configure PHY mode ID of Wi-SUN stack as defined by Wi-SUN FAN 1.1. + * Set domain configuration of Wi-SUN stack. * * Change the default configuration for Wi-SUN PHY operation. * * Supported values: - * FSK without FEC: - * PHY mode ID | Symbol Rate (kbps) | Modulation Index - * 1 50 0.5 - * 2 50 1.0 - * 3 100 0.5 - * 4 100 1.0 - * 5 150 0.5 - * 6 200 0.5 - * 7 200 1.0 - * 8 300 0.5 - * - * FSK with FEC: - * PHY mode ID | Symbol Rate (kbps) | Modulation Index - * 17 50 0.5 - * 18 50 1.0 - * 19 100 0.5 - * 20 100 1.0 - * 21 150 0.5 - * 22 200 0.5 - * 23 200 1.0 - * 24 300 0.5 - * - * OFDM: - * PHY mode ID | Option | MCS | Data rate (kbps) - * 34 1 2 400 - * 35 1 3 800 - * 36 1 4 1200 - * 37 1 5 1600 - * 38 1 6 2400 - * 51 2 3 400 - * 52 2 4 600 - * 53 2 5 800 - * 54 2 6 1200 - * 68 3 4 300 - * 69 3 5 400 - * 70 3 6 600 - * 84 4 4 150 - * 85 4 5 200 - * 86 4 6 300 - * - * if value of 255 is given then previous value is used. - * - * \param interface_id Network interface ID. - * \param phy_mode_id PHY mode ID. Default 255 (not used). - * - * \return 0, Init OK. - * \return <0 Init fail. - */ -int ws_management_phy_mode_id_set( - int8_t interface_id, - uint8_t phy_mode_id); - -/** - * Get PHY mode ID of Wi-SUN stack. - * - * \param interface_id Network interface ID. - * \param phy_mode_id PHY mode ID. - * - * \return 0, OK. - * \return <0 Fail. - */ -int ws_management_phy_mode_id_get( - int8_t interface_id, - uint8_t *phy_mode_id); - -/** - * Validate PHY mode ID of Wi-SUN stack. - * - * \param interface_id Network interface ID. + * Regulatory domain: "NA"(0x01), "KR"(0x09), "EU"(0x03), "IN"(0x05), "BZ"(0x07), "JP"(0x09), "WW"(0x00) + * + * PHY mode ID: + * FSK without FEC: + * PHY mode ID | Symbol Rate (kbps) | Modulation Index + * 1 50 0.5 + * 2 50 1.0 + * 3 100 0.5 + * 4 100 1.0 + * 5 150 0.5 + * 6 200 0.5 + * 7 200 1.0 + * 8 300 0.5 + * + * FSK with FEC: + * PHY mode ID | Symbol Rate (kbps) | Modulation Index + * 17 50 0.5 + * 18 50 1.0 + * 19 100 0.5 + * 20 100 1.0 + * 21 150 0.5 + * 22 200 0.5 + * 23 200 1.0 + * 24 300 0.5 + * + * OFDM: + * PHY mode ID | Option | MCS | Data rate (kbps) + * 34 1 2 400 + * 35 1 3 800 + * 36 1 4 1200 + * 37 1 5 1600 + * 38 1 6 2400 + * 51 2 3 400 + * 52 2 4 600 + * 53 2 5 800 + * 54 2 6 1200 + * 68 3 4 300 + * 69 3 5 400 + * 70 3 6 600 + * 84 4 4 150 + * 85 4 5 200 + * 86 4 6 300 + * + * Channel plan ID: + * North America (NA): (1), (2), (5) + * Brazil (BZ): (1), (2), (5) + * + * If value of 0 is given then previous value is used. + * If value of 255 is given then default value is used. + * + * \param interface_id Network interface ID. + * \param regulatory_domain Regulatory domain. * \param phy_mode_id PHY mode ID. + * \param channel_plan_id Channel plan ID. * * \return 0, OK. * \return <0 Fail. */ -int ws_management_phy_mode_id_validate( - int8_t interface_id, - uint8_t phy_mode_id); - -/** - * Configure Channel plan ID of Wi-SUN stack as defined by Wi-SUN FAN 1.1. - * - * Change the default channel configuration for Wi-SUN. - * - * Supported values: - * North America (NA): (1), (2), (5) - * Brazil (BZ): (1), (2), (5) - * - * if value of 255 is given then previous value is used. - * - * \param interface_id Network interface ID. - * \param channel_plan_id Channel plan ID. Default 255 (not used). - * - * \return 0, Init OK. - * \return <0 Init fail. - */ -int ws_management_channel_plan_id_set( +int ws_management_domain_configuration_set( int8_t interface_id, + uint8_t regulatory_domain, + uint8_t phy_mode_id, uint8_t channel_plan_id); /** - * Get Channel plan ID of Wi-SUN stack. + * Get domain configuration of Wi-SUN stack. * * \param interface_id Network interface ID. + * \param regulatory_domain Regulatory domain. + * \param phy_mode_id PHY mode ID. * \param channel_plan_id Channel plan ID. * * \return 0, OK. * \return <0 Fail. */ -int ws_management_channel_plan_id_get( +int ws_management_domain_configuration_get( int8_t interface_id, + uint8_t *regulatory_domain, + uint8_t *phy_mode_id, uint8_t *channel_plan_id); /** - * Validate Channel plan ID of Wi-SUN stack. + * Validate domain configuration of Wi-SUN stack. * * \param interface_id Network interface ID. + * \param regulatory_domain Regulatory domain. + * \param phy_mode_id PHY mode ID. * \param channel_plan_id Channel plan ID. * * \return 0, OK. * \return <0 Fail. */ -int ws_management_channel_plan_id_validate( +int ws_management_domain_configuration_validate( int8_t interface_id, + uint8_t regulatory_domain, + uint8_t phy_mode_id, uint8_t channel_plan_id); /** diff --git a/source/6LoWPAN/ws/ws_empty_functions.c b/source/6LoWPAN/ws/ws_empty_functions.c index 8084a27b7793..c70f2e36c5da 100644 --- a/source/6LoWPAN/ws/ws_empty_functions.c +++ b/source/6LoWPAN/ws/ws_empty_functions.c @@ -68,56 +68,41 @@ int ws_management_network_name_validate( return -1; } -int ws_management_phy_mode_id_set( - int8_t interface_id, - uint8_t phy_mode_id) -{ - (void)interface_id; - (void)phy_mode_id; - return -1; -} - -int ws_management_phy_mode_id_get( - int8_t interface_id, - uint8_t *phy_mode_id) -{ - (void)interface_id; - (void)phy_mode_id; - return -1; -} - -int ws_management_phy_mode_id_validate( - int8_t interface_id, - uint8_t phy_mode_id) -{ - (void)interface_id; - (void)phy_mode_id; - return -1; -} - -int ws_management_channel_plan_id_set( +int ws_management_domain_configuration_set( int8_t interface_id, + uint8_t regulatory_domain, + uint8_t phy_mode_id, uint8_t channel_plan_id) { + (void)regulatory_domain; (void)interface_id; + (void)phy_mode_id; (void)channel_plan_id; return -1; } -int ws_management_channel_plan_id_get( +int ws_management_domain_configuration_get( int8_t interface_id, + uint8_t *regulatory_domain, + uint8_t *phy_mode_id, uint8_t *channel_plan_id) { + (void)regulatory_domain; (void)interface_id; + (void)phy_mode_id; (void)channel_plan_id; return -1; } -int ws_management_channel_plan_id_validate( +int ws_management_domain_configuration_validate( int8_t interface_id, + uint8_t regulatory_domain, + uint8_t phy_mode_id, uint8_t channel_plan_id) { + (void)regulatory_domain; (void)interface_id; + (void)phy_mode_id; (void)channel_plan_id; return -1; } diff --git a/source/6LoWPAN/ws/ws_management_api.c b/source/6LoWPAN/ws/ws_management_api.c index b5f8010a3a92..b7ff5e7a8d64 100644 --- a/source/6LoWPAN/ws/ws_management_api.c +++ b/source/6LoWPAN/ws/ws_management_api.c @@ -156,12 +156,13 @@ int ws_management_network_name_validate( return 0; } -int ws_management_phy_mode_id_set( +int ws_management_domain_configuration_set( int8_t interface_id, - uint8_t phy_mode_id) + uint8_t regulatory_domain, + uint8_t phy_mode_id, + uint8_t channel_plan_id) { protocol_interface_info_entry_t *cur; - cur = protocol_stack_interface_info_get_by_id(interface_id); if (interface_id >= 0 && (!cur || !ws_info(cur))) { return -1; @@ -177,91 +178,22 @@ int ws_management_phy_mode_id_set( return -3; } - if (phy_mode_id != 255) { - cfg.phy_mode_id = phy_mode_id; - } else { - cfg.phy_mode_id = cfg_default.phy_mode_id; - } - - if (ws_cfg_phy_set(cur, NULL, &cfg, 0) < 0) { - return -4; - } - - return 0; -} - -int ws_management_phy_mode_id_get( - int8_t interface_id, - uint8_t *phy_mode_id) -{ - protocol_interface_info_entry_t *cur; - cur = protocol_stack_interface_info_get_by_id(interface_id); - if (interface_id >= 0 && (!cur || !ws_info(cur))) { - return -1; - } - if (!phy_mode_id) { - return -2; - } - - ws_phy_cfg_t cfg; - if (ws_cfg_phy_get(&cfg, NULL) < 0) { - return -3; - } - - *phy_mode_id = cfg.phy_mode_id; - - return 0; -} - -int ws_management_phy_mode_id_validate( - int8_t interface_id, - uint8_t phy_mode_id) -{ - protocol_interface_info_entry_t *cur; - cur = protocol_stack_interface_info_get_by_id(interface_id); - if (interface_id >= 0 && (!cur || !ws_info(cur))) { - return -1; - } - - ws_phy_cfg_t cfg; - if (ws_cfg_phy_get(&cfg, NULL) < 0) { - return -3; - } - - cfg.phy_mode_id = phy_mode_id; - - if (ws_cfg_phy_validate(NULL, &cfg) < 0) { - return -4; - } - - return 0; -} - -int ws_management_channel_plan_id_set( - int8_t interface_id, - uint8_t channel_plan_id) -{ - protocol_interface_info_entry_t *cur; - - cur = protocol_stack_interface_info_get_by_id(interface_id); - if (interface_id >= 0 && (!cur || !ws_info(cur))) { - return -1; - } - - ws_phy_cfg_t cfg; - ws_phy_cfg_t cfg_default; - if (ws_cfg_phy_get(&cfg, NULL) < 0) { - return -3; + if (regulatory_domain == 255) { + cfg.regulatory_domain = cfg_default.regulatory_domain; + } else if (regulatory_domain != 0) { + cfg.regulatory_domain = regulatory_domain; } - if (ws_cfg_phy_default_set(&cfg_default) < 0) { - return -3; + if (phy_mode_id == 255) { + cfg.phy_mode_id = cfg_default.phy_mode_id; + } else if (phy_mode_id != 0) { + cfg.phy_mode_id = phy_mode_id; } - if (channel_plan_id != 255) { - cfg.channel_plan_id = channel_plan_id; - } else { + if (channel_plan_id == 255) { cfg.channel_plan_id = cfg_default.channel_plan_id; + } else if (channel_plan_id != 0) { + cfg.channel_plan_id = channel_plan_id; } if (ws_cfg_phy_set(cur, NULL, &cfg, 0) < 0) { @@ -271,8 +203,10 @@ int ws_management_channel_plan_id_set( return 0; } -int ws_management_channel_plan_id_get( +int ws_management_domain_configuration_get( int8_t interface_id, + uint8_t *regulatory_domain, + uint8_t *phy_mode_id, uint8_t *channel_plan_id) { protocol_interface_info_entry_t *cur; @@ -280,22 +214,29 @@ int ws_management_channel_plan_id_get( if (interface_id >= 0 && (!cur || !ws_info(cur))) { return -1; } - if (!channel_plan_id) { - return -2; - } ws_phy_cfg_t cfg; if (ws_cfg_phy_get(&cfg, NULL) < 0) { - return -3; + return -2; } - *channel_plan_id = cfg.channel_plan_id; + if (regulatory_domain) { + *regulatory_domain = cfg.regulatory_domain; + } + if (phy_mode_id) { + *phy_mode_id = cfg.phy_mode_id; + } + if (channel_plan_id) { + *channel_plan_id = cfg.channel_plan_id; + } return 0; } -int ws_management_channel_plan_id_validate( +int ws_management_domain_configuration_validate( int8_t interface_id, + uint8_t regulatory_domain, + uint8_t phy_mode_id, uint8_t channel_plan_id) { protocol_interface_info_entry_t *cur; @@ -309,6 +250,8 @@ int ws_management_channel_plan_id_validate( return -3; } + cfg.regulatory_domain = regulatory_domain; + cfg.phy_mode_id = phy_mode_id; cfg.channel_plan_id = channel_plan_id; if (ws_cfg_phy_validate(NULL, &cfg) < 0) {