Lines Matching +full:0 +full:- +full:576
10 * SPDX-License-Identifier: Apache-2.0
20 * @version 1.0.0
40 #define NET_VLAN_TAG_UNSPEC 0x0fff
44 #define PF_UNSPEC 0 /**< Unspecified protocol family. */
50 #define PF_LOCAL 6 /**< Inter-process communication */
51 #define PF_UNIX PF_LOCAL /**< Inter-process communication */
60 #define AF_LOCAL PF_LOCAL /**< Inter-process communication */
61 #define AF_UNIX PF_UNIX /**< Inter-process communication */
65 IPPROTO_IP = 0, /**< IP protocol (pseudo-val for setsockopt() */
94 /** @brief Convert 16-bit value from network to host byte order.
102 /** @brief Convert 32-bit value from network to host byte order.
110 /** @brief Convert 64-bit value from network to host byte order.
118 /** @brief Convert 16-bit value from host to network byte order.
126 /** @brief Convert 32-bit value from host to network byte order.
134 /** @brief Convert 64-bit value from host to network byte order.
199 uint16_t sll_protocol; /**< Physical-layer protocol */
204 uint8_t sll_addr[8]; /**< Physical-layer address, big endian */
227 uint16_t sll_protocol; /**< Physical-layer protocol */
232 uint8_t *sll_addr; /**< Physical-layer address, big endian */
271 int cmsg_type; /**< Protocol-specific type */
296 ((msghdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
297 (struct cmsghdr *)((msghdr)->msg_control) : NULL)
307 (((uint8_t *)(cmsg) + ALIGN_H((cmsg)->cmsg_len) + \
309 (uint8_t *)((msghdr)->msg_control) + (msghdr)->msg_controllen) ? \
312 ALIGN_H((cmsg)->cmsg_len))))
346 #define PACKET_HOST 0 /* To us */
411 char data[NET_SOCKADDR_MAX_SIZE - sizeof(sa_family_t)];
419 char data[NET_SOCKADDR_PTR_MAX_SIZE - sizeof(sa_family_t)];
425 char data[NET_SOCKADDR_MAX_SIZE - sizeof(sa_family_t)];
431 char sun_path[NET_SOCKADDR_MAX_SIZE - sizeof(sa_family_t)];
451 #define IN6ADDR_ANY_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, \
452 0, 0, 0, 0, 0, 0, 0 } } }
455 #define IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, \
456 0, 0, 0, 0, 0, 0, 0, 0, 1 } } }
459 #define INADDR_ANY 0
462 #define INADDR_BROADCAST 0xffffffff
468 #define INADDR_LOOPBACK_INIT { { { 127, 0, 0, 1 } } }
499 NET_IPV4_MTU = 576,
505 NET_PRIORITY_BE = 0, /**< Best effort (default) */
527 NET_ADDR_ANY_STATE = -1, /**< Default (invalid) address type */
528 NET_ADDR_TENTATIVE = 0, /**< Tentative address */
536 NET_ADDR_ANY = 0,
603 uint8_t optdata[0];
626 #define NET_IPV6_NEXTHDR_HBHO 0
663 #define NET_IPV6H_LENGTH_OFFSET 0x04 /* Offset of the Length field in the IPv6 header */
665 #define NET_IPV6_FRAGH_OFFSET_MASK 0xfff8 /* Mask for the 13-bit Fragment Offset field */
666 #define NET_IPV4_FRAGH_OFFSET_MASK 0x1fff /* Mask for the 13-bit Fragment Offset field */
667 #define NET_IPV4_MORE_FRAG_MASK 0x2000 /* Mask for the 1-bit More Fragments field */
668 #define NET_IPV4_DO_NOT_FRAG_MASK 0x4000 /* Mask for the 1-bit Do Not Fragment field */
681 return UNALIGNED_GET(&addr->s6_addr32[0]) == 0 && in net_ipv6_is_addr_loopback()
682 UNALIGNED_GET(&addr->s6_addr32[1]) == 0 && in net_ipv6_is_addr_loopback()
683 UNALIGNED_GET(&addr->s6_addr32[2]) == 0 && in net_ipv6_is_addr_loopback()
684 ntohl(UNALIGNED_GET(&addr->s6_addr32[3])) == 1; in net_ipv6_is_addr_loopback()
696 return addr->s6_addr[0] == 0xFF; in net_ipv6_is_addr_mcast()
746 uint8_t bits = 128 - length; in net_ipv6_is_prefix()
767 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain; in net_ipv6_is_prefix()
784 uint8_t bits = 128 - prefix_len; in net_ipv6_addr_prefix_mask()
789 memset(outaddr, 0, 16U); in net_ipv6_addr_prefix_mask()
800 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain; in net_ipv6_addr_prefix_mask()
813 return addr->s4_addr[0] == 127U; in net_ipv4_is_addr_loopback()
825 return UNALIGNED_GET(&addr->s_addr) == 0; in net_ipv4_is_addr_unspecified()
837 return (ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xF0000000) == 0xE0000000; in net_ipv4_is_addr_mcast()
849 return (ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xFFFF0000) == 0xA9FE0000; in net_ipv4_is_ll_addr()
865 masked_24 = ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xFFFFFF00; in net_ipv4_is_private_addr()
866 masked_16 = masked_24 & 0xFFFF0000; in net_ipv4_is_private_addr()
867 masked_12 = masked_24 & 0xFFF00000; in net_ipv4_is_private_addr()
868 masked_10 = masked_24 & 0xFFC00000; in net_ipv4_is_private_addr()
869 masked_8 = masked_24 & 0xFF000000; in net_ipv4_is_private_addr()
871 return masked_8 == 0x0A000000 || /* 10.0.0.0/8 */ in net_ipv4_is_private_addr()
872 masked_10 == 0x64400000 || /* 100.64.0.0/10 */ in net_ipv4_is_private_addr()
873 masked_12 == 0xAC100000 || /* 172.16.0.0/12 */ in net_ipv4_is_private_addr()
874 masked_16 == 0xC0A80000 || /* 192.168.0.0/16 */ in net_ipv4_is_private_addr()
875 masked_24 == 0xC0000200 || /* 192.0.2.0/24 */ in net_ipv4_is_private_addr()
876 masked_24 == 0xC0336400 || /* 192.51.100.0/24 */ in net_ipv4_is_private_addr()
877 masked_24 == 0xCB007100; /* 203.0.113.0/24 */ in net_ipv4_is_private_addr()
926 return UNALIGNED_GET(&addr1->s_addr) == UNALIGNED_GET(&addr2->s_addr); in net_ipv4_addr_cmp()
982 return UNALIGNED_GET(&addr->s6_addr16[0]) == htons(0xFE80); in net_ipv6_is_ll_addr()
994 return UNALIGNED_GET(&addr->s6_addr16[0]) == htons(0xFEC0); in net_ipv6_is_sl_addr()
1007 return addr->s6_addr[0] == 0xFD; in net_ipv6_is_ula_addr()
1019 return (addr->s6_addr[0] & 0xE0) == 0x20; in net_ipv6_is_global_addr()
1035 masked_32 = ntohl(UNALIGNED_GET(&addr->s6_addr32[0])); in net_ipv6_is_private_addr()
1036 masked_7 = masked_32 & 0xfc000000; in net_ipv6_is_private_addr()
1038 return masked_32 == 0x20010db8 || /* 2001:db8::/32 */ in net_ipv6_is_private_addr()
1039 masked_7 == 0xfc000000; /* fc00::/7 */ in net_ipv6_is_private_addr()
1147 return UNALIGNED_GET(&addr->s6_addr32[0]) == 0 && in net_ipv6_is_addr_unspecified()
1148 UNALIGNED_GET(&addr->s6_addr32[1]) == 0 && in net_ipv6_is_addr_unspecified()
1149 UNALIGNED_GET(&addr->s6_addr32[2]) == 0 && in net_ipv6_is_addr_unspecified()
1150 UNALIGNED_GET(&addr->s6_addr32[3]) == 0; in net_ipv6_is_addr_unspecified()
1155 * FF02:0:0:0:0:1:FFXX:XXXX defined in RFC 3513
1163 return UNALIGNED_GET(&addr->s6_addr32[0]) == htonl(0xff020000) && in net_ipv6_is_addr_solicited_node()
1164 UNALIGNED_GET(&addr->s6_addr32[1]) == 0x00000000 && in net_ipv6_is_addr_solicited_node()
1165 UNALIGNED_GET(&addr->s6_addr32[2]) == htonl(0x00000001) && in net_ipv6_is_addr_solicited_node()
1166 ((UNALIGNED_GET(&addr->s6_addr32[3]) & htonl(0xff000000)) == in net_ipv6_is_addr_solicited_node()
1167 htonl(0xff000000)); in net_ipv6_is_addr_solicited_node()
1183 return (addr->s6_addr[0] == 0xff) && ((addr->s6_addr[1] & 0xF) == scope); in net_ipv6_is_addr_mcast_scope()
1198 return (addr_1->s6_addr[0] == 0xff) && (addr_2->s6_addr[0] == 0xff) && in net_ipv6_is_same_mcast_scope()
1199 (addr_1->s6_addr[1] == addr_2->s6_addr[1]); in net_ipv6_is_same_mcast_scope()
1211 return net_ipv6_is_addr_mcast_scope(addr, 0x0e); in net_ipv6_is_addr_mcast_global()
1225 return net_ipv6_is_addr_mcast_scope(addr, 0x01); in net_ipv6_is_addr_mcast_iface()
1239 return net_ipv6_is_addr_mcast_scope(addr, 0x02); in net_ipv6_is_addr_mcast_link()
1243 * @brief Check if the IPv6 address is a mesh-local scope multicast
1248 * @return True if the address is a mesh-local scope multicast address,
1253 return net_ipv6_is_addr_mcast_scope(addr, 0x03); in net_ipv6_is_addr_mcast_mesh()
1267 return net_ipv6_is_addr_mcast_scope(addr, 0x05); in net_ipv6_is_addr_mcast_site()
1281 return net_ipv6_is_addr_mcast_scope(addr, 0x08); in net_ipv6_is_addr_mcast_org()
1297 return UNALIGNED_GET(&addr->s6_addr16[1]) == group->s6_addr16[1] && in net_ipv6_is_addr_mcast_group()
1298 UNALIGNED_GET(&addr->s6_addr16[2]) == group->s6_addr16[2] && in net_ipv6_is_addr_mcast_group()
1299 UNALIGNED_GET(&addr->s6_addr16[3]) == group->s6_addr16[3] && in net_ipv6_is_addr_mcast_group()
1300 UNALIGNED_GET(&addr->s6_addr32[1]) == group->s6_addr32[1] && in net_ipv6_is_addr_mcast_group()
1301 UNALIGNED_GET(&addr->s6_addr32[2]) == group->s6_addr32[1] && in net_ipv6_is_addr_mcast_group()
1302 UNALIGNED_GET(&addr->s6_addr32[3]) == group->s6_addr32[3]; in net_ipv6_is_addr_mcast_group()
1317 { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, in net_ipv6_is_addr_mcast_all_nodes_group()
1318 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } } in net_ipv6_is_addr_mcast_all_nodes_group()
1358 * FF02:0:0:0:0:1:FFXX:XXXX defined in RFC 3513
1367 dst->s6_addr[0] = 0xFF; in net_ipv6_addr_create_solicited_node()
1368 dst->s6_addr[1] = 0x02; in net_ipv6_addr_create_solicited_node()
1369 UNALIGNED_PUT(0, &dst->s6_addr16[1]); in net_ipv6_addr_create_solicited_node()
1370 UNALIGNED_PUT(0, &dst->s6_addr16[2]); in net_ipv6_addr_create_solicited_node()
1371 UNALIGNED_PUT(0, &dst->s6_addr16[3]); in net_ipv6_addr_create_solicited_node()
1372 UNALIGNED_PUT(0, &dst->s6_addr16[4]); in net_ipv6_addr_create_solicited_node()
1373 dst->s6_addr[10] = 0U; in net_ipv6_addr_create_solicited_node()
1374 dst->s6_addr[11] = 0x01; in net_ipv6_addr_create_solicited_node()
1375 dst->s6_addr[12] = 0xFF; in net_ipv6_addr_create_solicited_node()
1376 dst->s6_addr[13] = src->s6_addr[13]; in net_ipv6_addr_create_solicited_node()
1377 UNALIGNED_PUT(UNALIGNED_GET(&src->s6_addr16[7]), &dst->s6_addr16[7]); in net_ipv6_addr_create_solicited_node()
1380 /** @brief Construct an IPv6 address from eight 16-bit words.
1383 * @param addr0 16-bit word which is part of the address
1384 * @param addr1 16-bit word which is part of the address
1385 * @param addr2 16-bit word which is part of the address
1386 * @param addr3 16-bit word which is part of the address
1387 * @param addr4 16-bit word which is part of the address
1388 * @param addr5 16-bit word which is part of the address
1389 * @param addr6 16-bit word which is part of the address
1390 * @param addr7 16-bit word which is part of the address
1398 UNALIGNED_PUT(htons(addr0), &addr->s6_addr16[0]); in net_ipv6_addr_create()
1399 UNALIGNED_PUT(htons(addr1), &addr->s6_addr16[1]); in net_ipv6_addr_create()
1400 UNALIGNED_PUT(htons(addr2), &addr->s6_addr16[2]); in net_ipv6_addr_create()
1401 UNALIGNED_PUT(htons(addr3), &addr->s6_addr16[3]); in net_ipv6_addr_create()
1402 UNALIGNED_PUT(htons(addr4), &addr->s6_addr16[4]); in net_ipv6_addr_create()
1403 UNALIGNED_PUT(htons(addr5), &addr->s6_addr16[5]); in net_ipv6_addr_create()
1404 UNALIGNED_PUT(htons(addr6), &addr->s6_addr16[6]); in net_ipv6_addr_create()
1405 UNALIGNED_PUT(htons(addr7), &addr->s6_addr16[7]); in net_ipv6_addr_create()
1415 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001); in net_ipv6_addr_create_ll_allnodes_mcast()
1425 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002); in net_ipv6_addr_create_ll_allrouters_mcast()
1437 net_ipv6_addr_create(addr6, 0, 0, 0, 0, 0, 0xffff, in net_ipv6_addr_create_v4_mapped()
1438 ntohs(addr4->s4_addr16[0]), in net_ipv6_addr_create_v4_mapped()
1439 ntohs(addr4->s4_addr16[1])); in net_ipv6_addr_create_v4_mapped()
1452 if (UNALIGNED_GET(&addr->s6_addr32[0]) == 0 && in net_ipv6_addr_is_v4_mapped()
1453 UNALIGNED_GET(&addr->s6_addr32[1]) == 0 && in net_ipv6_addr_is_v4_mapped()
1454 UNALIGNED_GET(&addr->s6_addr16[5]) == 0xffff) { in net_ipv6_addr_is_v4_mapped()
1463 * Interface identifier is either generated from EUI-64 (MAC) defined
1470 * @param network_id_len Network identifier length, if set to 0 then the
1472 * @param dad_counter Duplicate Address Detection counter value, can be set to 0
1477 * @return 0 if ok, < 0 if error
1495 (void)net_ipv6_addr_generate_iid(NULL, NULL, NULL, 0, 0, addr, lladdr); in net_ipv6_addr_create_iid()
1510 switch (lladdr->len) { in net_ipv6_addr_based_on_ll()
1512 if (!memcmp(&addr->s6_addr[14], lladdr->addr, lladdr->len) && in net_ipv6_addr_based_on_ll()
1513 addr->s6_addr[8] == 0U && in net_ipv6_addr_based_on_ll()
1514 addr->s6_addr[9] == 0U && in net_ipv6_addr_based_on_ll()
1515 addr->s6_addr[10] == 0U && in net_ipv6_addr_based_on_ll()
1516 addr->s6_addr[11] == 0xff && in net_ipv6_addr_based_on_ll()
1517 addr->s6_addr[12] == 0xfe) { in net_ipv6_addr_based_on_ll()
1523 if (lladdr->type == NET_LINK_ETHERNET) { in net_ipv6_addr_based_on_ll()
1524 if (!memcmp(&addr->s6_addr[9], &lladdr->addr[1], 2) && in net_ipv6_addr_based_on_ll()
1525 !memcmp(&addr->s6_addr[13], &lladdr->addr[3], 3) && in net_ipv6_addr_based_on_ll()
1526 addr->s6_addr[11] == 0xff && in net_ipv6_addr_based_on_ll()
1527 addr->s6_addr[12] == 0xfe && in net_ipv6_addr_based_on_ll()
1528 (addr->s6_addr[8] ^ 0x02) == lladdr->addr[0]) { in net_ipv6_addr_based_on_ll()
1535 if (!memcmp(&addr->s6_addr[9], &lladdr->addr[1], in net_ipv6_addr_based_on_ll()
1536 lladdr->len - 1) && in net_ipv6_addr_based_on_ll()
1537 (addr->s6_addr[8] ^ 0x02) == lladdr->addr[0]) { in net_ipv6_addr_based_on_ll()
1640 * @return 0 if ok, < 0 if error
1689 * @return 0 if ok, <0 if error
1702 * @return < 0 if seq1 < seq2, 0 if seq1 == seq2, > 0 if seq > seq2
1706 return (int32_t)(seq1 - seq2); in net_tcp_seq_cmp()
1721 return net_tcp_seq_cmp(seq1, seq2) > 0; in net_tcp_seq_greater()
1733 * @return 0 if ok, <0 if error
1818 * @return 0 if ok, <0 if error
1829 return -ENOTSUP; in net_ipv6_pe_add_filter()
1838 * @return 0 if ok, <0 if error
1847 return -ENOTSUP; in net_ipv6_pe_del_filter()