Skip to content
Merged
2 changes: 2 additions & 0 deletions include/net/net_l2.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ NET_L2_DECLARE_PUBLIC(IEEE802154_L2);
#ifdef CONFIG_NET_L2_BT
#define BLUETOOTH_L2 BLUETOOTH
#define BLUETOOTH_L2_CTX_TYPE void*
NET_L2_DECLARE_PUBLIC(BLUETOOTH_L2);
#endif /* CONFIG_NET_L2_BT */

#ifdef CONFIG_NET_OFFLOAD
#define OFFLOAD_IP_L2 OFFLOAD_IP
#define OFFLOAD_IP_L2_CTX_TYPE void*
NET_L2_DECLARE_PUBLIC(OFFLOAD_IP);
#endif /* CONFIG_NET_OFFLOAD */

extern struct net_l2 __net_l2_end[];
Expand Down
30 changes: 30 additions & 0 deletions subsys/net/ip/Kconfig.rpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ menuconfig NET_RPL

if NET_RPL

config NET_RPL_PREFIX
string "Network IPv6 prefix"
help
What is the DAG id (prefix) of the RPL network. This is only used
if you are creating a root node. You should specify here the full
IPv6 address as that is used as a root node address.
Example: 2001:db8::1/64

choice
prompt "Network type"
default NET_RPL_L2_ANY
default NET_RPL_L2_IEEE802154 if NET_L2_IEEE802154
help
The type of the network that this RPL device is supporting.
Currently all the nodes in the network need to be the same type
like IEEE 802.15.4.

config NET_RPL_L2_ANY
bool "Any network type"

config NET_RPL_L2_IEEE802154
bool "IEEE 802.15.4"
endchoice

choice
prompt "Objective function"
default NET_RPL_MRHOF
Expand Down Expand Up @@ -99,6 +123,12 @@ config NET_RPL_MAX_DAG_PER_INSTANCE
help
This determines how many DAG to allocate within one RPL instance.

config NET_RPL_MAX_PARENTS
int "Maximum number of parents for one node"
default NET_IPV6_MAX_NEIGHBORS
help
This determines how many RPL parents each node can have.

config NET_RPL_DAO_SPECIFY_DAG
bool "Specify DAG when sending a DAO message."
depends on NET_RPL
Expand Down
8 changes: 4 additions & 4 deletions subsys/net/ip/nbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct net_nbr *net_nbr_get(struct net_nbr_table *table)
{
int i;

for (i = 0; i < CONFIG_NET_IPV6_MAX_NEIGHBORS; i++) {
for (i = 0; i < table->nbr_count; i++) {
struct net_nbr *nbr = get_nbr(table->nbr, i);

if (!nbr->ref) {
Expand Down Expand Up @@ -164,7 +164,7 @@ struct net_nbr *net_nbr_lookup(struct net_nbr_table *table,
{
int i;

for (i = 0; i < CONFIG_NET_IPV6_MAX_NEIGHBORS; i++) {
for (i = 0; i < table->nbr_count; i++) {
struct net_nbr *nbr = get_nbr(table->nbr, i);

if (nbr->ref && nbr->iface == iface &&
Expand All @@ -191,7 +191,7 @@ void net_nbr_clear_table(struct net_nbr_table *table)
{
int i;

for (i = 0; i < CONFIG_NET_IPV6_MAX_NEIGHBORS; i++) {
for (i = 0; i < table->nbr_count; i++) {
struct net_nbr *nbr = get_nbr(table->nbr, i);
struct net_linkaddr lladdr = {
.addr = net_neighbor_lladdr[i].lladdr.addr,
Expand All @@ -211,7 +211,7 @@ void net_nbr_print(struct net_nbr_table *table)
{
int i;

for (i = 0; i < CONFIG_NET_IPV6_MAX_NEIGHBORS; i++) {
for (i = 0; i < table->nbr_count; i++) {
struct net_nbr *nbr = get_nbr(table->nbr, i);

if (!nbr->ref) {
Expand Down
4 changes: 4 additions & 0 deletions subsys/net/ip/nbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct net_nbr_table {

/** Function to be called when the table is cleared. */
void (*const clear)(struct net_nbr_table *table);

/** Max number of neighbors in the pool */
const u16_t nbr_count;
};

#define NET_NBR_LOCAL static
Expand All @@ -108,6 +111,7 @@ struct net_nbr_table {
.table = { \
.clear = _clear, \
.nbr = (struct net_nbr *)_pool, \
.nbr_count = ARRAY_SIZE(_pool), \
} \
}

Expand Down
2 changes: 1 addition & 1 deletion subsys/net/ip/net_pkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

#if defined(CONFIG_NET_DEBUG_NET_PKT)
#define SYS_LOG_DOMAIN "net/net_pkt"
#define SYS_LOG_DOMAIN "net/pkt"
#define NET_LOG_ENABLED 1
#endif

Expand Down
103 changes: 92 additions & 11 deletions subsys/net/ip/net_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,65 @@ static inline const char *addrstate2str(enum net_addr_state addr_state)
return "<invalid state>";
}

static const char *iface2str(struct net_if *iface, const char **extra)
{
#ifdef CONFIG_NET_L2_IEEE802154
if (iface->l2 == &NET_L2_GET_NAME(IEEE802154)) {
if (extra) {
*extra = "=============";
}

return "IEEE 802.15.4";
}
#endif

#ifdef CONFIG_NET_L2_ETHERNET
if (iface->l2 == &NET_L2_GET_NAME(ETHERNET)) {
if (extra) {
*extra = "========";
}

return "Ethernet";
}
#endif

#ifdef CONFIG_NET_L2_DUMMY
if (iface->l2 == &NET_L2_GET_NAME(DUMMY)) {
if (extra) {
*extra = "=====";
}

return "Dummy";
}
#endif

#ifdef CONFIG_NET_L2_BT
if (iface->l2 == &NET_L2_GET_NAME(BLUETOOTH)) {
if (extra) {
*extra = "=========";
}

return "Bluetooth";
}
#endif

#ifdef CONFIG_NET_L2_OFFLOAD
if (iface->l2 == &NET_L2_GET_NAME(OFFLOAD_IP)) {
if (extra) {
*extra = "==========";
}

return "IP Offload";
}
#endif

if (extra) {
*extra = "==============";
}

return "<unknown type>";
}

static void iface_cb(struct net_if *iface, void *user_data)
{
#if defined(CONFIG_NET_IPV6)
Expand All @@ -99,12 +158,13 @@ static void iface_cb(struct net_if *iface, void *user_data)
#endif
struct net_if_addr *unicast;
struct net_if_mcast_addr *mcast;
const char *extra;
int i, count;

ARG_UNUSED(user_data);

printk("Interface %p\n", iface);
printk("====================\n");
printk("Interface %p (%s)\n", iface, iface2str(iface, &extra));
printk("=======================%s\n", extra);

if (!net_if_is_up(iface)) {
printk("Interface is down.\n");
Expand Down Expand Up @@ -304,10 +364,13 @@ static void route_cb(struct net_route_entry *entry, void *user_data)

static void iface_per_route_cb(struct net_if *iface, void *user_data)
{
const char *extra;

ARG_UNUSED(user_data);

printk("IPv6 routes for interface %p\n", iface);
printk("====================================\n");
printk("IPv6 routes for interface %p (%s)\n", iface,
iface2str(iface, &extra));
printk("=======================================%s\n", extra);

net_route_foreach(route_cb, iface);
}
Expand All @@ -318,13 +381,16 @@ static void route_mcast_cb(struct net_route_entry_mcast *entry,
void *user_data)
{
struct net_if *iface = user_data;
const char *extra;

if (entry->iface != iface) {
return;
}

printk("IPv6 multicast route %p for interface %p\n", entry, iface);
printk("========================================================\n");
printk("IPv6 multicast route %p for interface %p (%s)\n", entry,
iface, iface2str(iface, &extra));
printk("==========================================================="
"%s\n", extra);

printk("IPv6 group : %s\n", net_sprint_ipv6_addr(&entry->group));
printk("Lifetime : %u\n", entry->lifetime);
Expand Down Expand Up @@ -1673,16 +1739,31 @@ static void rpl_parent(struct net_rpl_parent *parent, void *user_data)
int *count = user_data;

if (*count == 0) {
printk(" Parent Last TX Rank DTSN Flags\tAddress\n");
printk(" Parent Last TX Rank DTSN Flags DAG\t\t\t"
"Address\n");
}

(*count)++;

if (parent->dag) {
printk("[%2d] %p %10d %2d %d 0x%08x %s\n",
*count, parent, parent->last_tx_time, parent->rank,
struct net_ipv6_nbr_data *data;
char addr[NET_IPV6_ADDR_LEN];

data = net_rpl_get_ipv6_nbr_data(parent);
if (data) {
snprintk(addr, sizeof(addr), "%s",
net_sprint_ipv6_addr(&data->addr));
} else {
snprintk(addr, sizeof(addr), "<unknown>");
}

printk("[%2d]%s %p %7d %5d %3d 0x%02x %s\t%s\n",
*count,
parent->dag->preferred_parent == parent ? "*" : " ",
parent, parent->last_tx_time, parent->rank,
parent->dtsn, parent->flags,
net_sprint_ipv6_addr(&parent->dag->dag_id));
net_sprint_ipv6_addr(&parent->dag->dag_id),
addr);
}
}

Expand Down Expand Up @@ -1783,7 +1864,7 @@ int net_shell_cmd_rpl(int argc, char *argv[])
instance, instance->is_used ? "active" : "disabled");

if (instance->default_route) {
printk("Default route : %s\n",
printk("Default route : %s\n",
net_sprint_ipv6_addr(
&instance->default_route->address.in6_addr));
}
Expand Down
Loading