-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
routing: add OLSRv2 #2294
Closed
Closed
routing: add OLSRv2 #2294
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
9f8fb47
add olsr2
benpicco c09baac
add metrics
benpicco aed2422
add olsr2 example application
benpicco 7654e2a
add BOARD_WHITELIST to olsr2 example
benpicco 0fc674d
remove unnecessary dependency tests
benpicco ed21054
fix typo
benpicco 838bb96
clean up example makefile
benpicco e575c61
explicit module name is not needed anymore
benpicco cc4d068
comments in constants.h
benpicco 63fd43e
prefix constants
benpicco dff04dc
don't overwrite DEBUG_H_
benpicco de76308
get rid of capital letter in simple_list
benpicco 608d211
doxygen for list.h
benpicco 1a58d8a
prefix add_neighbor
benpicco dca2f95
added more parens
benpicco f04ca05
add @author
benpicco 84567a1
debug.h -> olsr_debug.h
benpicco cf2febe
astyle --style=linux
benpicco 35ff52f
define SECOND
benpicco ff1ccac
astyle --options=../../../../.astylerc *
benpicco 2bfb3e7
move list to sys/
benpicco a7126f8
add single-linked list implementation
benpicco 0cf92a9
adapt to thread api changes
benpicco 21f176a
fix licence
benpicco 367fa9a
add test for slist
benpicco e29c6d0
get rid of olsr_debug.h
benpicco a68b76a
[slist] explicit check for NULL
benpicco 974d739
explicit check for NULL
benpicco 10f1695
style fixes
benpicco 8ec3265
use cpuid_get() when availiable
benpicco 2734d22
slist cleanup part 1
benpicco 9be6e21
slist cleanup pt2
benpicco 6804209
slist cleanup pt3
benpicco d38272a
adapt to net api change
benpicco 9a61bd4
routing.h -> routing_table.h
benpicco b8ccb7f
introduce new Makefile options
benpicco 291e9cc
silence warnings
benpicco 822ffa5
fix merge conflict
benpicco 469472f
fix warnings in oonf_api
benpicco 9ae960b
fix warning about printf type
benpicco 251540e
explain IF_ID
benpicco d2adbf8
make nbuf static
benpicco 66a9974
prefix local_name
benpicco 4cfc515
pkg: copy Kijewski's container_of implementation
64ca5f9
Add patches to fix the rest of the warnings
c65cd85
use msg_try_send
benpicco d99a2c1
set address mode
benpicco b1987b6
should be +=
benpicco a8faf5f
SQUASH ME: remove exports from application Makefile
OlegHahm d779e1f
olsr2: added extern c to headers
OlegHahm 696b96e
SQUASH ME: removed unnecessary dependencies
OlegHahm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
APPLICATION = olsr_node | ||
|
||
BOARD ?= native | ||
RIOTBASE ?= $(CURDIR)/../.. | ||
|
||
# other toolchains lack assert.h used by oonf_api | ||
BOARD_WHITELIST := avsextrem msba2 native | ||
|
||
# Comment this out to disable code in RIOT that does safety checking | ||
# which is not needed in a production environment but helps in the | ||
# development process: | ||
CFLAGS += -DDEVELHELP | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
USEPKG += oonf_api | ||
|
||
CFLAGS += -DRIOT -DENABLE_NAME | ||
|
||
# Modules to include. | ||
USEMODULE += rtc | ||
USEMODULE += uart0 | ||
USEMODULE += posix | ||
USEMODULE += ps | ||
USEMODULE += shell | ||
USEMODULE += shell_commands | ||
USEMODULE += random | ||
USEMODULE += config | ||
USEMODULE += olsr2 | ||
USEMODULE += defaulttransceiver | ||
|
||
# on msba2 and avsextrem cpuid_get is not implemented | ||
ifneq (,$(filter $(BOARD), msba2 avsextrem)) | ||
export CFLAGS += -DENABLE_LEDS -DHAVE_NO_CPUID | ||
endif | ||
|
||
include $(RIOTBASE)/Makefile.include |
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 |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* Copyright (C) 2014 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser General | ||
* Public License v2.1. See the file LICENSE in the top level directory for more | ||
* details. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <thread.h> | ||
#include <vtimer.h> | ||
#include <rtc.h> | ||
#include <random.h> | ||
#include <socket_base/socket.h> | ||
#include <transceiver.h> | ||
#include <sixlowpan/icmp.h> | ||
|
||
#include <shell.h> | ||
#include <posix_io.h> | ||
#include <board_uart0.h> | ||
|
||
#include <olsr2/olsr2.h> | ||
|
||
/* Interface ID */ | ||
#define IF_ID (0) | ||
|
||
#ifdef HAVE_NO_CPUID | ||
#include <config.h> | ||
|
||
static uint32_t get_node_id(void) { | ||
return sysconfig.id; | ||
} | ||
|
||
#else /* CPU ID availiable */ | ||
#include <periph/cpuid.h> | ||
|
||
static uint32_t get_node_id(void) { | ||
uint32_t cpuid = 0; | ||
cpuid_get(&cpuid); | ||
return cpuid; | ||
} | ||
|
||
#endif /* get_node_id */ | ||
|
||
#ifdef ENABLE_NAME | ||
|
||
static void ping(int argc, char **argv) { | ||
static uint16_t id = 0; | ||
|
||
if (argc < 2) { | ||
puts("usage: ping [node]"); | ||
return; | ||
} | ||
|
||
id++; | ||
int packets = 10; | ||
|
||
ipv6_addr_t* dest = get_ip_by_name(argv[1]); | ||
if (dest == NULL) { | ||
printf("Unknown node: %s\n", argv[1]); | ||
return; | ||
} | ||
|
||
char addr_str[IPV6_MAX_ADDR_STR_LEN]; | ||
ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, dest); | ||
|
||
uint8_t payload[] = "foobar"; | ||
|
||
for (int i = 0; i < packets; ++i) { | ||
printf("sending %u bytes to %s\n", sizeof payload, addr_str); | ||
icmpv6_send_echo_request(dest, id, i, payload, sizeof payload); | ||
vtimer_usleep(1000000); | ||
} | ||
} | ||
#endif /* ENABLE_NAME */ | ||
|
||
static void set_id(int argc, char **argv) { | ||
if (argc < 2) { | ||
puts("usage: set_id [id] [name]"); | ||
return; | ||
} | ||
|
||
uint16_t id = atoi(argv[1]); | ||
sysconfig.id = id; | ||
sysconfig.radio_address = (uint8_t) id; | ||
|
||
#ifdef ENABLE_NAME | ||
if (argc > 2) | ||
strncpy(sysconfig.name, argv[2], CONFIG_NAME_LEN); | ||
#endif | ||
config_save(); | ||
} | ||
|
||
static void print_routes(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) { | ||
print_topology_set(); | ||
} | ||
|
||
static void init(void) { | ||
ipv6_addr_t tmp; | ||
|
||
rtc_enable(); | ||
genrand_init(get_node_id()); | ||
net_if_set_src_address_mode(IF_ID, NET_IF_TRANS_ADDR_M_SHORT); | ||
net_if_set_hardware_address(IF_ID, get_node_id()); | ||
|
||
ipv6_addr_set_link_local_prefix(&tmp); | ||
ipv6_addr_set_by_eui64(&tmp, IF_ID, &tmp); | ||
ipv6_net_if_add_addr(IF_ID, &tmp, NDP_ADDR_STATE_PREFERRED, | ||
NDP_OPT_PI_VLIFETIME_INFINITE, | ||
NDP_OPT_PI_PLIFETIME_INFINITE, 0); | ||
|
||
ipv6_addr_set_all_nodes_addr(&tmp); | ||
ipv6_net_if_add_addr(IF_ID, &tmp, NDP_ADDR_STATE_PREFERRED, | ||
NDP_OPT_PI_VLIFETIME_INFINITE, | ||
NDP_OPT_PI_PLIFETIME_INFINITE, 0); | ||
|
||
olsr_init(); | ||
} | ||
|
||
const shell_command_t shell_commands[] = { | ||
{"routes", "print all known nodes and routes", print_routes}, | ||
{"set_id", "set node ID and name", set_id}, | ||
#ifdef ENABLE_NAME | ||
{"ping", "send packets to a node", ping}, | ||
#endif | ||
{NULL, NULL, NULL} | ||
}; | ||
|
||
int main(void) { | ||
init(); | ||
|
||
posix_open(uart0_handler_pid, 0); | ||
|
||
shell_t shell; | ||
shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc); | ||
|
||
shell_run(&shell); | ||
|
||
return 0; | ||
} |
29 changes: 29 additions & 0 deletions
29
pkg/oonf_api/0005-only-define-container_of-when-necessary.patch
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From d81d24b9d4c897c508799cb390b13cb018758709 Mon Sep 17 00:00:00 2001 | ||
From: Benjamin Valentin <[email protected]> | ||
Date: Fri, 10 Oct 2014 02:05:01 +0200 | ||
Subject: [PATCH] only define container_of when necessary | ||
|
||
--- | ||
src-api/common/container_of.h | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/src-api/common/container_of.h b/src-api/common/container_of.h | ||
index 9fd1893..fcb38fe 100644 | ||
--- a/src-api/common/container_of.h | ||
+++ b/src-api/common/container_of.h | ||
@@ -58,10 +58,12 @@ | ||
* @param member name of node inside struct | ||
* @return pointer to surrounding struct | ||
*/ | ||
+#ifndef container_of | ||
#define container_of(ptr, type, member) ({ \ | ||
const typeof(((type *)0)->member ) *__tempptr = (ptr); \ | ||
(type *)((char *)__tempptr - offsetof(type,member)); \ | ||
}) | ||
+#endif | ||
|
||
/** | ||
* Helper function for NULL safe container_of macro | ||
-- | ||
1.9.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From 40651f114bd6e1b4b2ebc89bdf8fb06d1243eb55 Mon Sep 17 00:00:00 2001 | ||
From: Benjamin Valentin <[email protected]> | ||
Date: Fri, 10 Oct 2014 02:08:32 +0200 | ||
Subject: [PATCH] if_index is not used | ||
|
||
--- | ||
src-api/common/netaddr.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/src-api/common/netaddr.c b/src-api/common/netaddr.c | ||
index ed44341..fa528ca 100644 | ||
--- a/src-api/common/netaddr.c | ||
+++ b/src-api/common/netaddr.c | ||
@@ -319,7 +319,7 @@ netaddr_create_host_bin(struct netaddr *host, const struct netaddr *netmask, | ||
*/ | ||
int | ||
netaddr_socket_init(union netaddr_socket *combined, const struct netaddr *addr, | ||
- uint16_t port, unsigned if_index) { | ||
+ uint16_t port, unsigned if_index __attribute__((unused))) { | ||
/* initialize memory block */ | ||
memset(combined, 0, sizeof(*combined)); | ||
|
||
-- | ||
1.9.1 | ||
|
45 changes: 45 additions & 0 deletions
45
pkg/oonf_api/0007-Use-RIOT-s-container_of-implementation.patch
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
From b2ad2073ac282f1bc6315e47ffbd12c3f6a9ae1a Mon Sep 17 00:00:00 2001 | ||
From: Hinnerk van Bruinehsen <[email protected]> | ||
Date: Wed, 29 Oct 2014 11:37:05 +0100 | ||
Subject: [PATCH] Use RIOT's container_of implementation | ||
|
||
--- | ||
src-api/common/container_of.h | 22 ++++++++++++++++++---- | ||
1 file changed, 18 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/src-api/common/container_of.h b/src-api/common/container_of.h | ||
index fcb38fe..b49d836 100644 | ||
--- a/src-api/common/container_of.h | ||
+++ b/src-api/common/container_of.h | ||
@@ -59,10 +59,24 @@ | ||
* @return pointer to surrounding struct | ||
*/ | ||
#ifndef container_of | ||
-#define container_of(ptr, type, member) ({ \ | ||
- const typeof(((type *)0)->member ) *__tempptr = (ptr); \ | ||
- (type *)((char *)__tempptr - offsetof(type,member)); \ | ||
- }) | ||
+#if __STDC_VERSION__ >= 201112L | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quick question: why is this the same as in core/include/kernel_macros.h. Is it possible to reduce the redundance anywhere? |
||
+# define container_of(PTR, TYPE, MEMBER) \ | ||
+ (_Generic((PTR), \ | ||
+ const __typeof__ (((TYPE *) 0)->MEMBER) *: \ | ||
+ ((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))), \ | ||
+ __typeof__ (((TYPE *) 0)->MEMBER) *: \ | ||
+ ((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))) \ | ||
+ )) | ||
+#elif defined __GNUC__ | ||
+# define container_of(PTR, TYPE, MEMBER) \ | ||
+ (__extension__ ({ \ | ||
+ __extension__ const __typeof__ (((TYPE *) 0)->MEMBER) *__m____ = (PTR); \ | ||
+ ((TYPE *) ((char *) __m____ - offsetof(TYPE, MEMBER))); \ | ||
+ })) | ||
+#else | ||
+# define container_of(PTR, TYPE, MEMBER) \ | ||
+ ((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))) | ||
+#endif | ||
#endif | ||
|
||
/** | ||
-- | ||
2.1.2 | ||
|
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
From e590e6f26b115da34a943fd4ed6d4c93fd2c64d0 Mon Sep 17 00:00:00 2001 | ||
From: Hinnerk van Bruinehsen <[email protected]> | ||
Date: Wed, 29 Oct 2014 12:05:11 +0100 | ||
Subject: [PATCH] Dissolve enum into single defines | ||
|
||
--- | ||
src-api/rfc5444/rfc5444.h | 26 ++++++++++++-------------- | ||
1 file changed, 12 insertions(+), 14 deletions(-) | ||
|
||
diff --git a/src-api/rfc5444/rfc5444.h b/src-api/rfc5444/rfc5444.h | ||
index c5d6420..6b5576e 100644 | ||
--- a/src-api/rfc5444/rfc5444.h | ||
+++ b/src-api/rfc5444/rfc5444.h | ||
@@ -43,25 +43,23 @@ | ||
|
||
#include "common/common_types.h" | ||
|
||
-enum { | ||
- /* timetlv_max = 14 * 2^28 * 1000 / 1024 = 14000 << 18 = 3 670 016 000 ms */ | ||
- RFC5444_TIMETLV_MAX = 0xdac00000, | ||
+/* timetlv_max = 14 * 2^28 * 1000 / 1024 = 14000 << 18 = 3 670 016 000 ms */ | ||
+#define RFC5444_TIMETLV_MAX 0xdac00000 | ||
|
||
- /* timetlv_min = 1000/1024 ms */ | ||
- RFC5444_TIMETLV_MIN = 0x00000001, | ||
+/* timetlv_min = 1000/1024 ms */ | ||
+#define RFC5444_TIMETLV_MIN 0x00000001 | ||
|
||
- /* metric_max = 1<<24 - 256 */ | ||
- RFC5444_METRIC_MAX = 0xffff00, | ||
+/* metric_max = 1<<24 - 256 */ | ||
+#define RFC5444_METRIC_MAX 0xffff00 | ||
|
||
- /* metric_min = 1 */ | ||
- RFC5444_METRIC_MIN = 0x000001, | ||
+/* metric_min = 1 */ | ||
+#define RFC5444_METRIC_MIN 0x000001 | ||
|
||
- /* larger than possible metric value */ | ||
- RFC5444_METRIC_INFINITE = 0xffffff, | ||
+/* larger than possible metric value */ | ||
+#define RFC5444_METRIC_INFINITE 0xffffff | ||
|
||
- /* infinite path cost */ | ||
- RFC5444_METRIC_INFINITE_PATH = 0xffffffff, | ||
-}; | ||
+/* infinite path cost */ | ||
+#define RFC5444_METRIC_INFINITE_PATH 0xffffffff | ||
|
||
EXPORT uint8_t rfc5444_timetlv_get_from_vector( | ||
uint8_t *vector, size_t vector_length, uint8_t hopcount); | ||
-- | ||
2.1.2 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the diff of this file could be completely moved to its own PR. seems unrelated to OLSR to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍