Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
9ce1c6df
You need to sign in or sign up before continuing.
Commit
9ce1c6df
authored
9 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
nhdp: use conn instead of socket_base
parent
fda61550
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile.dep
+7
-6
7 additions, 6 deletions
Makefile.dep
sys/net/routing/nhdp/nhdp.c
+19
-18
19 additions, 18 deletions
sys/net/routing/nhdp/nhdp.c
sys/net/routing/nhdp/nhdp.h
+0
-1
0 additions, 1 deletion
sys/net/routing/nhdp/nhdp.h
with
26 additions
and
25 deletions
Makefile.dep
+
7
−
6
View file @
9ce1c6df
...
...
@@ -6,6 +6,13 @@ ifneq (,$(filter pnet,$(USEMODULE)))
USEMODULE
+=
vtimer
endif
ifneq
(,$(filter nhdp,$(USEMODULE)))
USEMODULE
+=
conn_udp
USEMODULE
+=
vtimer
USEMODULE
+=
oonf_common
USEMODULE
+=
oonf_rfc5444
endif
ifneq
(,$(filter gnrc_%,$(filter-out gnrc_netapi gnrc_netreg gnrc_netif% gnrc_pktbuf,$(USEMODULE))))
USEMODULE
+=
gnrc
endif
...
...
@@ -294,12 +301,6 @@ ifneq (,$(filter libfixmath-unittests,$(USEMODULE)))
USEPKG
+=
libfixmath
endif
ifneq
(,$(filter nhdp,$(USEMODULE)))
USEMODULE
+=
vtimer
USEMODULE
+=
oonf_common
USEMODULE
+=
oonf_rfc5444
endif
ifneq
(,$(filter fib,$(USEMODULE)))
USEMODULE
+=
universal_address
USEMODULE
+=
xtimer
...
...
This diff is collapsed.
Click to expand it.
sys/net/routing/nhdp/nhdp.c
+
19
−
18
View file @
9ce1c6df
...
...
@@ -18,6 +18,7 @@
* @}
*/
#include
"conn/udp.h"
#include
"msg.h"
#include
"netapi.h"
#include
"net/gnrc/netif.h"
...
...
@@ -35,6 +36,10 @@
#include
"nhdp_writer.h"
#include
"nhdp_reader.h"
#ifndef MODULE_CONN_UDP
#error "nhdp needs a conn_udp implementation to work"
#endif
char
nhdp_stack
[
NHDP_STACK_SIZE
];
char
nhdp_rcv_stack
[
NHDP_STACK_SIZE
];
...
...
@@ -44,8 +49,7 @@ static kernel_pid_t nhdp_rcv_pid = KERNEL_PID_UNDEF;
static
kernel_pid_t
helper_pid
=
KERNEL_PID_UNDEF
;
static
nhdp_if_entry_t
nhdp_if_table
[
GNRC_NETIF_NUMOF
];
static
mutex_t
send_rcv_mutex
=
MUTEX_INIT
;
static
sockaddr6_t
sa_bcast
;
static
int
sock_rcv
;
static
conn_udp_t
conn
;
#if (NHDP_METRIC_NEEDS_TIMER)
static
vtimer_t
metric_timer
;
...
...
@@ -85,12 +89,6 @@ kernel_pid_t nhdp_start(void)
{
if
(
nhdp_pid
==
KERNEL_PID_UNDEF
)
{
/* Init destination address for NHDP's packets */
sa_bcast
.
sin6_family
=
AF_INET6
;
sa_bcast
.
sin6_port
=
HTONS
(
MANET_PORT
);
ipv6_addr_set_all_nodes_addr
(
&
sa_bcast
.
sin6_addr
);
/* Configure sending/receiving UDP socket */
sock_rcv
=
socket_base_socket
(
AF_INET6
,
SOCK_DGRAM
,
IPPROTO_UDP
);
/* Start the NHDP thread */
nhdp_pid
=
thread_create
(
nhdp_stack
,
sizeof
(
nhdp_stack
),
THREAD_PRIORITY_MAIN
-
1
,
...
...
@@ -293,20 +291,20 @@ static void *_nhdp_receiver(void *arg __attribute__((unused)))
msg_init_queue
(
msg_q
,
NHDP_MSG_QUEUE_SIZE
);
/* Configure socket address for the manet port 269 */
sockaddr6_t
sa_rcv
=
{.
sin6_family
=
AF_INET6
,
.
sin6_port
=
HTONS
(
MANET_PORT
)
};
ipv6_addr_t
unspec
=
IPV6_ADDR_UNSPECIFIED
;
/* Bind UDP socket to socket address */
if
(
socket_base_bind
(
sock_rcv
,
&
sa_rcv
,
sizeof
(
sa_rcv
))
==
-
1
)
{
/* Failed binding the socket */
socket_base_close
(
sock_rcv
);
if
(
conn_udp_create
(
&
conn
,
&
unspec
,
sizeof
(
unspec
),
AF_INET6
,
MANET_PORT
)
==
-
1
)
{
/* Failed creating the connection */
return
0
;
}
while
(
1
)
{
int32_t
rcv_size
=
socket_base_recvfrom
(
sock_rcv
,
(
void
*
)
nhdp_rcv_buf
,
NHDP_MAX_RFC5444_PACKET_SZ
,
0
,
&
sa_rcv
,
&
fromlen
);
ipv6_addr_t
rcv_addr
;
uint16_t
rcv_port
;
int32_t
rcv_size
=
conn_udp_recvfrom
(
&
conn
,
(
void
*
)
nhdp_rcv_buf
,
NHDP_MAX_RFC5444_PACKET_SZ
,
&
rcv_addr
,
sizeof
(
rcv_addr
),
&
rcv_port
);
if
(
rcv_size
>
0
)
{
/* Packet received, let the reader handle it */
...
...
@@ -316,7 +314,7 @@ static void *_nhdp_receiver(void *arg __attribute__((unused)))
}
}
socket_base_close
(
sock_rcv
);
gnrc_udp_close
(
&
conn
);
return
0
;
}
...
...
@@ -328,5 +326,8 @@ static void write_packet(struct rfc5444_writer *wr __attribute__((unused)),
struct
rfc5444_writer_target
*
iface
__attribute__
((
unused
)),
void
*
buffer
,
size_t
length
)
{
socket_base_sendto
(
sock_rcv
,
buffer
,
length
,
0
,
&
sa_bcast
,
sizeof
(
sa_bcast
));
ipv6_addr_t
src
,
dst
=
IPV6_ADDR_ALL_NODES_LINK_LOCAL
;
uint16_t
sport
,
dport
=
MANET_PORT
;
conn_udp_getlocaladdr
(
&
conn
,
&
src
,
&
sport
);
conn_udp_sendto
(
buffer
,
length
,
&
src
,
sizeof
(
src
),
&
dst
,
sizeof
(
dst
),
AF_INET
,
sport
,
dport
);
}
This diff is collapsed.
Click to expand it.
sys/net/routing/nhdp/nhdp.h
+
0
−
1
View file @
9ce1c6df
...
...
@@ -23,7 +23,6 @@
#include
"timex.h"
#include
"kernel_types.h"
#include
"socket_base/socket.h"
#include
"nhdp_metric.h"
#include
"rfc5444/rfc5444_writer.h"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment