-
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
[RFC] add olsr2 routing algorithm #765
Closed
Closed
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
b20fad3
add olsr2
benpicco 59b25c7
add metrics
benpicco c5e39cf
add olsr2 example application
benpicco 6db5324
add BOARD_WHITELIST to olsr2 example
benpicco 72f4ba5
remove unnecessary dependency tests
benpicco 83cb9f5
fix typo
benpicco 03114da
clean up example makefile
benpicco f6336cb
explicit module name is not needed anymore
benpicco 4094738
comments in constants.h
benpicco e75d7f9
prefix constants
benpicco fef2f23
don't overwrite DEBUG_H_
benpicco e00fcb3
get rid of capital letter in simple_list
benpicco 800ca64
doxygen for list.h
benpicco 0ccc9e1
prefix add_neighbor
benpicco 84014e5
added more parens
benpicco 9a5f005
add @author
benpicco f989a82
debug.h -> olsr_debug.h
benpicco 621a1f4
astyle --style=linux
benpicco 8d59a5f
define SECOND
benpicco 7d2fe2f
astyle --options=../../../../.astylerc *
benpicco 3654a1d
move list to sys/
benpicco 9635f8d
add single-linked list implementation
benpicco 50cd845
adapt to thread api changes
benpicco 598aa63
fix licence
benpicco bdad777
add test for slist
benpicco 44e2cd3
get rid of olsr_debug.h
benpicco eb29e39
[slist] explicit check for NULL
benpicco 4196a4d
explicit check for NULL
benpicco b2f6c02
style fixes
benpicco 97eaa4a
use cpuid_get() when availiable
benpicco dc53b2f
slist cleanup part 1
benpicco d482de8
slist cleanup pt2
benpicco 9a04ead
slist cleanup pt3
benpicco c9b2f5a
adapt to net api change
benpicco ad03d12
routing.h -> routing_table.h
benpicco ad42160
introduce new Makefile options
benpicco cc25083
silence warnings
benpicco ca235e4
fix merge conflict
benpicco 605f3b9
fix warnings in oonf_api
benpicco 68cc358
fix warning about printf type
benpicco a8e2b50
explain IF_ID
benpicco 1efb0f5
make nbuf static
benpicco 173bd7d
prefix local_name
benpicco 82ef757
pkg: copy Kijewski's container_of implementation
98cfc03
Add patches to fix the rest of the warnings
d6c6214
use msg_try_send
benpicco d44adc9
set address mode
benpicco 15b66ba
should be +=
benpicco 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 @@ | ||
export APPLICATION = olsr_node | ||
|
||
export BOARD ?= native | ||
export 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 | ||
|
||
export 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); | ||
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. Something like 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. ok |
||
} | ||
} | ||
#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 <benpicco@zedat.fu-berlin.de> | ||
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 <benpicco@zedat.fu-berlin.de> | ||
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 <h.v.bruinehsen@fu-berlin.de> | ||
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 | ||
+# 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 <h.v.bruinehsen@fu-berlin.de> | ||
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.
What does this flag do?
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.
I guess this describes the InterFace ID
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.
Ah, makes sense. The parser in my had saw the token
IF
and interpreted the line asif there is an ID? It's 0, hence there is none
. ;-)Maybe better be verbose?
#define INTERFACE_ID
?