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
53a9dc36
Unverified
Commit
53a9dc36
authored
7 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
nhdp: port to sock
parent
c23d624d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile.dep
+1
-1
1 addition, 1 deletion
Makefile.dep
sys/net/routing/nhdp/nhdp.c
+14
-22
14 additions, 22 deletions
sys/net/routing/nhdp/nhdp.c
with
15 additions
and
23 deletions
Makefile.dep
+
1
−
1
View file @
53a9dc36
...
...
@@ -14,7 +14,7 @@ ifneq (,$(filter csma_sender,$(USEMODULE)))
endif
ifneq
(,$(filter nhdp,$(USEMODULE)))
USEMODULE
+=
conn
_udp
USEMODULE
+=
sock
_udp
USEMODULE
+=
xtimer
USEMODULE
+=
oonf_rfc5444
endif
...
...
This diff is collapsed.
Click to expand it.
sys/net/routing/nhdp/nhdp.c
+
14
−
22
View file @
53a9dc36
...
...
@@ -18,8 +18,7 @@
* @}
*/
#include
"net/gnrc/conn.h"
#include
"net/conn/udp.h"
#include
"net/sock/udp.h"
#include
"msg.h"
#include
"net/gnrc/netapi.h"
#include
"net/gnrc/netif.h"
...
...
@@ -38,10 +37,6 @@
#include
"nhdp_writer.h"
#include
"nhdp_reader.h"
#ifndef MODULE_CONN_UDP
#error "nhdp needs a conn_udp implementation to work"
#endif
#define HELLO_TIMER (12345)
char
nhdp_stack
[
NHDP_STACK_SIZE
];
...
...
@@ -53,7 +48,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
conn
_udp_t
conn
;
static
sock
_udp_t
sock
;
#if (NHDP_METRIC_NEEDS_TIMER)
static
xtimer_t
metric_timer
;
...
...
@@ -295,27 +290,24 @@ static void *_nhdp_runner(void *arg)
*/
static
void
*
_nhdp_receiver
(
void
*
arg
__attribute__
((
unused
)))
{
static
const
sock_udp_ep_t
ep
=
{
.
family
=
AF_INET6
,
.
netif
=
SOCK_ADDR_ANY_NETIF
,
.
port
=
MANET_PORT
};
char
nhdp_rcv_buf
[
NHDP_MAX_RFC5444_PACKET_SZ
];
msg_t
msg_q
[
NHDP_MSG_QUEUE_SIZE
];
msg_init_queue
(
msg_q
,
NHDP_MSG_QUEUE_SIZE
);
/* Configure socket address for the manet port 269 */
ipv6_addr_t
unspec
=
IPV6_ADDR_UNSPECIFIED
;
/* Bind UDP socket to socket address */
if
(
conn
_udp_create
(
&
conn
,
&
unspec
,
sizeof
(
unspec
),
AF_INET6
,
MANET_PORT
)
==
-
1
)
{
if
(
sock
_udp_create
(
&
sock
,
&
ep
,
NULL
,
0
)
<
0
)
{
/* Failed creating the connection */
return
0
;
}
while
(
1
)
{
ipv6_addr_t
rcv_addr
;
uint16_t
rcv_port
;
size_t
addr_len
=
sizeof
(
rcv_addr
);
int32_t
rcv_size
=
conn_udp_recvfrom
(
&
conn
,
(
void
*
)
nhdp_rcv_buf
,
NHDP_MAX_RFC5444_PACKET_SZ
,
&
rcv_addr
,
&
addr_len
,
&
rcv_port
);
int32_t
rcv_size
=
sock_udp_recv
(
&
sock
,
(
void
*
)
nhdp_rcv_buf
,
NHDP_MAX_RFC5444_PACKET_SZ
,
SOCK_NO_TIMEOUT
,
NULL
);
if
(
rcv_size
>
0
)
{
/* Packet received, let the reader handle it */
...
...
@@ -325,7 +317,7 @@ static void *_nhdp_receiver(void *arg __attribute__((unused)))
}
}
conn
_udp_close
(
&
conn
);
sock
_udp_close
(
&
sock
);
return
0
;
}
...
...
@@ -337,8 +329,8 @@ static void write_packet(struct rfc5444_writer *wr __attribute__((unused)),
struct
rfc5444_writer_target
*
iface
__attribute__
((
unused
)),
void
*
buffer
,
size_t
length
)
{
ipv6_addr_t
src
,
dst
=
IPV6_ADDR_ALL_NODES_LINK_LOCAL
;
uint16_t
sport
,
d
port
=
MANET_PORT
;
conn_udp_getlocaladdr
(
&
conn
,
&
src
,
&
sport
);
conn
_udp_send
to
(
buffer
,
length
,
&
src
,
sizeof
(
src
),
&
dst
,
sizeof
(
dst
),
AF_INET
,
sport
,
dport
);
sock_udp_ep_t
ep
=
{
.
family
=
AF_INET6
,
.
netif
=
SOCK_ADDR_ANY_NETIF
,
.
port
=
MANET_PORT
}
;
memcpy
(
ep
.
addr
.
ipv6
,
&
ipv6_addr_all_nodes_link_local
,
sizeof
(
ep
.
addr
.
ipv6
)
);
sock
_udp_send
(
&
sock
,
buffer
,
length
,
&
ep
);
}
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