63#ifdef LWIP_HOOK_FILENAME
64#include LWIP_HOOK_FILENAME
86ip6_route(
const ip6_addr_t *
src,
const ip6_addr_t *
dest)
112 if (ip6_addr_has_zone(
dest)) {
113 IP6_ADDR_ZONECHECK(
dest);
143 if (ip6_addr_has_scope(
dest, IP6_UNKNOWN) ||
144 ip6_addr_has_scope(
src, IP6_UNICAST) ||
146 if (ip6_addr_islinklocal(
dest) || ip6_addr_ismulticast_iflocal(
dest) ||
147 ip6_addr_ismulticast_linklocal(
dest) || ip6_addr_islinklocal(
src) ||
149 ip6_addr_isloopback(
src)) {
151 if (ip6_addr_has_zone(
src)) {
168 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif,
i)) &&
169 ip6_addr_zoneless_eq(
src, netif_ip6_addr(
netif,
i))) {
181 IP6_ADDR_ZONECHECK(
src);
183#ifdef LWIP_HOOK_IP6_ROUTE
201 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif,
i)) &&
202 ip6_addr_net_eq(
dest, netif_ip6_addr(
netif,
i)) &&
203 (netif_ip6_addr_isstatic(
netif,
i) ||
204 ip6_addr_nethost_eq(
dest, netif_ip6_addr(
netif,
i)))) {
218 if (!ip6_addr_isany(
src)) {
224 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif,
i)) &&
225 ip6_addr_eq(
src, netif_ip6_addr(
netif,
i))) {
232#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
234 if (ip6_addr_isloopback(
dest)) {
283ip6_select_source_address(
struct netif *
netif,
const ip6_addr_t *
dest)
286 const ip6_addr_t *cand_addr;
287 s8_t dest_scope, cand_scope;
288 s8_t best_scope = IP6_MULTICAST_SCOPE_RESERVED;
289 u8_t i, cand_pref, cand_bits;
295 if (ip6_addr_isglobal(
dest)) {
296 dest_scope = IP6_MULTICAST_SCOPE_GLOBAL;
297 }
else if (ip6_addr_islinklocal(
dest) || ip6_addr_isloopback(
dest)) {
298 dest_scope = IP6_MULTICAST_SCOPE_LINK_LOCAL;
299 }
else if (ip6_addr_isuniquelocal(
dest)) {
300 dest_scope = IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL;
301 }
else if (ip6_addr_ismulticast(
dest)) {
302 dest_scope = ip6_addr_multicast_scope(
dest);
303 }
else if (ip6_addr_issitelocal(
dest)) {
304 dest_scope = IP6_MULTICAST_SCOPE_SITE_LOCAL;
307 dest_scope = IP6_MULTICAST_SCOPE_GLOBAL;
314 if (!ip6_addr_isvalid(netif_ip6_addr_state(
netif,
i))) {
318 cand_addr = netif_ip6_addr(
netif,
i);
319 if (ip6_addr_isglobal(cand_addr)) {
320 cand_scope = IP6_MULTICAST_SCOPE_GLOBAL;
321 }
else if (ip6_addr_islinklocal(cand_addr)) {
322 cand_scope = IP6_MULTICAST_SCOPE_LINK_LOCAL;
323 }
else if (ip6_addr_isuniquelocal(cand_addr)) {
324 cand_scope = IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL;
325 }
else if (ip6_addr_issitelocal(cand_addr)) {
326 cand_scope = IP6_MULTICAST_SCOPE_SITE_LOCAL;
329 cand_scope = IP6_MULTICAST_SCOPE_RESERVEDF;
331 cand_pref = ip6_addr_ispreferred(netif_ip6_addr_state(
netif,
i));
335 cand_bits = ip6_addr_net_zoneless_eq(cand_addr,
dest);
336 if (cand_bits && ip6_addr_nethost_eq(cand_addr,
dest)) {
337 return netif_ip_addr6(
netif,
i);
339 if ((best_addr ==
NULL) ||
340 ((cand_scope < best_scope) && (cand_scope >= dest_scope)) ||
341 ((cand_scope > best_scope) && (best_scope < dest_scope)) ||
342 ((cand_scope == best_scope) && ((cand_pref > best_pref) ||
343 ((cand_pref == best_pref) && (cand_bits > best_bits))))) {
345 best_addr = netif_ip_addr6(
netif,
i);
346 best_scope = cand_scope;
347 best_pref = cand_pref;
348 best_bits = cand_bits;
371 if (ip6_addr_islinklocal(ip6_current_dest_addr()) ||
372 ip6_addr_isloopback(ip6_current_dest_addr())) {
380 netif = ip6_route(IP6_ADDR_ANY6, ip6_current_dest_addr());
383 IP6_ADDR_BLOCK1(ip6_current_dest_addr()),
384 IP6_ADDR_BLOCK2(ip6_current_dest_addr()),
385 IP6_ADDR_BLOCK3(ip6_current_dest_addr()),
386 IP6_ADDR_BLOCK4(ip6_current_dest_addr()),
387 IP6_ADDR_BLOCK5(ip6_current_dest_addr()),
388 IP6_ADDR_BLOCK6(ip6_current_dest_addr()),
389 IP6_ADDR_BLOCK7(ip6_current_dest_addr()),
390 IP6_ADDR_BLOCK8(ip6_current_dest_addr())));
406 if ((ip6_addr_has_zone(ip6_current_src_addr()) &&
407 !ip6_addr_test_zone(ip6_current_src_addr(),
netif)) ||
408 ip6_addr_isloopback(ip6_current_src_addr())) {
409 LWIP_DEBUGF(
IP6_DEBUG, (
"ip6_forward: not forwarding packet beyond its source address zone.\n"));
450 IP6_ADDR_BLOCK1(ip6_current_dest_addr()),
451 IP6_ADDR_BLOCK2(ip6_current_dest_addr()),
452 IP6_ADDR_BLOCK3(ip6_current_dest_addr()),
453 IP6_ADDR_BLOCK4(ip6_current_dest_addr()),
454 IP6_ADDR_BLOCK5(ip6_current_dest_addr()),
455 IP6_ADDR_BLOCK6(ip6_current_dest_addr()),
456 IP6_ADDR_BLOCK7(ip6_current_dest_addr()),
457 IP6_ADDR_BLOCK8(ip6_current_dest_addr())));
460 netif->output_ip6(
netif,
p, ip6_current_dest_addr());
479 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif,
i)) &&
480 ip6_addr_eq(ip6_current_dest_addr(), netif_ip6_addr(
netif,
i))
481#
if IPV6_CUSTOM_SCOPES
482 && (!ip6_addr_has_zone(ip6_current_src_addr()) ||
483 ip6_addr_test_zone(ip6_current_src_addr(),
netif))
514 u16_t hlen, hlen_tot;
520 raw_input_state_t raw_status;
528 ip6hdr = (
struct ip6_hdr *)
p->payload;
538#ifdef LWIP_HOOK_IP6_INPUT
539 if (LWIP_HOOK_IP6_INPUT(
p, inp)) {
549 (
"IPv6 header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet dropped.\n",
554 (
"IPv6 (plen %"U16_F") is longer than pbuf (len %"U16_F"), IP packet dropped.\n",
574 if (ip6_addr_isipv4mappedipv6(
ip_2_ip6(&
ip_data.current_iphdr_dest)) ||
585 ip6_addr_assign_zone(
ip_2_ip6(&
ip_data.current_iphdr_dest), IP6_UNKNOWN, inp);
586 ip6_addr_assign_zone(
ip_2_ip6(&
ip_data.current_iphdr_src), IP6_UNICAST, inp);
589 ip_data.current_ip6_header = ip6hdr;
593 ip_data.current_input_netif = inp;
596 if (ip6_addr_ismulticast(ip6_current_dest_addr())) {
598 if (ip6_addr_isallnodes_iflocal(ip6_current_dest_addr()) ||
599 ip6_addr_isallnodes_linklocal(ip6_current_dest_addr())) {
603 else if (mld6_lookfor_group(inp, ip6_current_dest_addr())) {
607 else if (ip6_addr_issolicitednode(ip6_current_dest_addr())) {
613 if (ip6_addr_isvalid(netif_ip6_addr_state(inp,
i)) &&
614 ip6_addr_solicitednode_eq(ip6_current_dest_addr(), netif_ip6_addr(inp,
i))) {
629 if (ip6_input_accept(inp)) {
633#if !IPV6_CUSTOM_SCOPES
637 if (ip6_addr_islinklocal(ip6_current_dest_addr()) ||
638 ip6_addr_islinklocal(ip6_current_src_addr())) {
642#if !LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF
649 if (ip6_addr_isloopback(ip6_current_dest_addr()) ||
650 ip6_addr_isloopback(ip6_current_src_addr())) {
654#if !LWIP_SINGLE_NETIF
660 if (ip6_input_accept(
netif)) {
672 if (ip6_addr_isany(ip6_current_src_addr()) &&
673 (!ip6_addr_issolicitednode(ip6_current_dest_addr()))) {
679 goto ip6_input_cleanup;
688 if (!ip6_addr_ismulticast(ip6_current_dest_addr())) {
690 ip6_forward(
p, ip6hdr, inp);
694 goto ip6_input_cleanup;
731 hlen = (
u16_t)(8 * (1 + hbh_hdr->_hlen));
733 if ((
p->len < 8) || (hlen >
p->len)) {
735 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
741 goto ip6_input_cleanup;
744 hlen_tot = (
u16_t)(hlen_tot + hlen);
748 while (opt_offset < hlen)
777 goto ip6_input_cleanup;
784 goto ip6_input_cleanup;
787 if (!ip6_addr_ismulticast(ip6_current_dest_addr())) {
793 goto ip6_input_cleanup;
821 hlen = 8 * (1 + dest_hdr->_hlen);
822 if ((
p->len < 8) || (hlen >
p->len)) {
824 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
830 goto ip6_input_cleanup;
833 hlen_tot = (
u16_t)(hlen_tot + hlen);
837 while (opt_offset < hlen)
871 goto ip6_input_cleanup;
878 goto ip6_input_cleanup;
881 if (!ip6_addr_ismulticast(ip6_current_dest_addr())) {
887 goto ip6_input_cleanup;
914 hlen = 8 * (1 + rout_hdr->_hlen);
916 if ((
p->len < 8) || (hlen >
p->len)) {
918 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
924 goto ip6_input_cleanup;
928 hlen_tot = (
u16_t)(hlen_tot + hlen);
933 if (rout_hdr->_hlen & 0x1) {
939 goto ip6_input_cleanup;
955 goto ip6_input_cleanup;
978 (
"IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n",
984 goto ip6_input_cleanup;
987 hlen_tot = (
u16_t)(hlen_tot + hlen);
996 goto ip6_input_cleanup;
1000 if ((frag_hdr->_fragment_offset &
1007 ip_data.current_ip_header_tot_len = hlen_tot;
1011 goto ip6_input_cleanup;
1016 ip6hdr = (
struct ip6_hdr *)
p->payload;
1023 LWIP_DEBUGF(
IP6_DEBUG, (
"ip6_input: packet with Fragment header dropped (with LWIP_IPV6_REASS==0)\n"));
1027 goto ip6_input_cleanup;
1039 LWIP_DEBUGF(
IP6_DEBUG, (
"ip6_input: packet with Hop-by-Hop options header dropped (only valid as a first option)\n"));
1042 goto ip6_input_cleanup;
1049 ip_data.current_ip_header_tot_len = hlen_tot;
1055 raw_status = raw_input(
p, inp);
1056 if (raw_status != RAW_INPUT_EATEN)
1082 icmp6_input(
p, inp);
1087 if (raw_status == RAW_INPUT_DELIVERED) {
1096 if ((!ip6_addr_ismulticast(ip6_current_dest_addr())) &&
1114 ip_data.current_ip_header_tot_len = 0;
1115 ip6_addr_set_zero(ip6_current_src_addr());
1116 ip6_addr_set_zero(ip6_current_dest_addr());
1149ip6_output_if(
struct pbuf *
p,
const ip6_addr_t *
src,
const ip6_addr_t *
dest,
1153 const ip6_addr_t *src_used =
src;
1157 if ((src_used ==
NULL) || ip6_addr_isany(src_used)) {
1165 return ip6_output_if_src(
p, src_used,
dest, hl,
tc, nexth,
netif);
1173ip6_output_if_src(
struct pbuf *
p,
const ip6_addr_t *
src,
const ip6_addr_t *
dest,
1178 ip6_addr_t dest_addr;
1192 if (ip6_addr_lacks_zone(
dest, IP6_UNKNOWN)) {
1193 ip6_addr_copy(dest_addr, *
dest);
1194 ip6_addr_assign_zone(&dest_addr, IP6_UNKNOWN,
netif);
1206 ip6hdr = (
struct ip6_hdr *)
p->payload;
1207 LWIP_ASSERT(
"check that first pbuf can hold struct ip6_hdr",
1208 (
p->len >=
sizeof(
struct ip6_hdr)));
1214 ip6_addr_copy_to_packed(ip6hdr->dest, *
dest);
1220 src = IP6_ADDR_ANY6;
1223 ip6_addr_copy_to_packed(ip6hdr->src, *
src);
1227 ip6hdr = (
struct ip6_hdr *)
p->payload;
1228 ip6_addr_copy_from_packed(dest_addr, ip6hdr->dest);
1229 ip6_addr_assign_zone(&dest_addr, IP6_UNKNOWN,
netif);
1241#if !LWIP_HAVE_LOOPIF
1242 if (ip6_addr_isloopback(
dest)) {
1243 return netif_loop_output(
netif,
p);
1247 if (ip6_addr_isvalid(netif_ip6_addr_state(
netif,
i)) &&
1248 ip6_addr_eq(
dest, netif_ip6_addr(
netif,
i))) {
1251 return netif_loop_output(
netif,
p);
1255#if LWIP_MULTICAST_TX_OPTIONS
1257 netif_loop_output(
netif,
p);
1263 if (netif_mtu6(
netif) && (
p->tot_len > nd6_get_destination_mtu(
dest,
netif))) {
1291ip6_output(
struct pbuf *
p,
const ip6_addr_t *
src,
const ip6_addr_t *
dest,
1296 ip6_addr_t src_addr, dest_addr;
1304 ip6hdr = (
struct ip6_hdr *)
p->payload;
1305 ip6_addr_copy_from_packed(src_addr, ip6hdr->src);
1306 ip6_addr_copy_from_packed(dest_addr, ip6hdr->dest);
1307 netif = ip6_route(&src_addr, &dest_addr);
1313 IP6_ADDR_BLOCK1(
dest),
1314 IP6_ADDR_BLOCK2(
dest),
1315 IP6_ADDR_BLOCK3(
dest),
1316 IP6_ADDR_BLOCK4(
dest),
1317 IP6_ADDR_BLOCK5(
dest),
1318 IP6_ADDR_BLOCK6(
dest),
1319 IP6_ADDR_BLOCK7(
dest),
1320 IP6_ADDR_BLOCK8(
dest)));
1329#if LWIP_NETIF_USE_HINTS
1350ip6_output_hinted(
struct pbuf *
p,
const ip6_addr_t *
src,
const ip6_addr_t *
dest,
1355 ip6_addr_t src_addr, dest_addr;
1364 ip6hdr = (
struct ip6_hdr *)
p->payload;
1365 ip6_addr_copy_from_packed(src_addr, ip6hdr->src);
1366 ip6_addr_copy_from_packed(dest_addr, ip6hdr->dest);
1367 netif = ip6_route(&src_addr, &dest_addr);
1373 IP6_ADDR_BLOCK1(
dest),
1374 IP6_ADDR_BLOCK2(
dest),
1375 IP6_ADDR_BLOCK3(
dest),
1376 IP6_ADDR_BLOCK4(
dest),
1377 IP6_ADDR_BLOCK5(
dest),
1378 IP6_ADDR_BLOCK6(
dest),
1379 IP6_ADDR_BLOCK7(
dest),
1380 IP6_ADDR_BLOCK8(
dest)));
1435 opt_data[0] =
value;
1453ip6_debug_print(
struct pbuf *
p)
1470 IP6_ADDR_BLOCK1(&(ip6hdr->src)),
1471 IP6_ADDR_BLOCK2(&(ip6hdr->src)),
1472 IP6_ADDR_BLOCK3(&(ip6hdr->src)),
1473 IP6_ADDR_BLOCK4(&(ip6hdr->src))));
1475 IP6_ADDR_BLOCK5(&(ip6hdr->src)),
1476 IP6_ADDR_BLOCK6(&(ip6hdr->src)),
1477 IP6_ADDR_BLOCK7(&(ip6hdr->src)),
1478 IP6_ADDR_BLOCK8(&(ip6hdr->src))));
1481 IP6_ADDR_BLOCK1(&(ip6hdr->dest)),
1482 IP6_ADDR_BLOCK2(&(ip6hdr->dest)),
1483 IP6_ADDR_BLOCK3(&(ip6hdr->dest)),
1484 IP6_ADDR_BLOCK4(&(ip6hdr->dest))));
1486 IP6_ADDR_BLOCK5(&(ip6hdr->dest)),
1487 IP6_ADDR_BLOCK6(&(ip6hdr->dest)),
1488 IP6_ADDR_BLOCK7(&(ip6hdr->dest)),
1489 IP6_ADDR_BLOCK8(&(ip6hdr->dest))));
#define LWIP_DEBUGF(debug, message)
#define LWIP_ASSERT(message, assertion)
#define LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p)
struct ip_globals ip_data
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define LWIP_PACKED_CAST(target_type, val)
#define LWIP_UNUSED_ARG(x)
#define LWIP_DBG_LEVEL_SERIOUS
#define LWIP_DBG_LEVEL_WARNING
#define LWIP_IPV6_NUM_ADDRESSES
#define LWIP_ASSERT_CORE_LOCKED()
#define netif_is_up(netif)
void pbuf_realloc(struct pbuf *p, u16_t new_len)
u8_t pbuf_free(struct pbuf *p)
#define ip_addr_copy_from_ip6_packed(dest, src)
struct netif * netif_list
struct netif * netif_default
#define netif_is_link_up(netif)
#define NETIF_FOREACH(netif)
#define NETIF_RESET_HINTS(netif)
#define NETIF_SET_HINTS(netif, netifhint)
u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment)
u8_t pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
u8_t pbuf_add_header_force(struct pbuf *p, size_t header_size_increment)
#define PBUF_FLAG_MCASTLOOP
#define IP6_ROUTER_ALERT_OPTION
#define IP6_HOME_ADDRESS_OPTION
#define IP6_DEST_NEXTH(hdr)
#define IP6_HBH_NEXTH(hdr)
#define IP6_FRAG_MBIT(hdr)
#define IP6_ROUTER_ALERT_DLEN
#define IP6_NEXTH_FRAGMENT
#define IP6_NEXTH_HOPBYHOP
#define IP6H_PLEN_SET(hdr, plen)
#define IP6_ROUT_SEG_LEFT(hdr)
#define IP6_FRAG_OFFSET_MASK
#define IP6_NEXTH_ROUTING
#define IP6_FRAG_MORE_FLAG
#define IP6_OPT_TYPE(hdr)
#define IP6_NEXTH_UDPLITE
#define IP6_OPT_TYPE_ACTION(hdr)
#define IP6_ROUT_NEXTH(hdr)
#define IP6H_NEXTH_SET(hdr, nexth)
#define IP6H_VTCFL_SET(hdr, v, tc, fl)
#define IP6_FRAG_NEXTH(hdr)
#define IP6H_HOPLIM_SET(hdr, hl)
#define IP6_OPT_DLEN(hdr)
#define IP6_ROUT_TYPE(hdr)
#define IP6_NEXTH_DESTOPTS
#define IP6_FRAG_STATS_INC(x)