-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
firmware: border_router setup() integration
- Loading branch information
Showing
5 changed files
with
103 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,13 @@ | ||
ifeq (,$(filter usbus_cdc_ecm,$(USEMODULE))) | ||
USEMODULE += usbus_cdc_ecm | ||
endif | ||
|
||
ifneq (,$(filter netdev_default,$(USEMODULE))) | ||
USEMODULE += netdev_default | ||
endif | ||
|
||
ifneq (,$(filter auto_init_usbus,$(USEMODULE))) | ||
USEMODULE += auto_init_usbus | ||
endif | ||
|
||
ifeq (,$(filter auto_init_gnrc_netif,$(USEMODULE))) | ||
USEMODULE += auto_init_gnrc_netif | ||
endif | ||
|
||
ifneq (,$(filter gnrc_icmpv6_error,$(USEMODULE))) | ||
USEMODULE += gnrc_icmpv6_error | ||
endif | ||
|
||
ifeq (,$(filter gnrc_sixlowpan_border_router_default,$(USEMODULE))) | ||
USEMODULE += gnrc_sixlowpan_border_router_default | ||
endif | ||
|
||
ifneq (,$(filter gnrc_udp,$(USEMODULE))) | ||
USEMODULE += gnrc_udp | ||
endif | ||
|
||
ifeq (,$(filter gnrc_icmpv6_echo,$(USEMODULE))) | ||
USEMODULE += gnrc_icmpv6_echo | ||
endif | ||
|
||
ifneq (,$(filter gnrc_ipv6_default,$(USEMODULE))) | ||
USEMODULE += gnrc_ipv6_default | ||
endif | ||
|
||
ifneq (,$(filter gnrc_netif_ieee802154,$(USEMODULE))) | ||
USEMODULE += gnrc_netif_ieee802154 | ||
endif | ||
|
||
ifeq (,$(filter radio,$(USEMODULE))) | ||
USEMODULE += radio | ||
endif | ||
|
||
ifeq (,$(filter net_tools,$(USEMODULE))) | ||
USEMODULE += net_tools | ||
endif | ||
USEMODULE += auto_init_gnrc_netif | ||
USEMODULE += auto_init_usbus | ||
USEMODULE += gnrc_icmpv6_echo | ||
USEMODULE += gnrc_icmpv6_error | ||
USEMODULE += gnrc_netif_ieee802154 | ||
USEMODULE += gnrc_sixlowpan_border_router_default | ||
USEMODULE += gnrc_udp | ||
USEMODULE += net_tools | ||
USEMODULE += netdev_default | ||
USEMODULE += radio | ||
USEMODULE += usbus_cdc_ecm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,10 @@ | |
* limitations under the License. | ||
*/ | ||
/** | ||
* @brief Border Radio. | ||
* @brief Border Router Module | ||
* | ||
* @author RocioRojas <[email protected]> | ||
* @author eduazocar <[email protected]> | ||
*/ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
@@ -38,51 +39,41 @@ int8_t get_wired_iface(void) { | |
return -1; | ||
} | ||
|
||
int border_router_add_ipv6(int cast_type, ipv6_addr_t *addr, uint8_t iface_type) { | ||
uint16_t flags = GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID; | ||
uint8_t prefix_len = _IPV6_DEFAULT_PREFIX_LEN; | ||
netif_t *iface = NULL; | ||
int8_t border_router_setup(ipv6_addr_t addr, uint8_t iface_type) { | ||
ipv6_addr_t ip; | ||
int8_t index; | ||
if (iface_type == WIRED_INTERFACE) { | ||
switch (iface_type) { | ||
case WIRED_INTERFACE: | ||
index = get_wired_iface(); | ||
} else if (iface_type == WIRELESS_INTERFACE) { | ||
break; | ||
case WIRELESS_INTERFACE: | ||
index = get_ieee802154_iface(); | ||
} else { | ||
break; | ||
default: | ||
printf("Error: Type of Interface doesn't exists File: %s, line: %d\n", __FILE__, __LINE__); | ||
return -1; | ||
} | ||
if (index == -1) { | ||
if (index < 0) { | ||
printf("Error: Expected interface wasn't found. File: %s, line %d\n", __FILE__, __LINE__); | ||
return -1; | ||
} | ||
if (get_ipv6_global(index, &ip) == 0) { | ||
printf("Error: Already exists an ipv6 Address File: %s, line: %d\n", __FILE__, __LINE__); | ||
return -1; | ||
} | ||
iface = netif_get_by_id(index); | ||
if (cast_type == _ANYCAST || cast_type == _UNICAST || cast_type == _MULTICAST) { | ||
if (cast_type == _MULTICAST) { | ||
if (ipv6_addr_is_multicast(addr)) { | ||
if (netif_set_opt(iface, NETOPT_IPV6_GROUP, 0, addr, sizeof(ipv6_addr_t)) < 0) { | ||
printf("error: unable to join IPv6 multicast group\n"); | ||
return -1; | ||
} | ||
} else { | ||
return -1; | ||
} | ||
} else { | ||
if (cast_type == _ANYCAST) { | ||
flags |= GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST; | ||
} | ||
flags |= (prefix_len << 8U); | ||
if (netif_set_opt(iface, NETOPT_IPV6_ADDR, flags, addr, sizeof(ipv6_addr_t)) < 0) { | ||
printf("error: unable to add IPv6 address\n"); | ||
return -1; | ||
} | ||
if (ipv6_addr_is_global(&addr)) { | ||
if (set_ipv6_global(index, addr) < 0) { | ||
return -1; | ||
} | ||
} else { | ||
return -1; | ||
return 0; | ||
} | ||
return 0; | ||
if (ipv6_addr_is_multicast(&addr)) { | ||
if (set_ipv6_multicast(index, addr) < 0) { | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
printf("Error: Only can be processed Unicast and Multicast Addresses. File: %s, line: %d\n", | ||
__FILE__, __LINE__); | ||
return -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,11 @@ | |
|
||
/** | ||
* @{ | ||
* @ingroup network | ||
* @ingroup border_router | ||
* @file border_router.h | ||
* @brief this module content all functions of Border Router | ||
* @author RocioRojas <[email protected]> | ||
* | ||
* @author eduazocar <[email protected]> | ||
*/ | ||
|
||
#ifndef BORDER_ROUTER_H | ||
|
@@ -32,23 +32,6 @@ | |
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
/** | ||
* @brief The default IPv6 prefix length if not specified. | ||
*/ | ||
#define _IPV6_DEFAULT_PREFIX_LEN (64U) | ||
|
||
/** | ||
* @brief List of cast types to the ipv6 address | ||
* | ||
*/ | ||
enum cast_t { | ||
_UNICAST = 0, /*!< Sets a process by which a packet is sent | ||
from one host to an individual host*/ | ||
_ANYCAST, /*!< Sets a method forwards messages to a single | ||
device of a specific group of devices. */ | ||
_MULTICAST /*!< Sets multicasting addresses messages for a | ||
specific group of devices in a network */ | ||
}; | ||
|
||
/** | ||
* @enum type_iface_t List of all types of Interface | ||
|
@@ -62,14 +45,15 @@ enum type_iface_t { | |
/**@}*/ | ||
|
||
/** | ||
* @brief This function it's set to border router to host. | ||
* @brief This function init the border router. sets ipv6 in an interface. | ||
* | ||
* @param[in] addr ipv6 address | ||
* @param[in] iface_type refers to if is used a WIRED or WIRELESS interface. | ||
* | ||
* @param [in] cast_type cast_type you want to set | ||
* @param [in] addr ipv6 address | ||
* @param [in] iface_type refers to if is used a WIRED or WIRELESS interface. | ||
* @return int | ||
* @retval 0 Setup Success | ||
* @retval -1 Setup Failed | ||
*/ | ||
int border_router_add_ipv6(int cast_type, ipv6_addr_t *addr, uint8_t iface_type); | ||
int8_t border_router_setup(ipv6_addr_t addr, uint8_t iface_type); | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters