Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
contiki-ng
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
NATAF Emmanuel
contiki-ng
Commits
d09c54fe
Commit
d09c54fe
authored
7 years ago
by
George Oikonomou
Browse files
Options
Downloads
Patches
Plain Diff
Use logging
parent
3656d2f9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/rpl-border-router/border-router.c
+13
-9
13 additions, 9 deletions
examples/rpl-border-router/border-router.c
examples/rpl-border-router/slip-bridge.c
+20
-18
20 additions, 18 deletions
examples/rpl-border-router/slip-bridge.c
with
33 additions
and
27 deletions
examples/rpl-border-router/border-router.c
+
13
−
9
View file @
d09c54fe
...
@@ -51,15 +51,18 @@
...
@@ -51,15 +51,18 @@
#include
"net/netstack.h"
#include
"net/netstack.h"
#include
"dev/button-sensor.h"
#include
"dev/button-sensor.h"
#include
"dev/slip.h"
#include
"dev/slip.h"
#include
"net/ipv6/uip-debug.h"
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<string.h>
#include
<string.h>
#include
<ctype.h>
#include
<ctype.h>
/*---------------------------------------------------------------------------*/
#define DEBUG DEBUG_NONE
/* Log configuration */
#include
"net/ipv6/uip-debug.h"
#include
"sys/log.h"
#define LOG_MODULE "BR"
#define LOG_LEVEL LOG_LEVEL_NONE
/*---------------------------------------------------------------------------*/
static
uip_ipaddr_t
prefix
;
static
uip_ipaddr_t
prefix
;
static
uint8_t
prefix_set
;
static
uint8_t
prefix_set
;
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
...
@@ -352,14 +355,14 @@ print_local_addresses(void)
...
@@ -352,14 +355,14 @@ print_local_addresses(void)
int
i
;
int
i
;
uint8_t
state
;
uint8_t
state
;
PRINTA
(
"Server IPv6 addresses:
\n
"
);
printf
(
"Server IPv6 addresses:
\n
"
);
for
(
i
=
0
;
i
<
UIP_DS6_ADDR_NB
;
i
++
)
{
for
(
i
=
0
;
i
<
UIP_DS6_ADDR_NB
;
i
++
)
{
state
=
uip_ds6_if
.
addr_list
[
i
].
state
;
state
=
uip_ds6_if
.
addr_list
[
i
].
state
;
if
(
uip_ds6_if
.
addr_list
[
i
].
isused
&&
if
(
uip_ds6_if
.
addr_list
[
i
].
isused
&&
(
state
==
ADDR_TENTATIVE
||
state
==
ADDR_PREFERRED
))
{
(
state
==
ADDR_TENTATIVE
||
state
==
ADDR_PREFERRED
))
{
PRINTA
(
" "
);
printf
(
" "
);
uip_debug_ipaddr_print
(
&
uip_ds6_if
.
addr_list
[
i
].
ipaddr
);
uip_debug_ipaddr_print
(
&
uip_ds6_if
.
addr_list
[
i
].
ipaddr
);
PRINTA
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
}
}
}
}
...
@@ -402,13 +405,14 @@ PROCESS_THREAD(border_router_process, ev, data)
...
@@ -402,13 +405,14 @@ PROCESS_THREAD(border_router_process, ev, data)
SENSORS_ACTIVATE
(
button_sensor
);
SENSORS_ACTIVATE
(
button_sensor
);
PRINTF
(
"RPL-Border router started
\n
"
);
printf
(
"RPL-Border router started
\n
"
);
/* Request prefix until it has been received */
/* Request prefix until it has been received */
while
(
!
prefix_set
)
{
while
(
!
prefix_set
)
{
etimer_set
(
&
et
,
CLOCK_SECOND
);
etimer_set
(
&
et
,
CLOCK_SECOND
);
request_prefix
();
request_prefix
();
PROCESS_WAIT_EVENT_UNTIL
(
etimer_expired
(
&
et
));
PROCESS_WAIT_EVENT_UNTIL
(
etimer_expired
(
&
et
));
LOG_INFO
(
"Waiting for prefix
\n
"
);
}
}
NETSTACK_MAC
.
on
();
NETSTACK_MAC
.
on
();
...
@@ -420,7 +424,7 @@ PROCESS_THREAD(border_router_process, ev, data)
...
@@ -420,7 +424,7 @@ PROCESS_THREAD(border_router_process, ev, data)
while
(
1
)
{
while
(
1
)
{
PROCESS_YIELD
();
PROCESS_YIELD
();
if
(
ev
==
sensors_event
&&
data
==
&
button_sensor
)
{
if
(
ev
==
sensors_event
&&
data
==
&
button_sensor
)
{
PRINTF
(
"Initiating global repair
\n
"
);
LOG_INFO
(
"Initiating global repair
\n
"
);
#if UIP_CONF_IPV6_RPL_LITE
#if UIP_CONF_IPV6_RPL_LITE
rpl_global_repair
();
rpl_global_repair
();
#else
#else
...
...
This diff is collapsed.
Click to expand it.
examples/rpl-border-router/slip-bridge.c
+
20
−
18
View file @
d09c54fe
...
@@ -37,17 +37,19 @@
...
@@ -37,17 +37,19 @@
* Joel Hoglund <joel@sics.se>
* Joel Hoglund <joel@sics.se>
* Nicolas Tsiftes <nvt@sics.se>
* Nicolas Tsiftes <nvt@sics.se>
*/
*/
/*---------------------------------------------------------------------------*/
#include
"net/ipv6/uip.h"
#include
"net/ipv6/uip.h"
#include
"net/ipv6/uip-ds6.h"
#include
"net/ipv6/uip-ds6.h"
#include
"dev/slip.h"
#include
"dev/slip.h"
#include
<string.h>
#include
<string.h>
/*---------------------------------------------------------------------------*/
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
/*---------------------------------------------------------------------------*/
#define DEBUG DEBUG_PRINT
/* Log configuration */
#include
"net/ipv6/uip-debug.h"
#include
"sys/log.h"
#define LOG_MODULE "SLIP"
#define LOG_LEVEL LOG_LEVEL_NONE
/*---------------------------------------------------------------------------*/
void
set_prefix_64
(
uip_ipaddr_t
*
);
void
set_prefix_64
(
uip_ipaddr_t
*
);
static
uip_ipaddr_t
last_sender
;
static
uip_ipaddr_t
last_sender
;
...
@@ -55,22 +57,22 @@ static uip_ipaddr_t last_sender;
...
@@ -55,22 +57,22 @@ static uip_ipaddr_t last_sender;
static
void
static
void
slip_input_callback
(
void
)
slip_input_callback
(
void
)
{
{
PRINTF
(
"SIN: %u
\n
"
,
uip_len
);
LOG_DBG
(
"SIN: %u
\n
"
,
uip_len
);
if
(
uip_buf
[
0
]
==
'!'
)
{
if
(
uip_buf
[
0
]
==
'!'
)
{
PRINTF
(
"Got configuration message of type %c
\n
"
,
uip_buf
[
1
]);
LOG_INFO
(
"Got configuration message of type %c
\n
"
,
uip_buf
[
1
]);
uip_clear_buf
();
uip_clear_buf
();
if
(
uip_buf
[
1
]
==
'P'
)
{
if
(
uip_buf
[
1
]
==
'P'
)
{
uip_ipaddr_t
prefix
;
uip_ipaddr_t
prefix
;
/* Here we set a prefix !!! */
/* Here we set a prefix !!! */
memset
(
&
prefix
,
0
,
16
);
memset
(
&
prefix
,
0
,
16
);
memcpy
(
&
prefix
,
&
uip_buf
[
2
],
8
);
memcpy
(
&
prefix
,
&
uip_buf
[
2
],
8
);
PRINTF
(
"Setting prefix "
);
LOG_INFO
(
"Setting prefix "
);
PRINT
6ADDR
(
&
prefix
);
LOG_INFO_
6ADDR
(
&
prefix
);
PRINTF
(
"
\n
"
);
LOG_INFO_
(
"
\n
"
);
set_prefix_64
(
&
prefix
);
set_prefix_64
(
&
prefix
);
}
}
}
else
if
(
uip_buf
[
0
]
==
'?'
)
{
}
else
if
(
uip_buf
[
0
]
==
'?'
)
{
PRINTF
(
"Got request message of type %c
\n
"
,
uip_buf
[
1
]);
LOG_INFO
(
"Got request message of type %c
\n
"
,
uip_buf
[
1
]);
if
(
uip_buf
[
1
]
==
'M'
)
{
if
(
uip_buf
[
1
]
==
'M'
)
{
char
*
hexchar
=
"0123456789abcdef"
;
char
*
hexchar
=
"0123456789abcdef"
;
int
j
;
int
j
;
...
@@ -104,13 +106,13 @@ output(void)
...
@@ -104,13 +106,13 @@ output(void)
if
(
uip_ipaddr_cmp
(
&
last_sender
,
&
UIP_IP_BUF
->
srcipaddr
))
{
if
(
uip_ipaddr_cmp
(
&
last_sender
,
&
UIP_IP_BUF
->
srcipaddr
))
{
/* Do not bounce packets back over SLIP if the packet was received
/* Do not bounce packets back over SLIP if the packet was received
over SLIP */
over SLIP */
PRINTF
(
"slip-bridge: Destination off-link but no route src="
);
LOG_ERR
(
"slip-bridge: Destination off-link but no route src="
);
PRINT
6ADDR
(
&
UIP_IP_BUF
->
srcipaddr
);
LOG_ERR_
6ADDR
(
&
UIP_IP_BUF
->
srcipaddr
);
PRINTF
(
" dst="
);
LOG_ERR_
(
" dst="
);
PRINT
6ADDR
(
&
UIP_IP_BUF
->
destipaddr
);
LOG_ERR_
6ADDR
(
&
UIP_IP_BUF
->
destipaddr
);
PRINTF
(
"
\n
"
);
LOG_ERR_
(
"
\n
"
);
}
else
{
}
else
{
PRINTF
(
"SUT: %u
\n
"
,
uip_len
);
LOG_DBG
(
"SUT: %u
\n
"
,
uip_len
);
slip_send
();
slip_send
();
}
}
return
0
;
return
0
;
...
...
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