Skip to content

Commit

Permalink
Network: made kconfig border router
Browse files Browse the repository at this point in the history
  • Loading branch information
CW-75 authored and Rocio committed Jul 10, 2022
1 parent 0b27c4c commit 422712f
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 81 deletions.
2 changes: 1 addition & 1 deletion firmware/network/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ rsource "radio/Kconfig"
rsource "rpl_protocol/Kconfig"
rsource "udp_client/Kconfig"
rsource "udp_server/Kconfig"

rsource "border_router/Kconfig"
endmenu
21 changes: 21 additions & 0 deletions firmware/network/border_router/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
menu "Border Router"

menu "INTERFACE"
config WIRED_INTERFACE
int "WIRED"
default 0

config WIRELESS_INTERFACE
int "WIRELESS"
default 1

config ADDRESS_IPV6_WIRED
string "Wired address IPV6"
default "2001:db8:1::1"

config ADDRESS_IPV6_WIRELESS
string "Wireless address IPV6"
default "2001:db8:2::1"

endmenu # Prefix
endmenu
7 changes: 5 additions & 2 deletions firmware/network/border_router/border_router.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@
int8_t border_router_setup(ipv6_addr_t addr, uint8_t prefix, uint8_t iface_type) {
ipv6_addr_t ip;
int8_t index;

switch (iface_type) {
case WIRED_INTERFACE:
case CONFIG_WIRED_INTERFACE:
index = get_wired_iface();
break;
case WIRELESS_INTERFACE:
case CONFIG_WIRELESS_INTERFACE:
index = get_ieee802154_iface();
break;
default:
printf("Error: Type of Interface doesn't exists File: %s, line: %d\n", __FILE__, __LINE__);
return -1;
}

if (index < 0) {
printf("Error: Expected interface wasn't found. File: %s, line %d\n", __FILE__, __LINE__);
return -1;
Expand All @@ -59,6 +61,7 @@ int8_t border_router_setup(ipv6_addr_t addr, uint8_t prefix, uint8_t iface_type)
}
return 0;
}

printf("Error: Only can be processed Unicast and Multicast Addresses. File: %s, line: %d\n",
__FILE__, __LINE__);
return -1;
Expand Down
15 changes: 2 additions & 13 deletions firmware/network/border_router/include/border_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,12 @@
extern "C" {
#endif

/**
* @enum type_iface_t List of all types of Interface
* @{
*
*/
enum type_iface_t {
WIRED_INTERFACE = 0, /*!<Represents the type of interface is wired*/
WIRELESS_INTERFACE /*!<Represents the type of interface is wireless*/
};
/**@}*/

/**
* @brief This function init the border router. sets ipv6 in an interface.
*
* @param[in] addr ipv6 address
* @param[in] addr ipv6 address.
* @param[in] iface_type refers to if is used a WIRED or WIRELESS interface.
* @param[in] prefix Networks prefix,express the subnet size.
* @param[in] prefix Networks prefix,express the subnet size.
* @retval 0 Setup Success
* @retval -1 Setup Failed
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/border_router/Kconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rsource "../../firmware/network/rpl_protocol/Kconfig"
rsource "../../firmware/network/border_router/Kconfig"
9 changes: 4 additions & 5 deletions tests/border_router/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ void test_border_router_setup_wired(void) {
ipv6_addr_t address = {
.u8 = {0},
};
ipv6_addr_from_str(&address, "2001:db8:2::1");
int err = border_router_setup(address, 64, WIRED_INTERFACE);
ipv6_addr_from_str(&address, CONFIG_ADDRESS_IPV6_WIRED);
int err = border_router_setup(address, 64, CONFIG_WIRED_INTERFACE);
TEST_ASSERT_EQUAL_INT(0, err);
}

void test_border_router_setup_wireless(void) {
ipv6_addr_t address = {
.u8 = {0},
};
ipv6_addr_from_str(&address, "2001:db8:1::2");
int err = border_router_setup(address, 16, WIRELESS_INTERFACE);
ipv6_addr_from_str(&address, CONFIG_ADDRESS_IPV6_WIRELESS);
int err = border_router_setup(address, 16, CONFIG_WIRELESS_INTERFACE);
TEST_ASSERT_EQUAL_INT(0, err);
}

Expand Down
12 changes: 1 addition & 11 deletions tests/radio/Kconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
menu "PHY settings"
#comment "PHY settings"
config TX_POWER
int "Default TX Power"
default 0

config RADIO_CHANNEL
int "Default Radio Channel"
default 11

endmenu #Phy
rsource "../../firmware/network/radio/Kconfig"
12 changes: 1 addition & 11 deletions tests/rpl/Kconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
menu "PHY settings"
#comment "PHY settings"
config TX_POWER
int "Default TX Power"
default 0

config RADIO_CHANNEL
int "Default Radio Channel"
default 11

endmenu #Phy
rsource "../../firmware/network/rpl_protocol/Kconfig"
38 changes: 1 addition & 37 deletions tests/uniqueid/Kconfig
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
menu "Uniqueid"

config SELECT_HEADER_IPV6
bool "Edit IPV6 Header"
default n

menu "Change default IPV6 header"
visible if SELECT_HEADER_IPV6
#comment "Header using in unique cpuid address"

config HEADER_ADDRESS_ID
string "IPV6 HEADER"
default "2001:db8:"

endmenu # Change default IPV6 header

menu "Subnet"
choice IPV6_MODE
prompt "Select IPV6 Subnet mode"
config MODE_STATIC
bool "STATIC"

config MODE_RANDOM
bool "RANDOM"

config MODE_MANUAL
bool "MANUAL"

endchoice

config SUBNET_ADDRESS_ID
string "IPV6 SUBNET"
default "1111:2222"
depends on MODE_MANUAL

endmenu # Prefix
endmenu
rsource "../../firmware/sys/uniqueid/Kconfig"

0 comments on commit 422712f

Please sign in to comment.