-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathnib.c
1732 lines (1613 loc) · 64.8 KB
/
nib.c
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2017 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.
*/
/**
* @{
*
* @file
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <kernel_defines.h>
#include "log.h"
#include "net/ipv6/addr.h"
#include "net/gnrc/icmpv6/error.h"
#include "net/gnrc/nettype.h"
#include "net/gnrc/netif/internal.h"
#include "net/gnrc/ipv6/nib.h"
#include "net/gnrc/ndp.h"
#include "net/gnrc/netreg.h"
#include "net/gnrc/pktqueue.h"
#include "net/gnrc/sixlowpan/nd.h"
#include "net/ndp.h"
#include "net/sixlowpan/nd.h"
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_DNS)
#include "net/sock/dns.h"
#endif
#if IS_ACTIVE(MODULE_DHCPV6_CLIENT)
#include "net/dhcpv6/client.h"
#endif
#include "_nib-internal.h"
#include "_nib-arsm.h"
#include "_nib-router.h"
#include "_nib-6ln.h"
#include "_nib-6lr.h"
#include "_nib-slaac.h"
#define ENABLE_DEBUG 0
#include "debug.h"
#if IS_ACTIVE(ENABLE_DEBUG)
#include "evtimer.h"
#endif
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_QUEUE_PKT)
static gnrc_pktqueue_t _queue_pool[CONFIG_GNRC_IPV6_NIB_NUMOF];
#endif /* CONFIG_GNRC_IPV6_NIB_QUEUE_PKT */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_DNS)
static evtimer_msg_event_t _rdnss_timeout;
#endif
/**
* @internal
* @{
*/
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
static void _handle_rtr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_rtr_sol_t *rtr_sol, size_t icmpv6_len);
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_rtr_adv_t *rtr_adv, size_t icmpv6_len);
static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_nbr_sol_t *nbr_sol, size_t icmpv6_len);
static void _handle_nbr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_nbr_adv_t *nbr_adv, size_t icmpv6_len);
static bool _resolve_addr(const ipv6_addr_t *dst, gnrc_netif_t *netif,
gnrc_pktsnip_t *pkt, gnrc_ipv6_nib_nc_t *nce,
_nib_onl_entry_t *entry);
static void _handle_pfx_timeout(_nib_offl_entry_t *pfx);
static void _handle_rtr_timeout(_nib_dr_entry_t *router);
static void _handle_snd_na(gnrc_pktsnip_t *pkt);
/* needs to be exported for 6LN's ARO handling */
void _handle_search_rtr(gnrc_netif_t *netif);
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_DNS)
static void _handle_rdnss_timeout(sock_udp_ep_t *dns_server);
#endif
/** @} */
static inline bool _should_search_rtr(const gnrc_netif_t *netif)
{
/* 6LBR interface does not send RS.
A non-advertising router sends RS or a 6LN that is advertising or not
has to refetch router information */
return !gnrc_netif_is_6lbr(netif) &&
(!gnrc_netif_is_rtr_adv(netif) || gnrc_netif_is_6ln(netif));
}
void gnrc_ipv6_nib_init(void)
{
evtimer_event_t *tmp;
_nib_acquire();
for (evtimer_event_t *ptr = _nib_evtimer.events;
(ptr != NULL) && (tmp = (ptr->next), 1);
ptr = tmp) {
evtimer_del((evtimer_t *)(&_nib_evtimer), ptr);
}
_nib_init();
_nib_release();
}
static void _add_static_lladdr(gnrc_netif_t *netif)
{
#ifdef CONFIG_GNRC_IPV6_STATIC_LLADDR
/* parse addr from string and explicitly set a link local prefix
* if ifnum > 1 each interface will get its own link local address
* with CONFIG_GNRC_IPV6_STATIC_LLADDR + i
*/
const char lladdr_str[] = CONFIG_GNRC_IPV6_STATIC_LLADDR;
ipv6_addr_t lladdr;
if (ipv6_addr_from_str(&lladdr, lladdr_str) != NULL) {
if (!IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED)) {
lladdr.u8[15] += netif->pid;
}
assert(ipv6_addr_is_link_local(&lladdr));
gnrc_netif_ipv6_addr_add_internal(
netif, &lladdr, 64U, GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID
);
}
#else
(void)netif;
#endif
}
void gnrc_ipv6_nib_iface_up(gnrc_netif_t *netif)
{
assert(netif != NULL);
gnrc_netif_acquire(netif);
_init_iface_arsm(netif);
netif->ipv6.rs_sent = 0;
netif->ipv6.na_sent = 0;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
if (gnrc_netif_ipv6_group_join_internal(netif, &ipv6_addr_all_routers_link_local)) {
DEBUG("nib: Can't join link-local all-routers on interface %u\n", netif->pid);
}
#endif
if (gnrc_netif_ipv6_group_join_internal(netif, &ipv6_addr_all_nodes_link_local) < 0) {
DEBUG("nib: Can't join link-local all-nodes on interface %u\n", netif->pid);
}
_add_static_lladdr(netif);
_auto_configure_addr(netif, &ipv6_addr_link_local_prefix, 64U);
if (_should_search_rtr(netif)) {
uint32_t next_rs_time = random_uint32_range(0, NDP_MAX_RS_MS_DELAY);
_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR, &netif->ipv6.search_rtr,
next_rs_time);
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
else {
_handle_snd_mc_ra(netif);
}
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
gnrc_netif_release(netif);
}
void gnrc_ipv6_nib_iface_down(gnrc_netif_t *netif, bool send_final_ra)
{
assert(netif != NULL);
DEBUG("nib: Deinitialize interface %u\n", netif->pid);
gnrc_netif_acquire(netif);
_deinit_iface_arsm(netif);
if (_should_search_rtr(netif)) {
_evtimer_del(&netif->ipv6.search_rtr);
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
else {
_evtimer_del(&netif->ipv6.snd_mc_ra);
if (send_final_ra) {
/* trigger final RA with lifetime set to zero */
netif->ipv6.ra_sent = (UINT8_MAX - NDP_MAX_FIN_RA_NUMOF) + 1;
_handle_snd_mc_ra(netif);
}
}
#else
(void)send_final_ra;
#endif
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_is_link_local(&netif->ipv6.addrs[i])) {
/* link-local address might change on reconnect */
gnrc_netif_ipv6_addr_remove_internal(netif, &netif->ipv6.addrs[i]);
}
}
gnrc_netif_ipv6_group_leave_internal(netif, &ipv6_addr_all_nodes_link_local);
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
gnrc_netif_ipv6_group_leave_internal(netif, &ipv6_addr_all_routers_link_local);
#endif
gnrc_netif_release(netif);
}
void gnrc_ipv6_nib_init_iface(gnrc_netif_t *netif)
{
assert(netif != NULL);
DEBUG("nib: Initialize interface %u\n", netif->pid);
gnrc_netif_acquire(netif);
netif->ipv6.retrans_time = NDP_RETRANS_TIMER_MS;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) || IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
/* TODO: set differently dependent on CONFIG_GNRC_IPV6_NIB_SLAAC if
* alternatives exist */
netif->ipv6.aac_mode |= GNRC_NETIF_AAC_AUTO;
#endif /* CONFIG_GNRC_IPV6_NIB_SLAAC || CONFIG_GNRC_IPV6_NIB_6LN */
_init_iface_router(netif);
gnrc_netif_init_6ln(netif);
gnrc_netif_release(netif);
}
static bool _on_link(const ipv6_addr_t *dst, unsigned *iface)
{
_nib_offl_entry_t *entry = NULL;
_nib_offl_entry_t *match = NULL;
if (ipv6_addr_is_link_local(dst)) {
return true;
}
while ((entry = _nib_offl_iter(entry))) {
if ((ipv6_addr_match_prefix(dst, &entry->pfx) >= entry->pfx_len) &&
((match == NULL) || (entry->pfx_len > match->pfx_len))) {
match = entry;
}
}
if (match) {
*iface = _nib_onl_get_if(match->next_hop);
/* check if prefix is on-link */
return (match->mode & _PL) && (match->flags & _PFX_ON_LINK);
}
return false;
}
static gnrc_netif_t *_acquire_new_iface(unsigned iface)
{
gnrc_netif_t *netif = gnrc_netif_get_by_pid(iface);
/* release NIB, in case other thread calls a NIB function while we wait for
* the netif */
_nib_release();
gnrc_netif_acquire(netif);
/* re-acquire NIB */
_nib_acquire();
return netif;
}
int gnrc_ipv6_nib_get_next_hop_l2addr(const ipv6_addr_t *dst,
gnrc_netif_t *netif, gnrc_pktsnip_t *pkt,
gnrc_ipv6_nib_nc_t *nce)
{
int res = 0;
DEBUG("nib: get next hop link-layer address of %s%%%u\n",
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)),
(netif != NULL) ? (unsigned)netif->pid : 0U);
gnrc_netif_acquire(netif);
_nib_acquire();
do { /* XXX: hidden goto ;-) */
_nib_onl_entry_t *node = _nib_onl_nc_get(dst,
(netif == NULL) ? 0 : netif->pid);
/* consider neighbor cache entries first */
unsigned iface = (node == NULL) ? 0 : _nib_onl_get_if(node);
if ((node != NULL) || _on_link(dst, &iface)) {
DEBUG("nib: %s is %s, start address resolution\n",
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)),
node ? "in NC" : "on-link");
/* on-link prefixes return their interface */
if (!ipv6_addr_is_link_local(dst) && (iface != 0)) {
/* release pre-assumed netif */
gnrc_netif_release(netif);
netif = _acquire_new_iface(iface);
/* get node from proper interface */
if (netif != NULL) {
node = _nib_onl_nc_get(dst, netif->pid);
}
}
if ((netif == NULL) ||
!_resolve_addr(dst, netif, pkt, nce, node)) {
DEBUG("nib: host unreachable\n");
/* _resolve_addr releases pkt only if not queued (in which case
* we also shouldn't release), but if netif is not defined we
* should release in any case. */
if ((netif == NULL) && (pkt != NULL)) {
gnrc_icmpv6_error_dst_unr_send(ICMPV6_ERROR_DST_UNR_ADDR,
pkt);
gnrc_pktbuf_release_error(pkt, EHOSTUNREACH);
}
res = -EHOSTUNREACH;
break;
}
}
else {
gnrc_ipv6_nib_ft_t route;
DEBUG("nib: %s is off-link, resolve route\n",
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)));
res = _nib_get_route(dst, pkt, &route);
if ((res < 0) || ipv6_addr_is_unspecified(&route.next_hop)) {
DEBUG("nib: no route to %s found or is prefix list entry, "
"search neighbor cache\n",
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)));
if ((res == 0) &&
/* If ARSM is not active only use link-local as next hop */
(IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM) ||
ipv6_addr_is_link_local(dst))) {
DEBUG("nib: prefix list entry => taking dst as next hop\n");
memcpy(&route.next_hop, dst, sizeof(route.next_hop));
}
else {
res = -ENETUNREACH;
if (pkt != NULL) {
gnrc_icmpv6_error_dst_unr_send(
ICMPV6_ERROR_DST_UNR_NO_ROUTE,
pkt
);
gnrc_pktbuf_release_error(pkt, ENETUNREACH);
}
break;
}
}
if ((netif != NULL) && (netif->pid != (int)route.iface)) {
/* release pre-assumed netif */
gnrc_netif_release(netif);
}
if ((netif == NULL) || (netif->pid != (int)route.iface)) {
/* get actual netif */
netif = _acquire_new_iface(route.iface);
}
node = _nib_onl_nc_get(&route.next_hop,
(netif != NULL) ? netif->pid : 0);
if (_resolve_addr(&route.next_hop, netif, pkt, nce, node)) {
_call_route_info_cb(netif,
GNRC_IPV6_NIB_ROUTE_INFO_TYPE_RN,
&route.dst,
(void *)((intptr_t)route.dst_len));
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_DC)
_nib_dc_add(&route.next_hop, netif->pid, dst);
#endif /* CONFIG_GNRC_IPV6_NIB_DC */
}
else {
/* _resolve_addr releases pkt if not queued (in which case
* we also shouldn't release */
res = -EHOSTUNREACH;
}
}
} while (0);
_nib_release();
gnrc_netif_release(netif);
return res;
}
void gnrc_ipv6_nib_handle_pkt(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const icmpv6_hdr_t *icmpv6, size_t icmpv6_len)
{
DEBUG("nib: Handle packet (icmpv6->type = %u)\n", icmpv6->type);
assert(netif != NULL);
gnrc_netif_acquire(netif);
_nib_acquire();
switch (icmpv6->type) {
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
case ICMPV6_RTR_SOL:
_handle_rtr_sol(netif, ipv6, (ndp_rtr_sol_t *)icmpv6, icmpv6_len);
break;
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
case ICMPV6_RTR_ADV:
_handle_rtr_adv(netif, ipv6, (ndp_rtr_adv_t *)icmpv6, icmpv6_len);
break;
case ICMPV6_NBR_SOL:
_handle_nbr_sol(netif, ipv6, (ndp_nbr_sol_t *)icmpv6, icmpv6_len);
break;
case ICMPV6_NBR_ADV:
_handle_nbr_adv(netif, ipv6, (ndp_nbr_adv_t *)icmpv6, icmpv6_len);
break;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_REDIRECT)
case ICMPV6_REDIRECT:
/* TODO */
break;
#endif /* CONFIG_GNRC_IPV6_NIB_REDIRECT */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_DAD)
case ICMPV6_DAR:
/* TODO */
break;
case ICMPV6_DAC:
/* TODO */
break;
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_DAD */
}
_nib_release();
gnrc_netif_release(netif);
}
void gnrc_ipv6_nib_handle_timer_event(void *ctx, uint16_t type)
{
DEBUG("nib: Handle timer event (ctx = %p, type = 0x%04x, now = %ums)\n",
ctx, type, (unsigned)evtimer_now_msec());
_nib_acquire();
switch (type) {
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM)
case GNRC_IPV6_NIB_SND_UC_NS:
case GNRC_IPV6_NIB_SND_MC_NS:
_handle_snd_ns(ctx);
break;
case GNRC_IPV6_NIB_REACH_TIMEOUT:
case GNRC_IPV6_NIB_DELAY_TIMEOUT:
_handle_state_timeout(ctx);
break;
case GNRC_IPV6_NIB_RECALC_REACH_TIME:
_recalc_reach_time(ctx);
break;
#endif /* CONFIG_GNRC_IPV6_NIB_ARSM */
case GNRC_IPV6_NIB_SND_NA:
_handle_snd_na(ctx);
break;
case GNRC_IPV6_NIB_SEARCH_RTR:
_handle_search_rtr(ctx);
break;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
case GNRC_IPV6_NIB_REPLY_RS:
_handle_reply_rs(ctx);
break;
case GNRC_IPV6_NIB_SND_MC_RA:
_handle_snd_mc_ra(ctx);
break;
case GNRC_IPV6_NIB_ROUTE_TIMEOUT:
_nib_ft_remove(ctx);
break;
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LR)
case GNRC_IPV6_NIB_ADDR_REG_TIMEOUT:
_nib_nc_remove(ctx);
break;
#endif /* CONFIG_GNRC_IPV6_NIB_6LR */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
case GNRC_IPV6_NIB_ABR_TIMEOUT:
_nib_abr_remove(&((_nib_abr_entry_t *)ctx)->addr);
break;
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
case GNRC_IPV6_NIB_PFX_TIMEOUT:
_handle_pfx_timeout(ctx);
break;
case GNRC_IPV6_NIB_RTR_TIMEOUT:
_handle_rtr_timeout(ctx);
break;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
case GNRC_IPV6_NIB_REREG_ADDRESS:
_handle_rereg_address(ctx);
break;
#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
case GNRC_IPV6_NIB_DAD:
_handle_dad(ctx);
break;
case GNRC_IPV6_NIB_VALID_ADDR:
_handle_valid_addr(ctx);
break;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_DNS)
case GNRC_IPV6_NIB_RDNSS_TIMEOUT:
_handle_rdnss_timeout(ctx);
#endif
default:
break;
}
_nib_release();
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
void gnrc_ipv6_nib_change_rtr_adv_iface(gnrc_netif_t *netif, bool enable)
{
gnrc_netif_acquire(netif);
if (enable) {
_set_rtr_adv(netif);
}
else {
uint32_t next_rs_time = random_uint32_range(0, NDP_MAX_RS_MS_DELAY);
netif->ipv6.ra_sent = (UINT8_MAX - NDP_MAX_FIN_RA_NUMOF) + 1;
netif->flags &= ~GNRC_NETIF_FLAGS_IPV6_RTR_ADV;
/* send final router advertisements */
_handle_snd_mc_ra(netif);
if (!gnrc_netif_is_6lbr(netif)) {
_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR,
&netif->ipv6.search_rtr, next_rs_time);
}
}
gnrc_netif_release(netif);
}
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
/*
* @internal
* @{
*/
static void _handle_mtuo(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
const ndp_opt_mtu_t *mtuo);
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_DNS)
static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
const ndp_opt_rdnss_impl_t *rdnsso);
#endif
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
const ndp_opt_pi_t *pio,
_nib_abr_entry_t *abr);
#else /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
const ndp_opt_pi_t *pio);
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
static uint32_t _handle_rio(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_opt_ri_t *pio);
/** @} */
/* Iterator for NDP options in a packet */
#define FOREACH_OPT(ndp_pkt, opt, icmpv6_len) \
for (opt = (ndp_opt_t *)(ndp_pkt + 1); \
icmpv6_len > 0; \
icmpv6_len -= (opt->len << 3), \
opt = (ndp_opt_t *)(((uint8_t *)opt) + (opt->len << 3)))
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
static void _handle_rtr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_rtr_sol_t *rtr_sol, size_t icmpv6_len)
{
size_t tmp_len = icmpv6_len - sizeof(ndp_rtr_sol_t);
_nib_onl_entry_t *nce = NULL;
ndp_opt_t *opt;
assert(netif != NULL);
/* check validity, see: https://tools.ietf.org/html/rfc4861#section-6.1.1 */
/* checksum is checked by GNRC's ICMPv6 module */
if (!(gnrc_netif_is_rtr(netif)) || (ipv6->hl != NDP_HOP_LIMIT) ||
(rtr_sol->code != 0U) || (icmpv6_len < sizeof(ndp_rtr_sol_t))) {
DEBUG("nib: Received router solicitation is invalid (or interface %i "
"is not a forwarding interface). Discarding silently\n",
netif->pid);
DEBUG(" - IP Hop Limit: %u (should be %u)\n", ipv6->hl,
NDP_HOP_LIMIT);
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_sol->code);
DEBUG(" - ICMP length: %" PRIuSIZE " (should > %" PRIuSIZE ")\n",
icmpv6_len, sizeof(ndp_rtr_sol_t));
return;
}
/* pre-check option length */
FOREACH_OPT(rtr_sol, opt, tmp_len) {
if (tmp_len > icmpv6_len) {
DEBUG("nib: Payload length (%" PRIuSIZE ") of RS doesn't align with options\n",
icmpv6_len);
return;
}
if (opt->len == 0U) {
DEBUG("nib: Option of length 0 detected. "
"Discarding router solicitation silently\n");
return;
}
if ((opt->type == NDP_OPT_SL2A) &&
ipv6_addr_is_unspecified(&ipv6->src)) {
DEBUG("nib: RS contains SLLAO, but source was unspecfied. "
"Discarding router solicitation silently\n");
return;
}
}
DEBUG("nib: Received valid router solicitation:\n");
DEBUG(" - Source address: %s\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
DEBUG(" - Destination address: %s\n",
ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
if (!ipv6_addr_is_unspecified(&ipv6->src)) {
tmp_len = icmpv6_len - sizeof(ndp_rtr_sol_t);
FOREACH_OPT(rtr_sol, opt, tmp_len) {
switch (opt->type) {
case NDP_OPT_SL2A:
if (!gnrc_netif_is_6ln(netif)) {
_handle_sl2ao(netif, ipv6, (const icmpv6_hdr_t *)rtr_sol,
opt);
}
break;
default:
break;
}
}
nce = _nib_onl_nc_get(&ipv6->src, netif->pid);
}
if (!gnrc_netif_is_6ln(netif)) {
uint32_t next_ra_delay = random_uint32_range(0, NDP_MAX_RA_DELAY);
uint32_t next_ra_scheduled = _evtimer_lookup(netif,
GNRC_IPV6_NIB_SND_MC_RA);
if (next_ra_scheduled < next_ra_delay) {
DEBUG("nib: There is a MC RA scheduled within the next %" PRIu32 "ms. "
"Using that to advertise router\n", next_ra_scheduled);
return;
}
else if (nce != NULL) {
/* we send unicast RAs so we do not need to rate-limit as
* https://tools.ietf.org/html/rfc4861#section-6.2.6 asks for */
_evtimer_add(nce, GNRC_IPV6_NIB_REPLY_RS, &nce->reply_rs,
next_ra_delay);
}
else {
uint32_t now = evtimer_now_msec();
/* check for integer overflows and initial value of last_ra */
if (((netif->ipv6.last_ra > (UINT32_MAX - NDP_MIN_MS_DELAY_BETWEEN_RAS) &&
(now < NDP_MIN_MS_DELAY_BETWEEN_RAS))) ||
((now - NDP_MIN_MS_DELAY_BETWEEN_RAS) > netif->ipv6.last_ra)) {
next_ra_delay += NDP_MIN_MS_DELAY_BETWEEN_RAS;
}
_evtimer_add(netif, GNRC_IPV6_NIB_SND_MC_RA, &netif->ipv6.snd_mc_ra,
next_ra_delay);
}
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LR)
else if (gnrc_netif_is_rtr(netif) && gnrc_netif_is_rtr_adv(netif)) {
_snd_rtr_advs(netif, &ipv6->src, false);
}
#endif /* CONFIG_GNRC_IPV6_NIB_6LR */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
(void)nce; /* NCE is not used */
#endif
}
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
static inline uint32_t _min(uint32_t a, uint32_t b)
{
return (a < b) ? a : b;
}
static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_rtr_adv_t *rtr_adv, size_t icmpv6_len)
{
size_t tmp_len = icmpv6_len - sizeof(ndp_rtr_adv_t);
_nib_dr_entry_t *dr = NULL;
ndp_opt_t *opt;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
sixlowpan_nd_opt_abr_t *abro = NULL;
_nib_abr_entry_t *abr = NULL;
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
uint32_t next_timeout = UINT32_MAX;
assert(netif != NULL);
/* check validity, see: https://tools.ietf.org/html/rfc4861#section-6.1.1 */
/* checksum is checked by GNRC's ICMPv6 module */
if (!(ipv6_addr_is_link_local(&ipv6->src)) ||
(ipv6->hl != NDP_HOP_LIMIT) || (rtr_adv->code != 0U) ||
(icmpv6_len < sizeof(ndp_rtr_adv_t)) ||
(!gnrc_netif_is_6ln(netif) &&
(byteorder_ntohs(rtr_adv->ltime) > NDP_RTR_ADV_LTIME_SEC_MAX))) {
DEBUG("nib: Received router advertisement is invalid. "
"Discarding silently\n");
DEBUG(" - IP Hop Limit: %u (should be %u)\n", ipv6->hl,
NDP_HOP_LIMIT);
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_adv->code);
DEBUG(" - ICMP length: %" PRIuSIZE " (should > %" PRIuSIZE ")\n",
icmpv6_len, sizeof(ndp_rtr_adv_t));
DEBUG(" - Source address: %s (should be link-local)\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
DEBUG(" - Router lifetime: %u (should be <= 9000 on non-6LN)\n",
byteorder_ntohs(rtr_adv->ltime));
return;
}
/* pre-check option length */
FOREACH_OPT(rtr_adv, opt, tmp_len) {
if (tmp_len > icmpv6_len) {
DEBUG("nib: Payload length (%" PRIuSIZE ") of RA doesn't align with options\n",
icmpv6_len);
return;
}
if (opt->len == 0U) {
DEBUG("nib: Option of length 0 detected. "
"Discarding router advertisement silently\n");
return;
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
if (opt->type == NDP_OPT_ABR) {
if (abro != NULL) {
DEBUG("nib: More than one ABRO. "
"Discarding router advertisement silently\n");
return;
}
abro = (sixlowpan_nd_opt_abr_t *)opt;
}
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
}
DEBUG("nib: Received valid router advertisement:\n");
DEBUG(" - Source address: %s\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
DEBUG(" - Destination address: %s\n",
ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
DEBUG(" - Cur Hop Limit: %u\n", rtr_adv->cur_hl);
DEBUG(" - Flags: %c%c\n",
(rtr_adv->flags & NDP_RTR_ADV_FLAGS_M) ? 'M' : '-',
(rtr_adv->flags & NDP_RTR_ADV_FLAGS_O) ? 'O' : '-');
DEBUG(" - Router Lifetime: %us\n", byteorder_ntohs(rtr_adv->ltime));
DEBUG(" - Reachable Time: %" PRIu32 "ms\n",
byteorder_ntohl(rtr_adv->reach_time));
DEBUG(" - Retrans Timer: %" PRIu32 "ms\n",
byteorder_ntohl(rtr_adv->retrans_timer));
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
if (abro != NULL) {
if ((abr = _handle_abro(abro)) == NULL) {
DEBUG("nib: could not allocate space for new border router or "
"there is no new information in the RA. "
"Discarding silently\n");
return;
}
/* UINT16_MAX * 60 * 1000 < UINT32_MAX so there are no overflows */
next_timeout = _min(next_timeout,
MS_PER_SEC * SEC_PER_MIN *
gnrc_sixlowpan_nd_opt_get_ltime(abro));
}
#if !IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
else if (gnrc_netif_is_6lr(netif)) {
DEBUG("nib: multihop prefix and context dissemination on router activated,\n"
" but no ABRO found. Discarding router advertisement silently\n");
return;
}
#endif /* !CONFIG_GNRC_IPV6_NIB_6LBR */
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
if (!gnrc_netif_is_6lbr(netif) && rtr_adv->ltime.u16 != 0) {
uint16_t rtr_ltime = byteorder_ntohs(rtr_adv->ltime);
dr = _nib_drl_add(&ipv6->src, netif->pid);
if (dr != NULL) {
_evtimer_add(dr, GNRC_IPV6_NIB_RTR_TIMEOUT, &dr->rtr_timeout,
rtr_ltime * MS_PER_SEC);
}
else {
DEBUG("nib: default router list is full. Ignoring RA from %s\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
return;
}
/* UINT16_MAX * 1000 < UINT32_MAX so there are no overflows */
next_timeout = _min(next_timeout, rtr_ltime * MS_PER_SEC);
}
else {
dr = _nib_drl_get(&ipv6->src, netif->pid);
DEBUG("nib: router lifetime was 0. Removing router and routes via it.");
if (dr != NULL) {
_handle_rtr_timeout(dr);
}
dr = NULL;
}
if (rtr_adv->cur_hl != 0) {
netif->cur_hl = rtr_adv->cur_hl;
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM)
if (rtr_adv->reach_time.u32 != 0) {
uint32_t reach_time = byteorder_ntohl(rtr_adv->reach_time);
if (reach_time != netif->ipv6.reach_time_base) {
_evtimer_add(netif, GNRC_IPV6_NIB_RECALC_REACH_TIME,
&netif->ipv6.recalc_reach_time,
CONFIG_GNRC_IPV6_NIB_REACH_TIME_RESET);
netif->ipv6.reach_time_base = reach_time;
_recalc_reach_time(&netif->ipv6);
}
}
#endif /* CONFIG_GNRC_IPV6_NIB_ARSM */
if (rtr_adv->retrans_timer.u32 != 0) {
netif->ipv6.retrans_time = byteorder_ntohl(rtr_adv->retrans_timer);
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
if ((dr != NULL) && gnrc_netif_is_6ln(netif) &&
!gnrc_netif_is_6lbr(netif)) {
/* (register addresses already assigned but not valid yet)*/
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if ((netif->ipv6.addrs_flags[i] != 0) &&
(netif->ipv6.addrs_flags[i] != GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID)) {
_handle_rereg_address(&netif->ipv6.addrs[i]);
}
}
}
#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
tmp_len = icmpv6_len - sizeof(ndp_rtr_adv_t);
FOREACH_OPT(rtr_adv, opt, tmp_len) {
switch (opt->type) {
case NDP_OPT_SL2A:
_handle_sl2ao(netif, ipv6, (const icmpv6_hdr_t *)rtr_adv,
opt);
break;
case NDP_OPT_MTU:
_handle_mtuo(netif, (const icmpv6_hdr_t *)rtr_adv,
(ndp_opt_mtu_t *)opt);
break;
case NDP_OPT_RI:
_handle_rio(netif, ipv6, (ndp_opt_ri_t *)opt);
break;
case NDP_OPT_PI: {
uint32_t min_pfx_timeout;
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
min_pfx_timeout = _handle_pio(netif,
(const icmpv6_hdr_t *)rtr_adv,
(ndp_opt_pi_t *)opt, abr);
#else /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
min_pfx_timeout = _handle_pio(netif,
(const icmpv6_hdr_t *)rtr_adv,
(ndp_opt_pi_t *)opt);
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
next_timeout = _min(next_timeout, min_pfx_timeout);
/* notify optional PIO consumer */
if (IS_USED(MODULE_GNRC_IPV6_NIB_RTR_ADV_PIO_CB)) {
extern void gnrc_ipv6_nib_rtr_adv_pio_cb(gnrc_netif_t *netif,
const ndp_opt_pi_t *pio);
gnrc_ipv6_nib_rtr_adv_pio_cb(netif, (ndp_opt_pi_t *)opt);
}
break;
}
/* ABRO was already secured in the option check above */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
case NDP_OPT_6CTX:
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
next_timeout = _min(_handle_6co((icmpv6_hdr_t *)rtr_adv,
(sixlowpan_nd_opt_6ctx_t *)opt,
abr), next_timeout);
#else /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
next_timeout = _min(_handle_6co((icmpv6_hdr_t *)rtr_adv,
(sixlowpan_nd_opt_6ctx_t *)opt),
next_timeout);
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
break;
#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_DNS)
case NDP_OPT_RDNSS:
next_timeout = _min(_handle_rdnsso(netif,
(icmpv6_hdr_t *)rtr_adv,
(ndp_opt_rdnss_impl_t *)opt),
next_timeout);
break;
#endif
default:
break;
}
}
/* we still don't have a default router */
if (dr == NULL) {
return;
}
#if IS_ACTIVE(MODULE_DHCPV6_CLIENT)
uint8_t current_conf_mode = dhcpv6_client_get_conf_mode();
if (rtr_adv->flags & NDP_RTR_ADV_FLAGS_M) {
if (IS_USED(MODULE_DHCPV6_CLIENT_IA_NA)) {
netif->ipv6.aac_mode |= GNRC_NETIF_AAC_DHCP;
dhcpv6_client_req_ia_na(netif->pid);
} else {
dhcpv6_client_set_conf_mode(DHCPV6_CLIENT_CONF_MODE_STATEFUL);
}
} else if ((rtr_adv->flags & NDP_RTR_ADV_FLAGS_O) &&
(current_conf_mode != DHCPV6_CLIENT_CONF_MODE_STATEFUL)) {
dhcpv6_client_set_conf_mode(DHCPV6_CLIENT_CONF_MODE_STATELESS);
}
#endif /* MODULE_DHCPV6_CLIENT */
/* stop sending router solicitations
* see https://tools.ietf.org/html/rfc4861#section-6.3.7 */
if (!gnrc_netif_is_6lbr(netif)) {
evtimer_del(&_nib_evtimer, &netif->ipv6.search_rtr.event);
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
if (gnrc_netif_is_6ln(netif) && !gnrc_netif_is_6lbr(netif)) {
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)) {
_set_rtr_adv(netif);
}
/* but re-fetch information from router in time */
_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR,
&netif->ipv6.search_rtr, (next_timeout >> 2) * 3);
/* i.e. 3/4 of the time before the earliest expires */
}
#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
}
static inline size_t _get_l2src(const gnrc_netif_t *netif, uint8_t *l2src)
{
#if GNRC_NETIF_L2ADDR_MAXLEN > 0
memcpy(l2src, netif->l2addr, netif->l2addr_len);
return netif->l2addr_len;
#else /* GNRC_NETIF_L2ADDR_MAXLEN > 0 */
(void)netif;
(void)l2src;
return 0;
#endif /* GNRC_NETIF_L2ADDR_MAXLEN > 0 */
}
static gnrc_pktsnip_t *_check_release_pkt(gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *payload)
{
if (pkt == NULL) {
DEBUG("nib: No space left in packet buffer. Not replying NS");
gnrc_pktbuf_release(payload);
}
return pkt;
}
static void _send_delayed_nbr_adv(const gnrc_netif_t *netif,
const ipv6_addr_t *tgt,
const ipv6_hdr_t *ipv6_hdr,
gnrc_pktsnip_t *payload)
{
gnrc_pktsnip_t *pkt;
_nib_onl_entry_t *nce;
uint8_t reply_flags = NDP_NBR_ADV_FLAGS_S;
nce = _nib_onl_nc_get(tgt, netif->pid);
if (nce == NULL) {
/* usually this should be the case, but when NCE is full, just
* ignore the sending. Other nodes in this anycast group are
* then preferred */
gnrc_pktbuf_release(payload);
return;
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
if (gnrc_netif_is_rtr(netif)) {
reply_flags |= NDP_NBR_ADV_FLAGS_R;
}
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
#if GNRC_NETIF_L2ADDR_MAXLEN > 0
if (ipv6_addr_is_multicast(&ipv6_hdr->dst)) {
uint8_t l2addr[GNRC_NETIF_L2ADDR_MAXLEN];
size_t l2addr_len = _get_l2src(netif, l2addr);
if (l2addr_len > 0) {
pkt = gnrc_ndp_opt_tl2a_build(l2addr, l2addr_len, payload);
if ((payload = _check_release_pkt(pkt, payload)) == NULL) {
return;
}
}
else {
reply_flags |= NDP_NBR_ADV_FLAGS_O;
}
}
else {
reply_flags |= NDP_NBR_ADV_FLAGS_O;
}
#else /* GNRC_NETIF_L2ADDR_MAXLEN > 0 */
reply_flags |= NDP_NBR_ADV_FLAGS_O;
#endif /* GNRC_NETIF_L2ADDR_MAXLEN > 0 */
/* discard const qualifier */
pkt = gnrc_ndp_nbr_adv_build(tgt, reply_flags, payload);
if ((payload = _check_release_pkt(pkt, payload)) == NULL) {
return;
}
pkt = gnrc_ipv6_hdr_build(payload, NULL, &ipv6_hdr->src);
if ((payload = _check_release_pkt(pkt, payload)) == NULL) {
return;
}
((ipv6_hdr_t *)payload->data)->hl = NDP_HOP_LIMIT;
pkt = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
if ((pkt = _check_release_pkt(pkt, payload)) == NULL) {
return;
}
gnrc_netif_hdr_set_netif(pkt->data, netif);
pkt = gnrc_pkt_prepend(payload, pkt);
_evtimer_add(pkt, GNRC_IPV6_NIB_SND_NA, &nce->snd_na,
random_uint32_range(0, NDP_MAX_ANYCAST_MS_DELAY));
}
static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_nbr_sol_t *nbr_sol, size_t icmpv6_len)
{
size_t tmp_len = icmpv6_len - sizeof(ndp_nbr_sol_t);
int tgt_idx;
ndp_opt_t *opt;
/* check validity, see: https://tools.ietf.org/html/rfc4861#section-7.1.1 */
/* checksum is checked by GNRC's ICMPv6 module */
if ((ipv6->hl != NDP_HOP_LIMIT) || (nbr_sol->code != 0U) ||
(icmpv6_len < sizeof(ndp_nbr_sol_t)) ||
ipv6_addr_is_multicast(&nbr_sol->tgt) ||
(ipv6_addr_is_unspecified(&ipv6->src) &&
!ipv6_addr_is_solicited_node(&ipv6->dst))) {
DEBUG("nib: Received neighbor solicitation is invalid. Discarding silently\n");
DEBUG(" - IP Hop Limit: %u (should be %u)\n", ipv6->hl,
NDP_HOP_LIMIT);
DEBUG(" - ICMP code: %u (should be 0)\n", nbr_sol->code);
DEBUG(" - ICMP length: %" PRIuSIZE " (should > %" PRIuSIZE ")\n",
icmpv6_len, sizeof(ndp_nbr_sol_t));
DEBUG(" - Target address: %s (should not be multicast)\n",
ipv6_addr_to_str(addr_str, &nbr_sol->tgt, sizeof(addr_str)));
DEBUG(" - Source address: %s\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
DEBUG(" - Destination address: %s (should be of format "