63 #ifdef LWIP_HOOK_FILENAME
64 #include LWIP_HOOK_FILENAME
84 ip6_route(
const ip6_addr_t *src,
const ip6_addr_t *dest)
98 if (ip6_addr_islinklocal(dest)) {
99 if (ip6_addr_isany(src)) {
114 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
115 ip6_addr_cmp(src, netif_ip6_addr(
netif, i))) {
130 #ifdef LWIP_HOOK_IP6_ROUTE
131 netif = LWIP_HOOK_IP6_ROUTE(src, dest);
143 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
144 ip6_addr_netcmp(dest, netif_ip6_addr(
netif, i))) {
151 netif = nd6_find_route(dest);
157 if (!ip6_addr_isany(src)) {
163 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
164 ip6_addr_cmp(src, netif_ip6_addr(
netif, i))) {
171 #if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
173 if (ip6_addr_isloopback(dest)) {
207 ip6_select_source_address(
struct netif *
netif,
const ip6_addr_t *dest)
213 if (ip6_addr_islinklocal(dest) || ip6_addr_ismulticast_linklocal(dest) || ip6_addr_ismulticast_iflocal(dest)) {
215 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
216 ip6_addr_islinklocal(netif_ip6_addr(
netif, i))) {
217 return netif_ip_addr6(
netif, i);
223 if (ip6_addr_issitelocal(dest) || ip6_addr_ismulticast_sitelocal(dest)) {
225 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
226 ip6_addr_issitelocal(netif_ip6_addr(
netif, i)) &&
227 ip6_addr_netcmp(dest, netif_ip6_addr(
netif, i))) {
228 return netif_ip_addr6(
netif, i);
234 if (ip6_addr_isuniquelocal(dest) || ip6_addr_ismulticast_orglocal(dest)) {
236 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
237 ip6_addr_isuniquelocal(netif_ip6_addr(
netif, i)) &&
238 ip6_addr_netcmp(dest, netif_ip6_addr(
netif, i))) {
239 return netif_ip_addr6(
netif, i);
245 if (ip6_addr_isglobal(dest) || ip6_addr_ismulticast_global(dest)) {
247 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
248 ip6_addr_isglobal(netif_ip6_addr(
netif, i))) {
250 src = netif_ip_addr6(
netif, i);
255 if ((!(ip6_addr_netcmp(
ip_2_ip6(src), dest))) &&
256 ip6_addr_netcmp(netif_ip6_addr(
netif, i), dest)) {
257 src = netif_ip_addr6(
netif, i);
269 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
270 ip6_addr_netcmp(dest, netif_ip6_addr(
netif, i))) {
271 return netif_ip_addr6(
netif, i);
278 #if LWIP_IPV6_FORWARD
294 if (ip6_addr_islinklocal(ip6_current_dest_addr()) ||
295 ip6_addr_isloopback(ip6_current_dest_addr())) {
303 netif = ip6_route(IP6_ADDR_ANY6, ip6_current_dest_addr());
306 IP6_ADDR_BLOCK1(ip6_current_dest_addr()),
307 IP6_ADDR_BLOCK2(ip6_current_dest_addr()),
308 IP6_ADDR_BLOCK3(ip6_current_dest_addr()),
309 IP6_ADDR_BLOCK4(ip6_current_dest_addr()),
310 IP6_ADDR_BLOCK5(ip6_current_dest_addr()),
311 IP6_ADDR_BLOCK6(ip6_current_dest_addr()),
312 IP6_ADDR_BLOCK7(ip6_current_dest_addr()),
313 IP6_ADDR_BLOCK8(ip6_current_dest_addr())));
351 icmp6_packet_too_big(p,
netif->
mtu);
359 IP6_ADDR_BLOCK1(ip6_current_dest_addr()),
360 IP6_ADDR_BLOCK2(ip6_current_dest_addr()),
361 IP6_ADDR_BLOCK3(ip6_current_dest_addr()),
362 IP6_ADDR_BLOCK4(ip6_current_dest_addr()),
363 IP6_ADDR_BLOCK5(ip6_current_dest_addr()),
364 IP6_ADDR_BLOCK6(ip6_current_dest_addr()),
365 IP6_ADDR_BLOCK7(ip6_current_dest_addr()),
366 IP6_ADDR_BLOCK8(ip6_current_dest_addr())));
369 netif->output_ip6(
netif, p, ip6_current_dest_addr());
391 ip6_input(
struct pbuf *p,
struct netif *inp)
407 if (
IP6H_V(ip6hdr) != 6) {
416 #ifdef LWIP_HOOK_IP6_INPUT
417 if (LWIP_HOOK_IP6_INPUT(p, inp)) {
427 (
"IPv6 header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet dropped.\n",
432 (
"IPv6 (plen %"U16_F") is longer than pbuf (len %"U16_F"), IP packet dropped.\n",
461 ip_data.current_ip6_header = ip6hdr;
468 if (ip6_addr_ismulticast(ip6_current_dest_addr())) {
470 if (ip6_addr_isallnodes_iflocal(ip6_current_dest_addr()) ||
471 ip6_addr_isallnodes_linklocal(ip6_current_dest_addr())) {
475 else if (mld6_lookfor_group(inp, ip6_current_dest_addr())) {
479 else if (ip6_addr_issolicitednode(ip6_current_dest_addr())) {
484 if (ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) &&
485 ip6_addr_cmp_solicitednode(ip6_current_dest_addr(), netif_ip6_addr(inp, i))) {
508 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
509 ip6_addr_cmp(ip6_current_dest_addr(), netif_ip6_addr(
netif, i))) {
516 if (ip6_addr_islinklocal(ip6_current_dest_addr())
518 || ip6_addr_isloopback(ip6_current_dest_addr())
545 if (ip6_addr_isany(ip6_current_src_addr()) &&
546 (!ip6_addr_issolicitednode(ip6_current_dest_addr()))) {
552 goto ip6_input_cleanup;
559 #if LWIP_IPV6_FORWARD
561 if (!ip6_addr_ismulticast(ip6_current_dest_addr())) {
563 ip6_forward(p, ip6hdr, inp);
567 goto ip6_input_cleanup;
598 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
604 goto ip6_input_cleanup;
621 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
627 goto ip6_input_cleanup;
644 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
650 goto ip6_input_cleanup;
664 nexth = frag_hdr->_nexth;
673 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
679 goto ip6_input_cleanup;
683 if ((frag_hdr->_fragment_offset &
695 goto ip6_input_cleanup;
707 LWIP_DEBUGF(
IP6_DEBUG, (
"ip6_input: packet with Fragment header dropped (with LWIP_IPV6_REASS==0)\n"));
711 goto ip6_input_cleanup;
733 if (raw_input(p, inp) == 0)
767 if ((!ip6_addr_ismulticast(ip6_current_dest_addr())) &&
785 ip6_addr_set_zero(ip6_current_src_addr());
786 ip6_addr_set_zero(ip6_current_dest_addr());
817 ip6_output_if(
struct pbuf *p,
const ip6_addr_t *src,
const ip6_addr_t *dest,
821 const ip6_addr_t *src_used = src;
823 if (src !=
NULL && ip6_addr_isany(src)) {
825 if ((src_used ==
NULL) || ip6_addr_isany(src_used)) {
833 return ip6_output_if_src(p, src_used, dest, hl, tc, nexth,
netif);
841 ip6_output_if_src(
struct pbuf *p,
const ip6_addr_t *src,
const ip6_addr_t *dest,
846 ip6_addr_t dest_addr;
860 LWIP_ASSERT(
"check that first pbuf can hold struct ip6_hdr",
867 ip6_addr_copy(ip6hdr->dest, *dest);
876 ip6_addr_copy(ip6hdr->src, *src);
881 ip6_addr_copy(dest_addr, ip6hdr->dest);
893 #if !LWIP_HAVE_LOOPIF
894 if (ip6_addr_isloopback(dest)) {
895 return netif_loop_output(
netif, p);
899 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif, i)) &&
900 ip6_addr_cmp(dest, netif_ip6_addr(
netif, i))) {
903 return netif_loop_output(
netif, p);
911 return ip6_frag(p,
netif, dest);
938 ip6_output(
struct pbuf *p,
const ip6_addr_t *src,
const ip6_addr_t *dest,
943 ip6_addr_t src_addr, dest_addr;
948 netif = ip6_route(src, dest);
952 ip6_addr_copy(src_addr, ip6hdr->src);
953 ip6_addr_copy(dest_addr, ip6hdr->dest);
954 netif = ip6_route(&src_addr, &dest_addr);
959 IP6_ADDR_BLOCK1(dest),
960 IP6_ADDR_BLOCK2(dest),
961 IP6_ADDR_BLOCK3(dest),
962 IP6_ADDR_BLOCK4(dest),
963 IP6_ADDR_BLOCK5(dest),
964 IP6_ADDR_BLOCK6(dest),
965 IP6_ADDR_BLOCK7(dest),
966 IP6_ADDR_BLOCK8(dest)));
971 return ip6_output_if(p, src, dest, hl, tc, nexth,
netif);
975 #if LWIP_NETIF_HWADDRHINT
996 ip6_output_hinted(
struct pbuf *p,
const ip6_addr_t *src,
const ip6_addr_t *dest,
1001 ip6_addr_t src_addr, dest_addr;
1007 netif = ip6_route(src, dest);
1011 ip6_addr_copy(src_addr, ip6hdr->src);
1012 ip6_addr_copy(dest_addr, ip6hdr->dest);
1013 netif = ip6_route(&src_addr, &dest_addr);
1018 IP6_ADDR_BLOCK1(dest),
1019 IP6_ADDR_BLOCK2(dest),
1020 IP6_ADDR_BLOCK3(dest),
1021 IP6_ADDR_BLOCK4(dest),
1022 IP6_ADDR_BLOCK5(dest),
1023 IP6_ADDR_BLOCK6(dest),
1024 IP6_ADDR_BLOCK7(dest),
1025 IP6_ADDR_BLOCK8(dest)));
1031 err = ip6_output_if(p, src, dest, hl, tc, nexth,
netif);
1050 ip6_options_add_hbh_ra(
struct pbuf *p,
u8_t nexth,
u8_t value)
1064 hbh_hdr->_nexth = nexth;
1067 hbh_hdr->_ra_opt_dlen = 2;
1068 hbh_hdr->_ra_opt_data = value;
1070 hbh_hdr->_padn_opt_dlen = 0;
1081 ip6_debug_print(
struct pbuf *p)
1098 IP6_ADDR_BLOCK1(&(ip6hdr->src)),
1099 IP6_ADDR_BLOCK2(&(ip6hdr->src)),
1100 IP6_ADDR_BLOCK3(&(ip6hdr->src)),
1101 IP6_ADDR_BLOCK4(&(ip6hdr->src))));
1103 IP6_ADDR_BLOCK5(&(ip6hdr->src)),
1104 IP6_ADDR_BLOCK6(&(ip6hdr->src)),
1105 IP6_ADDR_BLOCK7(&(ip6hdr->src)),
1106 IP6_ADDR_BLOCK8(&(ip6hdr->src))));
1109 IP6_ADDR_BLOCK1(&(ip6hdr->dest)),
1110 IP6_ADDR_BLOCK2(&(ip6hdr->dest)),
1111 IP6_ADDR_BLOCK3(&(ip6hdr->dest)),
1112 IP6_ADDR_BLOCK4(&(ip6hdr->dest))));
1114 IP6_ADDR_BLOCK5(&(ip6hdr->dest)),
1115 IP6_ADDR_BLOCK6(&(ip6hdr->dest)),
1116 IP6_ADDR_BLOCK7(&(ip6hdr->dest)),
1117 IP6_ADDR_BLOCK8(&(ip6hdr->dest))));