0001-add-RIOT-support.patch
8.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
From 9e99bc8ed9f4e4d326a14589ad29607fef89e3a5 Mon Sep 17 00:00:00 2001
From: Benjamin Valentin <benpicco@zedat.fu-berlin.de>
Date: Wed, 5 Feb 2014 20:01:41 +0100
Subject: [PATCH 01/10] add RIOT support
---
Makefile | 29 ++++++++++++++++++++
external/regex/Makefile | 4 +++
src-api/common/Makefile | 3 +++
src-api/common/autobuf.c | 6 +++++
src-api/common/common_types.h | 5 ++++
src-api/common/daemonize.c | 2 +-
src-api/common/netaddr.c | 11 +++++++-
src-api/common/netaddr.h | 2 ++
src-api/rfc5444/Makefile | 3 +++
src-api/rfc5444/rfc5444_api_config.h | 51 ++++++++++++++++++++++++++++++++++++
10 files changed, 114 insertions(+), 2 deletions(-)
create mode 100644 Makefile
create mode 100644 external/regex/Makefile
create mode 100644 src-api/common/Makefile
create mode 100644 src-api/rfc5444/Makefile
create mode 100644 src-api/rfc5444/rfc5444_api_config.h
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1f1cd9c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,29 @@
+#
+# to use oonf_api in your RIOT project,
+# add the following to your Makefile:
+#
+# export OONFBASE = /path/to/this/directory
+# EXTERNAL_MODULES += $(OONFBASE)
+#
+# this provides the following modules:
+# oonf_common - avl tree, list, netaddr, regex, string functions
+# oonf_rfc5444 - packetBB implementation, requires oonf_common
+
+ifneq (,$(filter oonf_common,$(USEMODULE)))
+ DIRS += src-api/common
+endif
+ifneq (,$(filter oonf_rfc5444,$(USEMODULE)))
+ DIRS += src-api/rfc5444
+endif
+ifneq (,$(filter oonf_cunit,$(USEMODULE)))
+ DIRS += tests/cunit
+endif
+ifneq (,$(filter oonf_regex,$(USEMODULE)))
+ DIRS += external/regex
+endif
+
+all:
+ mkdir -p $(BINDIR)
+ @for i in $(DIRS) ; do $(MAKE) -C $$i || exit 1; done ;
+
+clean:
diff --git a/external/regex/Makefile b/external/regex/Makefile
new file mode 100644
index 0000000..3bc1ce1
--- /dev/null
+++ b/external/regex/Makefile
@@ -0,0 +1,4 @@
+MODULE:=oonf_$(shell basename $(CURDIR))
+INCLUDES += $(CURDIR)/..
+
+include $(RIOTBASE)/Makefile.base
diff --git a/src-api/common/Makefile b/src-api/common/Makefile
new file mode 100644
index 0000000..5e0046d
--- /dev/null
+++ b/src-api/common/Makefile
@@ -0,0 +1,3 @@
+MODULE:=oonf_$(shell basename $(CURDIR))
+
+include $(RIOTBASE)/Makefile.base
diff --git a/src-api/common/autobuf.c b/src-api/common/autobuf.c
index 77c519b..37e77ac 100644
--- a/src-api/common/autobuf.c
+++ b/src-api/common/autobuf.c
@@ -51,6 +51,12 @@
#include <winsock2.h>
#endif
+#ifdef RIOT_VERSION
+int getpagesize(void) {
+ return 512;
+}
+#endif
+
#include "common/autobuf.h"
/**
diff --git a/src-api/common/common_types.h b/src-api/common/common_types.h
index c90cf46..b5f170a 100644
--- a/src-api/common/common_types.h
+++ b/src-api/common/common_types.h
@@ -77,6 +77,11 @@
#define PRINTF_SIZE_T_HEX_SPECIFIER "Ix"
#define PRINTF_SSIZE_T_SPECIFIER "Id"
#define PRINTF_PTRDIFF_T_SPECIFIER "Id"
+#elif defined(RIOT_VERSION)
+ #define PRINTF_SIZE_T_SPECIFIER "d"
+ #define PRINTF_SIZE_T_HEX_SPECIFIER "x"
+ #define PRINTF_SSIZE_T_SPECIFIER "d"
+ #define PRINTF_PTRDIFF_T_SPECIFIER "d"
#elif defined(__GNUC__)
#define PRINTF_SIZE_T_SPECIFIER "zu"
#define PRINTF_SIZE_T_HEX_SPECIFIER "zx"
diff --git a/src-api/common/daemonize.c b/src-api/common/daemonize.c
index 103c88f..8a6cd2b 100644
--- a/src-api/common/daemonize.c
+++ b/src-api/common/daemonize.c
@@ -48,7 +48,7 @@
#include "common/common_types.h"
#include "common/daemonize.h"
-#ifndef WIN32
+#if (!defined(_WIN32)) && (!defined(RIOT_VERSION))
/**
* Prepare the start of a daemon. Fork into background,
* but keep stdin/out/err open and a pipe connected to
diff --git a/src-api/common/netaddr.c b/src-api/common/netaddr.c
index dedab2c..6b214ee 100644
--- a/src-api/common/netaddr.c
+++ b/src-api/common/netaddr.c
@@ -43,7 +43,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef RIOT_VERSION
#include <net/if.h>
+#else
+#define DONT_HAVE_SIN6_SCOPE_ID
+#endif
#include "common/common_types.h"
#include "common/string.h"
@@ -326,7 +330,9 @@ netaddr_socket_init(union netaddr_socket *combined, const struct netaddr *addr,
/* ipv6 */
memcpy(&combined->v6.sin6_addr, addr->_addr, 16);
combined->v6.sin6_port = htons(port);
+#ifndef DONT_HAVE_SIN6_SCOPE_ID
combined->v6.sin6_scope_id = if_index;
+#endif
break;
default:
/* unknown address type */
@@ -561,6 +567,7 @@ netaddr_socket_to_string(struct netaddr_str *dst, const union netaddr_socket *sr
ntohs(src->v4.sin_port));
}
else if (src->std.sa_family == AF_INET6) {
+#ifndef DONT_HAVE_SIN6_SCOPE_ID
if (src->v6.sin6_scope_id) {
char scope_buf[IF_NAMESIZE];
@@ -569,7 +576,9 @@ netaddr_socket_to_string(struct netaddr_str *dst, const union netaddr_socket *sr
ntohs(src->v6.sin6_port),
if_indextoname(src->v6.sin6_scope_id, scope_buf));
}
- else {
+ else
+#endif
+ {
snprintf(dst->buf, sizeof(*dst), "[%s]:%d",
inet_ntop(AF_INET6, &src->v6.sin6_addr, buf.buf, sizeof(buf)),
ntohs(src->v6.sin6_port));
diff --git a/src-api/common/netaddr.h b/src-api/common/netaddr.h
index 78fd5b4..cc8189c 100644
--- a/src-api/common/netaddr.h
+++ b/src-api/common/netaddr.h
@@ -45,9 +45,11 @@
#ifndef _WIN32
#include <arpa/inet.h>
+#ifndef RIOT_VERSION
#include <netinet/if_ether.h>
#include <netinet/ip.h>
#include <net/if.h>
+#endif
#else
#include <winsock2.h>
#include <ws2tcpip.h>
diff --git a/src-api/rfc5444/Makefile b/src-api/rfc5444/Makefile
new file mode 100644
index 0000000..5e0046d
--- /dev/null
+++ b/src-api/rfc5444/Makefile
@@ -0,0 +1,3 @@
+MODULE:=oonf_$(shell basename $(CURDIR))
+
+include $(RIOTBASE)/Makefile.base
diff --git a/src-api/rfc5444/rfc5444_api_config.h b/src-api/rfc5444/rfc5444_api_config.h
new file mode 100644
index 0000000..9bf6622
--- /dev/null
+++ b/src-api/rfc5444/rfc5444_api_config.h
@@ -0,0 +1,51 @@
+
+/*
+ * The olsr.org Optimized Link-State Routing daemon(olsrd)
+ * Copyright (c) 2004-2012, the olsr.org team - see HISTORY file
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ */
+
+#ifndef RFC5444_API_CONFIG_H_
+#define RFC5444_API_CONFIG_H_
+
+#define DISALLOW_CONSUMER_CONTEXT_DROP false
+#define WRITER_STATE_MACHINE true
+#define DEBUG_CLEANUP true
+#define DO_ADDR_COMPRESSION true
+#define CLEAR_ADDRESS_POSTFIX false
+
+#endif /* RFC5444_API_CONFIG_H_ */
--
1.9.1