Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
IPv4/IPv6 primitives and helpers

IPv4/IPv6 primitives and helpers. More...

Data Structures

struct  in6_addr
 IPv6 address struct. More...
 
struct  in_addr
 IPv4 address struct. More...
 
struct  sockaddr_in6
 Socket address struct for IPv6. More...
 
struct  sockaddr_in
 Socket address struct for IPv4. More...
 
struct  sockaddr_ll
 Socket address struct for packet socket. More...
 
struct  iovec
 IO vector array element. More...
 
struct  msghdr
 Message struct. More...
 
struct  cmsghdr
 Control message ancillary data. More...
 
struct  sockaddr
 Generic sockaddr struct. More...
 
struct  net_tuple
 IPv6/IPv4 network connection tuple. More...
 

Macros

#define PF_UNSPEC   0
 Unspecified protocol family.
 
#define PF_INET   1
 IP protocol family version 4.
 
#define PF_INET6   2
 IP protocol family version 6.
 
#define PF_PACKET   3
 Packet family.
 
#define PF_CAN   4
 Controller Area Network.
 
#define PF_NET_MGMT   5
 Network management info.
 
#define PF_LOCAL   6
 Inter-process communication

 
#define PF_UNIX   PF_LOCAL
 Inter-process communication

 
#define AF_UNSPEC   PF_UNSPEC
 Unspecified address family.
 
#define AF_INET   PF_INET
 IP protocol family version 4.
 
#define AF_INET6   PF_INET6
 IP protocol family version 6.
 
#define AF_PACKET   PF_PACKET
 Packet family.
 
#define AF_CAN   PF_CAN
 Controller Area Network.
 
#define AF_NET_MGMT   PF_NET_MGMT
 Network management info.
 
#define AF_LOCAL   PF_LOCAL
 Inter-process communication

 
#define AF_UNIX   PF_UNIX
 Inter-process communication

 
#define ntohs(x)   sys_be16_to_cpu(x)
 Convert 16-bit value from network to host byte order.
 
#define ntohl(x)   sys_be32_to_cpu(x)
 Convert 32-bit value from network to host byte order.
 
#define ntohll(x)   sys_be64_to_cpu(x)
 Convert 64-bit value from network to host byte order.
 
#define htons(x)   sys_cpu_to_be16(x)
 Convert 16-bit value from host to network byte order.
 
#define htonl(x)   sys_cpu_to_be32(x)
 Convert 32-bit value from host to network byte order.
 
#define htonll(x)   sys_cpu_to_be64(x)
 Convert 64-bit value from host to network byte order.
 
#define NET_IPV6_ADDR_SIZE   16
 Binary size of the IPv6 address.
 
#define NET_IPV4_ADDR_SIZE   4
 Binary size of the IPv4 address.
 
#define CMSG_FIRSTHDR(msghdr)
 Returns a pointer to the first cmsghdr in the ancillary data buffer associated with the passed msghdr.
 
#define CMSG_NXTHDR(msghdr, cmsg)
 Returns the next valid cmsghdr after the passed cmsghdr.
 
#define CMSG_DATA(cmsg)   ((uint8_t *)(cmsg) + ALIGN_D(sizeof(struct cmsghdr)))
 Returns a pointer to the data portion of a cmsghdr.
 
#define CMSG_SPACE(length)   (ALIGN_D(sizeof(struct cmsghdr)) + ALIGN_H(length))
 Returns the number of bytes an ancillary element with payload of the passed data length occupies.
 
#define CMSG_LEN(length)   (ALIGN_D(sizeof(struct cmsghdr)) + length)
 Returns the value to store in the cmsg_len member of the cmsghdr structure, taking into account any necessary alignment.
 
#define IN6ADDR_ANY_INIT
 IPv6 address initializer.
 
#define IN6ADDR_LOOPBACK_INIT
 IPv6 loopback address initializer.
 
#define INADDR_ANY   0
 IPv4 any address.
 
#define INADDR_ANY_INIT   { { { INADDR_ANY } } }
 IPv4 address initializer.
 
#define INADDR_LOOPBACK_INIT   { { { 127, 0, 0, 1 } } }
 IPv6 loopback address initializer.
 
#define INET_ADDRSTRLEN   16
 Max length of the IPv4 address as a string.
 
#define INET6_ADDRSTRLEN   46
 Max length of the IPv6 address as a string.
 
#define NET_MAX_PRIORITIES   8
 How many priority values there are.
 
#define net_ipaddr_copy(dest, src)    UNALIGNED_PUT(UNALIGNED_GET(src), dest)
 Copy an IPv4 or IPv6 address.
 

Typedefs

typedef unsigned short int sa_family_t
 Socket address family type.
 
typedef size_t socklen_t
 Length of a socket address.
 

Enumerations

enum  net_ip_protocol {
  IPPROTO_IP = 0 , IPPROTO_ICMP = 1 , IPPROTO_IGMP = 2 , IPPROTO_IPIP = 4 ,
  IPPROTO_TCP = 6 , IPPROTO_UDP = 17 , IPPROTO_IPV6 = 41 , IPPROTO_ICMPV6 = 58 ,
  IPPROTO_RAW = 255
}
 Protocol numbers from IANA/BSD. More...
 
enum  net_ip_protocol_secure {
  IPPROTO_TLS_1_0 = 256 , IPPROTO_TLS_1_1 = 257 , IPPROTO_TLS_1_2 = 258 , IPPROTO_DTLS_1_0 = 272 ,
  IPPROTO_DTLS_1_2 = 273
}
 Protocol numbers for TLS protocols. More...
 
enum  net_sock_type { SOCK_STREAM = 1 , SOCK_DGRAM , SOCK_RAW }
 Socket type. More...
 
enum  net_ip_mtu { NET_IPV6_MTU = 1280 , NET_IPV4_MTU = 576 }
 IP Maximum Transfer Unit. More...
 
enum  net_priority {
  NET_PRIORITY_BK = 1 , NET_PRIORITY_BE = 0 , NET_PRIORITY_EE = 2 , NET_PRIORITY_CA = 3 ,
  NET_PRIORITY_VI = 4 , NET_PRIORITY_VO = 5 , NET_PRIORITY_IC = 6 , NET_PRIORITY_NC = 7
}
 Network packet priority settings described in IEEE 802.1Q Annex I.1. More...
 
enum  net_addr_state { NET_ADDR_ANY_STATE = -1 , NET_ADDR_TENTATIVE = 0 , NET_ADDR_PREFERRED , NET_ADDR_DEPRECATED }
 What is the current state of the network address. More...
 
enum  net_addr_type {
  NET_ADDR_ANY = 0 , NET_ADDR_AUTOCONF , NET_ADDR_DHCP , NET_ADDR_MANUAL ,
  NET_ADDR_OVERRIDABLE
}
 How the network address is assigned to network interface. More...
 

Functions

static bool net_ipv6_is_addr_loopback (struct in6_addr *addr)
 Check if the IPv6 address is a loopback address (::1).
 
static bool net_ipv6_is_addr_mcast (const struct in6_addr *addr)
 Check if the IPv6 address is a multicast address.
 
struct net_if_addrnet_if_ipv6_addr_lookup (const struct in6_addr *addr, struct net_if **iface)
 
static bool net_ipv6_is_my_addr (struct in6_addr *addr)
 Check if IPv6 address is found in one of the network interfaces.
 
struct net_if_mcast_addrnet_if_ipv6_maddr_lookup (const struct in6_addr *addr, struct net_if **iface)
 
static bool net_ipv6_is_my_maddr (struct in6_addr *maddr)
 Check if IPv6 multicast address is found in one of the network interfaces.
 
static bool net_ipv6_is_prefix (const uint8_t *addr1, const uint8_t *addr2, uint8_t length)
 Check if two IPv6 addresses are same when compared after prefix mask.
 
static bool net_ipv4_is_addr_loopback (struct in_addr *addr)
 Check if the IPv4 address is a loopback address (127.0.0.0/8).
 
static bool net_ipv4_is_addr_unspecified (const struct in_addr *addr)
 Check if the IPv4 address is unspecified (all bits zero)
 
static bool net_ipv4_is_addr_mcast (const struct in_addr *addr)
 Check if the IPv4 address is a multicast address.
 
static bool net_ipv4_is_ll_addr (const struct in_addr *addr)
 Check if the given IPv4 address is a link local address.
 
static bool net_ipv4_is_private_addr (const struct in_addr *addr)
 Check if the given IPv4 address is from a private address range.
 
static void net_ipv4_addr_copy_raw (uint8_t *dest, const uint8_t *src)
 Copy an IPv4 address raw buffer.
 
static void net_ipv6_addr_copy_raw (uint8_t *dest, const uint8_t *src)
 Copy an IPv6 address raw buffer.
 
static bool net_ipv4_addr_cmp (const struct in_addr *addr1, const struct in_addr *addr2)
 Compare two IPv4 addresses.
 
static bool net_ipv4_addr_cmp_raw (const uint8_t *addr1, const uint8_t *addr2)
 Compare two raw IPv4 address buffers.
 
static bool net_ipv6_addr_cmp (const struct in6_addr *addr1, const struct in6_addr *addr2)
 Compare two IPv6 addresses.
 
static bool net_ipv6_addr_cmp_raw (const uint8_t *addr1, const uint8_t *addr2)
 Compare two raw IPv6 address buffers.
 
static bool net_ipv6_is_ll_addr (const struct in6_addr *addr)
 Check if the given IPv6 address is a link local address.
 
static bool net_ipv6_is_sl_addr (const struct in6_addr *addr)
 Check if the given IPv6 address is a site local address.
 
static bool net_ipv6_is_ula_addr (const struct in6_addr *addr)
 Check if the given IPv6 address is a unique local address.
 
static bool net_ipv6_is_global_addr (const struct in6_addr *addr)
 Check if the given IPv6 address is a global address.
 
static bool net_ipv6_is_private_addr (const struct in6_addr *addr)
 Check if the given IPv6 address is from a private/local address range.
 
const struct in6_addrnet_ipv6_unspecified_address (void)
 Return pointer to any (all bits zeros) IPv6 address.
 
const struct in_addrnet_ipv4_unspecified_address (void)
 Return pointer to any (all bits zeros) IPv4 address.
 
const struct in_addrnet_ipv4_broadcast_address (void)
 Return pointer to broadcast (all bits ones) IPv4 address.
 
bool net_if_ipv4_addr_mask_cmp (struct net_if *iface, const struct in_addr *addr)
 
static bool net_ipv4_addr_mask_cmp (struct net_if *iface, const struct in_addr *addr)
 Check if the given address belongs to same subnet that has been configured for the interface.
 
bool net_if_ipv4_is_addr_bcast (struct net_if *iface, const struct in_addr *addr)
 
static bool net_ipv4_is_addr_bcast (struct net_if *iface, const struct in_addr *addr)
 Check if the given IPv4 address is a broadcast address.
 
struct net_if_addrnet_if_ipv4_addr_lookup (const struct in_addr *addr, struct net_if **iface)
 
static bool net_ipv4_is_my_addr (const struct in_addr *addr)
 Check if the IPv4 address is assigned to any network interface in the system.
 
static bool net_ipv6_is_addr_unspecified (const struct in6_addr *addr)
 Check if the IPv6 address is unspecified (all bits zero)
 
static bool net_ipv6_is_addr_solicited_node (const struct in6_addr *addr)
 Check if the IPv6 address is solicited node multicast address FF02:0:0:0:0:1:FFXX:XXXX defined in RFC 3513.
 
static bool net_ipv6_is_addr_mcast_scope (const struct in6_addr *addr, int scope)
 Check if the IPv6 address is a given scope multicast address (FFyx::).
 
static bool net_ipv6_is_same_mcast_scope (const struct in6_addr *addr_1, const struct in6_addr *addr_2)
 Check if the IPv6 addresses have the same multicast scope (FFyx::).
 
static bool net_ipv6_is_addr_mcast_global (const struct in6_addr *addr)
 Check if the IPv6 address is a global multicast address (FFxE::/16).
 
static bool net_ipv6_is_addr_mcast_iface (const struct in6_addr *addr)
 Check if the IPv6 address is a interface scope multicast address (FFx1::).
 
static bool net_ipv6_is_addr_mcast_link (const struct in6_addr *addr)
 Check if the IPv6 address is a link local scope multicast address (FFx2::).
 
static bool net_ipv6_is_addr_mcast_mesh (const struct in6_addr *addr)
 Check if the IPv6 address is a mesh-local scope multicast address (FFx3::).
 
static bool net_ipv6_is_addr_mcast_site (const struct in6_addr *addr)
 Check if the IPv6 address is a site scope multicast address (FFx5::).
 
static bool net_ipv6_is_addr_mcast_org (const struct in6_addr *addr)
 Check if the IPv6 address is an organization scope multicast address (FFx8::).
 
static bool net_ipv6_is_addr_mcast_group (const struct in6_addr *addr, const struct in6_addr *group)
 Check if the IPv6 address belongs to certain multicast group.
 
static bool net_ipv6_is_addr_mcast_all_nodes_group (const struct in6_addr *addr)
 Check if the IPv6 address belongs to the all nodes multicast group.
 
static bool net_ipv6_is_addr_mcast_iface_all_nodes (const struct in6_addr *addr)
 Check if the IPv6 address is a interface scope all nodes multicast address (FF01::1).
 
static bool net_ipv6_is_addr_mcast_link_all_nodes (const struct in6_addr *addr)
 Check if the IPv6 address is a link local scope all nodes multicast address (FF02::1).
 
static void net_ipv6_addr_create_solicited_node (const struct in6_addr *src, struct in6_addr *dst)
 Create solicited node IPv6 multicast address FF02:0:0:0:0:1:FFXX:XXXX defined in RFC 3513.
 
static void net_ipv6_addr_create (struct in6_addr *addr, uint16_t addr0, uint16_t addr1, uint16_t addr2, uint16_t addr3, uint16_t addr4, uint16_t addr5, uint16_t addr6, uint16_t addr7)
 Construct an IPv6 address from eight 16-bit words.
 
static void net_ipv6_addr_create_ll_allnodes_mcast (struct in6_addr *addr)
 Create link local allnodes multicast IPv6 address.
 
static void net_ipv6_addr_create_ll_allrouters_mcast (struct in6_addr *addr)
 Create link local allrouters multicast IPv6 address.
 
static void net_ipv6_addr_create_v4_mapped (const struct in_addr *addr4, struct in6_addr *addr6)
 Create IPv4 mapped IPv6 address.
 
static bool net_ipv6_addr_is_v4_mapped (const struct in6_addr *addr)
 Is the IPv6 address an IPv4 mapped one.
 
static void net_ipv6_addr_create_iid (struct in6_addr *addr, struct net_linkaddr *lladdr)
 Create IPv6 address interface identifier.
 
static bool net_ipv6_addr_based_on_ll (const struct in6_addr *addr, const struct net_linkaddr *lladdr)
 Check if given address is based on link layer address.
 
static struct sockaddr_in6net_sin6 (const struct sockaddr *addr)
 Get sockaddr_in6 from sockaddr.
 
static struct sockaddr_innet_sin (const struct sockaddr *addr)
 Get sockaddr_in from sockaddr.
 
static struct sockaddr_in6_ptr * net_sin6_ptr (const struct sockaddr_ptr *addr)
 Get sockaddr_in6_ptr from sockaddr_ptr.
 
static struct sockaddr_in_ptr * net_sin_ptr (const struct sockaddr_ptr *addr)
 Get sockaddr_in_ptr from sockaddr_ptr.
 
static struct sockaddr_ll_ptr * net_sll_ptr (const struct sockaddr_ptr *addr)
 Get sockaddr_ll_ptr from sockaddr_ptr.
 
static struct sockaddr_can_ptr * net_can_ptr (const struct sockaddr_ptr *addr)
 Get sockaddr_can_ptr from sockaddr_ptr.
 
int net_addr_pton (sa_family_t family, const char *src, void *dst)
 Convert a string to IP address.
 
char * net_addr_ntop (sa_family_t family, const void *src, char *dst, size_t size)
 Convert IP address to string form.
 
bool net_ipaddr_parse (const char *str, size_t str_len, struct sockaddr *addr)
 Parse a string that contains either IPv4 or IPv6 address and optional port, and store the information in user supplied sockaddr struct.
 
int net_port_set_default (struct sockaddr *addr, uint16_t default_port)
 Set the default port in the sockaddr structure.
 
static int32_t net_tcp_seq_cmp (uint32_t seq1, uint32_t seq2)
 Compare TCP sequence numbers.
 
static bool net_tcp_seq_greater (uint32_t seq1, uint32_t seq2)
 Check that one TCP sequence number is greater.
 
int net_bytes_from_str (uint8_t *buf, int buf_len, const char *src)
 Convert a string of hex values to array of bytes.
 
int net_tx_priority2tc (enum net_priority prio)
 Convert Tx network packet priority to traffic class so we can place the packet into correct Tx queue.
 
int net_rx_priority2tc (enum net_priority prio)
 Convert Rx network packet priority to traffic class so we can place the packet into correct Rx queue.
 
static enum net_priority net_vlan2priority (uint8_t priority)
 Convert network packet VLAN priority to network packet priority so we can place the packet into correct queue.
 
static uint8_t net_priority2vlan (enum net_priority priority)
 Convert network packet priority to network packet VLAN priority.
 
const char * net_family2str (sa_family_t family)
 Return network address family value as a string.
 
static int net_ipv6_pe_add_filter (struct in6_addr *addr, bool is_denylist)
 Add IPv6 prefix as a privacy extension filter.
 
static int net_ipv6_pe_del_filter (struct in6_addr *addr)
 Delete IPv6 prefix from privacy extension filter list.
 

Detailed Description

IPv4/IPv6 primitives and helpers.

Macro Definition Documentation

◆ AF_CAN

#define AF_CAN   PF_CAN

#include <zephyr/net/net_ip.h>

Controller Area Network.


◆ AF_INET

#define AF_INET   PF_INET

#include <zephyr/net/net_ip.h>

IP protocol family version 4.

◆ AF_INET6

#define AF_INET6   PF_INET6

#include <zephyr/net/net_ip.h>

IP protocol family version 6.

◆ AF_LOCAL

#define AF_LOCAL   PF_LOCAL

#include <zephyr/net/net_ip.h>

Inter-process communication

◆ AF_NET_MGMT

#define AF_NET_MGMT   PF_NET_MGMT

#include <zephyr/net/net_ip.h>

Network management info.


◆ AF_PACKET

#define AF_PACKET   PF_PACKET

#include <zephyr/net/net_ip.h>

Packet family.


◆ AF_UNIX

#define AF_UNIX   PF_UNIX

#include <zephyr/net/net_ip.h>

Inter-process communication

◆ AF_UNSPEC

#define AF_UNSPEC   PF_UNSPEC

#include <zephyr/net/net_ip.h>

Unspecified address family.


◆ CMSG_DATA

#define CMSG_DATA (   cmsg)    ((uint8_t *)(cmsg) + ALIGN_D(sizeof(struct cmsghdr)))

#include <zephyr/net/net_ip.h>

Returns a pointer to the data portion of a cmsghdr.

The pointer returned cannot be assumed to be suitably aligned for accessing arbitrary payload data types. Applications should not cast it to a pointer type matching the payload, but should instead use memcpy(3) to copy data to or from a suitably declared object.

◆ CMSG_FIRSTHDR

#define CMSG_FIRSTHDR (   msghdr)

#include <zephyr/net/net_ip.h>

Value:
((msghdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
(struct cmsghdr *)((msghdr)->msg_control) : NULL)
Control message ancillary data.
Definition: net_ip.h:258
Message struct.
Definition: net_ip.h:247

Returns a pointer to the first cmsghdr in the ancillary data buffer associated with the passed msghdr.

It returns NULL if there isn't enough space for a cmsghdr in the buffer.

◆ CMSG_LEN

#define CMSG_LEN (   length)    (ALIGN_D(sizeof(struct cmsghdr)) + length)

#include <zephyr/net/net_ip.h>

Returns the value to store in the cmsg_len member of the cmsghdr structure, taking into account any necessary alignment.

It takes the data length as an argument.

◆ CMSG_NXTHDR

#define CMSG_NXTHDR (   msghdr,
  cmsg 
)

#include <zephyr/net/net_ip.h>

Value:
(((cmsg) == NULL) ? CMSG_FIRSTHDR(msghdr) : \
(((uint8_t *)(cmsg) + ALIGN_H((cmsg)->cmsg_len) + \
ALIGN_D(sizeof(struct cmsghdr)) > \
(uint8_t *)((msghdr)->msg_control) + (msghdr)->msg_controllen) ? \
NULL : \
(struct cmsghdr *)((uint8_t *)(cmsg) + \
ALIGN_H((cmsg)->cmsg_len))))
#define CMSG_FIRSTHDR(msghdr)
Returns a pointer to the first cmsghdr in the ancillary data buffer associated with the passed msghdr...
Definition: net_ip.h:285
sizeof(size_t))
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88

Returns the next valid cmsghdr after the passed cmsghdr.

It returns NULL when there isn't enough space left in the buffer.

◆ CMSG_SPACE

#define CMSG_SPACE (   length)    (ALIGN_D(sizeof(struct cmsghdr)) + ALIGN_H(length))

#include <zephyr/net/net_ip.h>

Returns the number of bytes an ancillary element with payload of the passed data length occupies.

◆ htonl

#define htonl (   x)    sys_cpu_to_be32(x)

#include <zephyr/net/net_ip.h>

Convert 32-bit value from host to network byte order.

Parameters
xThe host byte order value to convert.
Returns
Network byte order value.

◆ htonll

#define htonll (   x)    sys_cpu_to_be64(x)

#include <zephyr/net/net_ip.h>

Convert 64-bit value from host to network byte order.

Parameters
xThe host byte order value to convert.
Returns
Network byte order value.

◆ htons

#define htons (   x)    sys_cpu_to_be16(x)

#include <zephyr/net/net_ip.h>

Convert 16-bit value from host to network byte order.

Parameters
xThe host byte order value to convert.
Returns
Network byte order value.

◆ IN6ADDR_ANY_INIT

#define IN6ADDR_ANY_INIT

#include <zephyr/net/net_ip.h>

Value:
{ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0 } } }

IPv6 address initializer.

◆ IN6ADDR_LOOPBACK_INIT

#define IN6ADDR_LOOPBACK_INIT

#include <zephyr/net/net_ip.h>

Value:
{ { { 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 1 } } }

IPv6 loopback address initializer.

◆ INADDR_ANY

#define INADDR_ANY   0

#include <zephyr/net/net_ip.h>

IPv4 any address.

◆ INADDR_ANY_INIT

#define INADDR_ANY_INIT   { { { INADDR_ANY } } }

#include <zephyr/net/net_ip.h>

IPv4 address initializer.

◆ INADDR_LOOPBACK_INIT

#define INADDR_LOOPBACK_INIT   { { { 127, 0, 0, 1 } } }

#include <zephyr/net/net_ip.h>

IPv6 loopback address initializer.

◆ INET6_ADDRSTRLEN

#define INET6_ADDRSTRLEN   46

#include <zephyr/net/net_ip.h>

Max length of the IPv6 address as a string.

Takes into account possible mapped IPv4 addresses.

◆ INET_ADDRSTRLEN

#define INET_ADDRSTRLEN   16

#include <zephyr/net/net_ip.h>

Max length of the IPv4 address as a string.

Defined by POSIX.

◆ net_ipaddr_copy

#define net_ipaddr_copy (   dest,
  src 
)     UNALIGNED_PUT(UNALIGNED_GET(src), dest)

#include <zephyr/net/net_ip.h>

Copy an IPv4 or IPv6 address.

Parameters
destDestination IP address.
srcSource IP address.
Returns
Destination address.

◆ NET_IPV4_ADDR_SIZE

#define NET_IPV4_ADDR_SIZE   4

#include <zephyr/net/net_ip.h>

Binary size of the IPv4 address.

◆ NET_IPV6_ADDR_SIZE

#define NET_IPV6_ADDR_SIZE   16

#include <zephyr/net/net_ip.h>

Binary size of the IPv6 address.

◆ NET_MAX_PRIORITIES

#define NET_MAX_PRIORITIES   8

#include <zephyr/net/net_ip.h>

How many priority values there are.

◆ ntohl

#define ntohl (   x)    sys_be32_to_cpu(x)

#include <zephyr/net/net_ip.h>

Convert 32-bit value from network to host byte order.

Parameters
xThe network byte order value to convert.
Returns
Host byte order value.

◆ ntohll

#define ntohll (   x)    sys_be64_to_cpu(x)

#include <zephyr/net/net_ip.h>

Convert 64-bit value from network to host byte order.

Parameters
xThe network byte order value to convert.
Returns
Host byte order value.

◆ ntohs

#define ntohs (   x)    sys_be16_to_cpu(x)

#include <zephyr/net/net_ip.h>

Convert 16-bit value from network to host byte order.

Parameters
xThe network byte order value to convert.
Returns
Host byte order value.

◆ PF_CAN

#define PF_CAN   4

#include <zephyr/net/net_ip.h>

Controller Area Network.


◆ PF_INET

#define PF_INET   1

#include <zephyr/net/net_ip.h>

IP protocol family version 4.

◆ PF_INET6

#define PF_INET6   2

#include <zephyr/net/net_ip.h>

IP protocol family version 6.

◆ PF_LOCAL

#define PF_LOCAL   6

#include <zephyr/net/net_ip.h>

Inter-process communication

◆ PF_NET_MGMT

#define PF_NET_MGMT   5

#include <zephyr/net/net_ip.h>

Network management info.


◆ PF_PACKET

#define PF_PACKET   3

#include <zephyr/net/net_ip.h>

Packet family.


◆ PF_UNIX

#define PF_UNIX   PF_LOCAL

#include <zephyr/net/net_ip.h>

Inter-process communication

◆ PF_UNSPEC

#define PF_UNSPEC   0

#include <zephyr/net/net_ip.h>

Unspecified protocol family.


Typedef Documentation

◆ sa_family_t

typedef unsigned short int sa_family_t

#include <zephyr/net/net_ip.h>

Socket address family type.

◆ socklen_t

typedef size_t socklen_t

#include <zephyr/net/net_ip.h>

Length of a socket address.

Enumeration Type Documentation

◆ net_addr_state

#include <zephyr/net/net_ip.h>

What is the current state of the network address.

Enumerator
NET_ADDR_ANY_STATE 

Default (invalid) address type.

NET_ADDR_TENTATIVE 

Tentative address

NET_ADDR_PREFERRED 

Preferred address

NET_ADDR_DEPRECATED 

Deprecated address

◆ net_addr_type

#include <zephyr/net/net_ip.h>

How the network address is assigned to network interface.

Enumerator
NET_ADDR_ANY 

Default value.

This is not a valid value.

NET_ADDR_AUTOCONF 

Auto configured address.

NET_ADDR_DHCP 

Address is from DHCP.

NET_ADDR_MANUAL 

Manually set address.

NET_ADDR_OVERRIDABLE 

Manually set address which is overridable by DHCP.

◆ net_ip_mtu

enum net_ip_mtu

#include <zephyr/net/net_ip.h>

IP Maximum Transfer Unit.

Enumerator
NET_IPV6_MTU 

IPv6 MTU length.

We must be able to receive this size IPv6 packet without fragmentation.

NET_IPV4_MTU 

IPv4 MTU length.

We must be able to receive this size IPv4 packet without fragmentation.

◆ net_ip_protocol

#include <zephyr/net/net_ip.h>

Protocol numbers from IANA/BSD.

Enumerator
IPPROTO_IP 

IP protocol (pseudo-val for setsockopt()

IPPROTO_ICMP 

ICMP protocol

IPPROTO_IGMP 

IGMP protocol

IPPROTO_IPIP 

IPIP tunnels

IPPROTO_TCP 

TCP protocol

IPPROTO_UDP 

UDP protocol

IPPROTO_IPV6 

IPv6 protocol

IPPROTO_ICMPV6 

ICMPv6 protocol.

IPPROTO_RAW 

RAW IP packets

◆ net_ip_protocol_secure

#include <zephyr/net/net_ip.h>

Protocol numbers for TLS protocols.

Enumerator
IPPROTO_TLS_1_0 

TLS 1.0 protocol.

IPPROTO_TLS_1_1 

TLS 1.1 protocol.

IPPROTO_TLS_1_2 

TLS 1.2 protocol.

IPPROTO_DTLS_1_0 

DTLS 1.0 protocol.

IPPROTO_DTLS_1_2 

DTLS 1.2 protocol.

◆ net_priority

#include <zephyr/net/net_ip.h>

Network packet priority settings described in IEEE 802.1Q Annex I.1.

Enumerator
NET_PRIORITY_BK 

Background (lowest)

NET_PRIORITY_BE 

Best effort (default)

NET_PRIORITY_EE 

Excellent effort

NET_PRIORITY_CA 

Critical applications

NET_PRIORITY_VI 

Video, < 100 ms latency and jitter.

NET_PRIORITY_VO 

Voice, < 10 ms latency and jitter

NET_PRIORITY_IC 

Internetwork control

NET_PRIORITY_NC 

Network control (highest)

◆ net_sock_type

#include <zephyr/net/net_ip.h>

Socket type.

Enumerator
SOCK_STREAM 

Stream socket type

SOCK_DGRAM 

Datagram socket type.

SOCK_RAW 

RAW socket type

Function Documentation

◆ net_addr_ntop()

char * net_addr_ntop ( sa_family_t  family,
const void *  src,
char *  dst,
size_t  size 
)

#include <zephyr/net/net_ip.h>

Convert IP address to string form.

Parameters
familyIP address family (AF_INET or AF_INET6)
srcPointer to struct in_addr if family is AF_INET or pointer to struct in6_addr if family is AF_INET6
dstBuffer for IP address as a null terminated string
sizeNumber of bytes available in the buffer
Returns
dst pointer if ok, NULL if error

◆ net_addr_pton()

int net_addr_pton ( sa_family_t  family,
const char *  src,
void *  dst 
)

#include <zephyr/net/net_ip.h>

Convert a string to IP address.

Parameters
familyIP address family (AF_INET or AF_INET6)
srcIP address in a null terminated string
dstPointer to struct in_addr if family is AF_INET or pointer to struct in6_addr if family is AF_INET6
Note
This function doesn't do precise error checking, do not use for untrusted strings.
Returns
0 if ok, < 0 if error

◆ net_bytes_from_str()

int net_bytes_from_str ( uint8_t buf,
int  buf_len,
const char *  src 
)

#include <zephyr/net/net_ip.h>

Convert a string of hex values to array of bytes.

The syntax of the string is "ab:02:98:fa:42:01"

Parameters
bufPointer to memory where the bytes are written.
buf_lenLength of the memory area.
srcString of bytes.
Returns
0 if ok, <0 if error

◆ net_can_ptr()

static struct sockaddr_can_ptr * net_can_ptr ( const struct sockaddr_ptr *  addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Get sockaddr_can_ptr from sockaddr_ptr.

This is a helper so that the code needing this functionality can be made shorter.

Parameters
addrSocket address
Returns
Pointer to CAN socket address

◆ net_family2str()

const char * net_family2str ( sa_family_t  family)

#include <zephyr/net/net_ip.h>

Return network address family value as a string.

This is only usable for debugging.

Parameters
familyNetwork address family code
Returns
Network address family as a string, or NULL if family is unknown.

◆ net_if_ipv4_addr_lookup()

struct net_if_addr * net_if_ipv4_addr_lookup ( const struct in_addr addr,
struct net_if **  iface 
)

#include <zephyr/net/net_ip.h>

◆ net_if_ipv4_addr_mask_cmp()

bool net_if_ipv4_addr_mask_cmp ( struct net_if iface,
const struct in_addr addr 
)

#include <zephyr/net/net_ip.h>

◆ net_if_ipv4_is_addr_bcast()

bool net_if_ipv4_is_addr_bcast ( struct net_if iface,
const struct in_addr addr 
)

#include <zephyr/net/net_ip.h>

◆ net_if_ipv6_addr_lookup()

struct net_if_addr * net_if_ipv6_addr_lookup ( const struct in6_addr addr,
struct net_if **  iface 
)

#include <zephyr/net/net_ip.h>

◆ net_if_ipv6_maddr_lookup()

struct net_if_mcast_addr * net_if_ipv6_maddr_lookup ( const struct in6_addr addr,
struct net_if **  iface 
)

#include <zephyr/net/net_ip.h>

◆ net_ipaddr_parse()

bool net_ipaddr_parse ( const char *  str,
size_t  str_len,
struct sockaddr addr 
)

#include <zephyr/net/net_ip.h>

Parse a string that contains either IPv4 or IPv6 address and optional port, and store the information in user supplied sockaddr struct.

Syntax of the IP address string: 192.0.2.1:80 192.0.2.42

[2001:db8::2] 2001:db::42 Note that the str_len parameter is used to restrict the amount of characters that are checked. If the string does not contain port number, then the port number in sockaddr is not modified.

Parameters
strString that contains the IP address.
str_lenLength of the string to be parsed.
addrPointer to user supplied struct sockaddr.
Returns
True if parsing could be done, false otherwise.

◆ net_ipv4_addr_cmp()

static bool net_ipv4_addr_cmp ( const struct in_addr addr1,
const struct in_addr addr2 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Compare two IPv4 addresses.

Parameters
addr1Pointer to IPv4 address.
addr2Pointer to IPv4 address.
Returns
True if the addresses are the same, false otherwise.

◆ net_ipv4_addr_cmp_raw()

static bool net_ipv4_addr_cmp_raw ( const uint8_t addr1,
const uint8_t addr2 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Compare two raw IPv4 address buffers.

Parameters
addr1Pointer to IPv4 address buffer.
addr2Pointer to IPv4 address buffer.
Returns
True if the addresses are the same, false otherwise.

◆ net_ipv4_addr_copy_raw()

static void net_ipv4_addr_copy_raw ( uint8_t dest,
const uint8_t src 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Copy an IPv4 address raw buffer.

Parameters
destDestination IP address.
srcSource IP address.

◆ net_ipv4_addr_mask_cmp()

static bool net_ipv4_addr_mask_cmp ( struct net_if iface,
const struct in_addr addr 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given address belongs to same subnet that has been configured for the interface.

Parameters
ifaceA valid pointer on an interface
addrIPv4 address
Returns
True if address is in same subnet, false otherwise.

◆ net_ipv4_broadcast_address()

const struct in_addr * net_ipv4_broadcast_address ( void  )

#include <zephyr/net/net_ip.h>

Return pointer to broadcast (all bits ones) IPv4 address.

Returns
Broadcast IPv4 address.

◆ net_ipv4_is_addr_bcast()

static bool net_ipv4_is_addr_bcast ( struct net_if iface,
const struct in_addr addr 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv4 address is a broadcast address.

Parameters
ifaceInterface to use. Must be a valid pointer to an interface.
addrIPv4 address
Returns
True if address is a broadcast address, false otherwise.

◆ net_ipv4_is_addr_loopback()

static bool net_ipv4_is_addr_loopback ( struct in_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv4 address is a loopback address (127.0.0.0/8).

Parameters
addrIPv4 address
Returns
True if address is a loopback address, False otherwise.

◆ net_ipv4_is_addr_mcast()

static bool net_ipv4_is_addr_mcast ( const struct in_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv4 address is a multicast address.

Parameters
addrIPv4 address
Returns
True if address is multicast address, False otherwise.

◆ net_ipv4_is_addr_unspecified()

static bool net_ipv4_is_addr_unspecified ( const struct in_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv4 address is unspecified (all bits zero)

Parameters
addrIPv4 address.
Returns
True if the address is unspecified, false otherwise.

◆ net_ipv4_is_ll_addr()

static bool net_ipv4_is_ll_addr ( const struct in_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv4 address is a link local address.

Parameters
addrA valid pointer on an IPv4 address
Returns
True if it is, false otherwise.

◆ net_ipv4_is_my_addr()

static bool net_ipv4_is_my_addr ( const struct in_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv4 address is assigned to any network interface in the system.

Parameters
addrA valid pointer on an IPv4 address
Returns
True if IPv4 address is found in one of the network interfaces, False otherwise.

◆ net_ipv4_is_private_addr()

static bool net_ipv4_is_private_addr ( const struct in_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv4 address is from a private address range.

See https://en.wikipedia.org/wiki/Reserved_IP_addresses for details.

Parameters
addrA valid pointer on an IPv4 address
Returns
True if it is, false otherwise.

◆ net_ipv4_unspecified_address()

const struct in_addr * net_ipv4_unspecified_address ( void  )

#include <zephyr/net/net_ip.h>

Return pointer to any (all bits zeros) IPv4 address.

Returns
Any IPv4 address.

◆ net_ipv6_addr_based_on_ll()

static bool net_ipv6_addr_based_on_ll ( const struct in6_addr addr,
const struct net_linkaddr lladdr 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if given address is based on link layer address.

Returns
True if it is, False otherwise

◆ net_ipv6_addr_cmp()

static bool net_ipv6_addr_cmp ( const struct in6_addr addr1,
const struct in6_addr addr2 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Compare two IPv6 addresses.

Parameters
addr1Pointer to IPv6 address.
addr2Pointer to IPv6 address.
Returns
True if the addresses are the same, false otherwise.

◆ net_ipv6_addr_cmp_raw()

static bool net_ipv6_addr_cmp_raw ( const uint8_t addr1,
const uint8_t addr2 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Compare two raw IPv6 address buffers.

Parameters
addr1Pointer to IPv6 address buffer.
addr2Pointer to IPv6 address buffer.
Returns
True if the addresses are the same, false otherwise.

◆ net_ipv6_addr_copy_raw()

static void net_ipv6_addr_copy_raw ( uint8_t dest,
const uint8_t src 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Copy an IPv6 address raw buffer.

Parameters
destDestination IP address.
srcSource IP address.

◆ net_ipv6_addr_create()

static void net_ipv6_addr_create ( struct in6_addr addr,
uint16_t  addr0,
uint16_t  addr1,
uint16_t  addr2,
uint16_t  addr3,
uint16_t  addr4,
uint16_t  addr5,
uint16_t  addr6,
uint16_t  addr7 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Construct an IPv6 address from eight 16-bit words.

Parameters
addrIPv6 address
addr016-bit word which is part of the address
addr116-bit word which is part of the address
addr216-bit word which is part of the address
addr316-bit word which is part of the address
addr416-bit word which is part of the address
addr516-bit word which is part of the address
addr616-bit word which is part of the address
addr716-bit word which is part of the address

◆ net_ipv6_addr_create_iid()

static void net_ipv6_addr_create_iid ( struct in6_addr addr,
struct net_linkaddr lladdr 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Create IPv6 address interface identifier.

Parameters
addrIPv6 address
lladdrLink local address

◆ net_ipv6_addr_create_ll_allnodes_mcast()

static void net_ipv6_addr_create_ll_allnodes_mcast ( struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Create link local allnodes multicast IPv6 address.

Parameters
addrIPv6 address

◆ net_ipv6_addr_create_ll_allrouters_mcast()

static void net_ipv6_addr_create_ll_allrouters_mcast ( struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Create link local allrouters multicast IPv6 address.

Parameters
addrIPv6 address

◆ net_ipv6_addr_create_solicited_node()

static void net_ipv6_addr_create_solicited_node ( const struct in6_addr src,
struct in6_addr dst 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Create solicited node IPv6 multicast address FF02:0:0:0:0:1:FFXX:XXXX defined in RFC 3513.

Parameters
srcIPv6 address.
dstIPv6 address.

◆ net_ipv6_addr_create_v4_mapped()

static void net_ipv6_addr_create_v4_mapped ( const struct in_addr addr4,
struct in6_addr addr6 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Create IPv4 mapped IPv6 address.

Parameters
addr4IPv4 address
addr6IPv6 address to be created

◆ net_ipv6_addr_is_v4_mapped()

static bool net_ipv6_addr_is_v4_mapped ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Is the IPv6 address an IPv4 mapped one.

The v4 mapped addresses look like ::ffff:a.b.c.d

Parameters
addrIPv6 address
Returns
True if IPv6 address is a IPv4 mapped address, False otherwise.

◆ net_ipv6_is_addr_loopback()

static bool net_ipv6_is_addr_loopback ( struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a loopback address (::1).

Parameters
addrIPv6 address
Returns
True if address is a loopback address, False otherwise.

◆ net_ipv6_is_addr_mcast()

static bool net_ipv6_is_addr_mcast ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a multicast address.

Parameters
addrIPv6 address
Returns
True if address is multicast address, False otherwise.

◆ net_ipv6_is_addr_mcast_all_nodes_group()

static bool net_ipv6_is_addr_mcast_all_nodes_group ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address belongs to the all nodes multicast group.

Parameters
addrIPv6 address
Returns
True if the IPv6 multicast address belongs to the all nodes multicast group, false otherwise

◆ net_ipv6_is_addr_mcast_global()

static bool net_ipv6_is_addr_mcast_global ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a global multicast address (FFxE::/16).

Parameters
addrIPv6 address.
Returns
True if the address is global multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_group()

static bool net_ipv6_is_addr_mcast_group ( const struct in6_addr addr,
const struct in6_addr group 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address belongs to certain multicast group.

Parameters
addrIPv6 address.
groupGroup id IPv6 address, the values must be in network byte order
Returns
True if the IPv6 multicast address belongs to given multicast group, false otherwise.

◆ net_ipv6_is_addr_mcast_iface()

static bool net_ipv6_is_addr_mcast_iface ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a interface scope multicast address (FFx1::).

Parameters
addrIPv6 address.
Returns
True if the address is a interface scope multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_iface_all_nodes()

static bool net_ipv6_is_addr_mcast_iface_all_nodes ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a interface scope all nodes multicast address (FF01::1).

Parameters
addrIPv6 address.
Returns
True if the address is a interface scope all nodes multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_link()

static bool net_ipv6_is_addr_mcast_link ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a link local scope multicast address (FFx2::).

Parameters
addrIPv6 address.
Returns
True if the address is a link local scope multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_link_all_nodes()

static bool net_ipv6_is_addr_mcast_link_all_nodes ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a link local scope all nodes multicast address (FF02::1).

Parameters
addrIPv6 address.
Returns
True if the address is a link local scope all nodes multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_mesh()

static bool net_ipv6_is_addr_mcast_mesh ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a mesh-local scope multicast address (FFx3::).

Parameters
addrIPv6 address.
Returns
True if the address is a mesh-local scope multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_org()

static bool net_ipv6_is_addr_mcast_org ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is an organization scope multicast address (FFx8::).

Parameters
addrIPv6 address.
Returns
True if the address is an organization scope multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_scope()

static bool net_ipv6_is_addr_mcast_scope ( const struct in6_addr addr,
int  scope 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a given scope multicast address (FFyx::).

Parameters
addrIPv6 address
scopeScope to check
Returns
True if the address is in given scope multicast address, false otherwise.

◆ net_ipv6_is_addr_mcast_site()

static bool net_ipv6_is_addr_mcast_site ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is a site scope multicast address (FFx5::).

Parameters
addrIPv6 address.
Returns
True if the address is a site scope multicast address, false otherwise.

◆ net_ipv6_is_addr_solicited_node()

static bool net_ipv6_is_addr_solicited_node ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is solicited node multicast address FF02:0:0:0:0:1:FFXX:XXXX defined in RFC 3513.

Parameters
addrIPv6 address.
Returns
True if the address is solicited node address, false otherwise.

◆ net_ipv6_is_addr_unspecified()

static bool net_ipv6_is_addr_unspecified ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 address is unspecified (all bits zero)

Parameters
addrIPv6 address.
Returns
True if the address is unspecified, false otherwise.

◆ net_ipv6_is_global_addr()

static bool net_ipv6_is_global_addr ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv6 address is a global address.

Parameters
addrA valid pointer on an IPv6 address
Returns
True if it is, false otherwise.

◆ net_ipv6_is_ll_addr()

static bool net_ipv6_is_ll_addr ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv6 address is a link local address.

Parameters
addrA valid pointer on an IPv6 address
Returns
True if it is, false otherwise.

◆ net_ipv6_is_my_addr()

static bool net_ipv6_is_my_addr ( struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if IPv6 address is found in one of the network interfaces.

Parameters
addrIPv6 address
Returns
True if address was found, False otherwise.

◆ net_ipv6_is_my_maddr()

static bool net_ipv6_is_my_maddr ( struct in6_addr maddr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if IPv6 multicast address is found in one of the network interfaces.

Parameters
maddrMulticast IPv6 address
Returns
True if address was found, False otherwise.

◆ net_ipv6_is_prefix()

static bool net_ipv6_is_prefix ( const uint8_t addr1,
const uint8_t addr2,
uint8_t  length 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if two IPv6 addresses are same when compared after prefix mask.

Parameters
addr1First IPv6 address.
addr2Second IPv6 address.
lengthPrefix length (max length is 128).
Returns
True if IPv6 prefixes are the same, False otherwise.

◆ net_ipv6_is_private_addr()

static bool net_ipv6_is_private_addr ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv6 address is from a private/local address range.

See https://en.wikipedia.org/wiki/Reserved_IP_addresses for details.

Parameters
addrA valid pointer on an IPv6 address
Returns
True if it is, false otherwise.

◆ net_ipv6_is_same_mcast_scope()

static bool net_ipv6_is_same_mcast_scope ( const struct in6_addr addr_1,
const struct in6_addr addr_2 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the IPv6 addresses have the same multicast scope (FFyx::).

Parameters
addr_1IPv6 address 1
addr_2IPv6 address 2
Returns
True if both addresses have same multicast scope, false otherwise.

◆ net_ipv6_is_sl_addr()

static bool net_ipv6_is_sl_addr ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv6 address is a site local address.

Parameters
addrA valid pointer on an IPv6 address
Returns
True if it is, false otherwise.

◆ net_ipv6_is_ula_addr()

static bool net_ipv6_is_ula_addr ( const struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Check if the given IPv6 address is a unique local address.

Parameters
addrA valid pointer on an IPv6 address
Returns
True if it is, false otherwise.

◆ net_ipv6_pe_add_filter()

static int net_ipv6_pe_add_filter ( struct in6_addr addr,
bool  is_denylist 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Add IPv6 prefix as a privacy extension filter.

Note that the filters can either allow or deny listing.

Parameters
addrIPv6 prefix
is_denylistTells if this filter is for allowing or denying listing.
Returns
0 if ok, <0 if error

◆ net_ipv6_pe_del_filter()

static int net_ipv6_pe_del_filter ( struct in6_addr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Delete IPv6 prefix from privacy extension filter list.

Parameters
addrIPv6 prefix
Returns
0 if ok, <0 if error

◆ net_ipv6_unspecified_address()

const struct in6_addr * net_ipv6_unspecified_address ( void  )

#include <zephyr/net/net_ip.h>

Return pointer to any (all bits zeros) IPv6 address.

Returns
Any IPv6 address.

◆ net_port_set_default()

int net_port_set_default ( struct sockaddr addr,
uint16_t  default_port 
)

#include <zephyr/net/net_ip.h>

Set the default port in the sockaddr structure.

If the port is already set, then do nothing.

Parameters
addrPointer to user supplied struct sockaddr.
default_portDefault port number to set.
Returns
0 if ok, <0 if error

◆ net_priority2vlan()

static uint8_t net_priority2vlan ( enum net_priority  priority)
inlinestatic

#include <zephyr/net/net_ip.h>

Convert network packet priority to network packet VLAN priority.

Parameters
priorityPacket priority
Returns
VLAN priority (PCP)

◆ net_rx_priority2tc()

int net_rx_priority2tc ( enum net_priority  prio)

#include <zephyr/net/net_ip.h>

Convert Rx network packet priority to traffic class so we can place the packet into correct Rx queue.

Parameters
prioNetwork priority
Returns
Rx traffic class that handles that priority network traffic.

◆ net_sin()

static struct sockaddr_in * net_sin ( const struct sockaddr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Get sockaddr_in from sockaddr.

This is a helper so that the code calling this function can be made shorter.

Parameters
addrSocket address
Returns
Pointer to IPv4 socket address

◆ net_sin6()

static struct sockaddr_in6 * net_sin6 ( const struct sockaddr addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Get sockaddr_in6 from sockaddr.

This is a helper so that the code calling this function can be made shorter.

Parameters
addrSocket address
Returns
Pointer to IPv6 socket address

◆ net_sin6_ptr()

static struct sockaddr_in6_ptr * net_sin6_ptr ( const struct sockaddr_ptr *  addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Get sockaddr_in6_ptr from sockaddr_ptr.

This is a helper so that the code calling this function can be made shorter.

Parameters
addrSocket address
Returns
Pointer to IPv6 socket address

◆ net_sin_ptr()

static struct sockaddr_in_ptr * net_sin_ptr ( const struct sockaddr_ptr *  addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Get sockaddr_in_ptr from sockaddr_ptr.

This is a helper so that the code calling this function can be made shorter.

Parameters
addrSocket address
Returns
Pointer to IPv4 socket address

◆ net_sll_ptr()

static struct sockaddr_ll_ptr * net_sll_ptr ( const struct sockaddr_ptr *  addr)
inlinestatic

#include <zephyr/net/net_ip.h>

Get sockaddr_ll_ptr from sockaddr_ptr.

This is a helper so that the code calling this function can be made shorter.

Parameters
addrSocket address
Returns
Pointer to linklayer socket address

◆ net_tcp_seq_cmp()

static int32_t net_tcp_seq_cmp ( uint32_t  seq1,
uint32_t  seq2 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Compare TCP sequence numbers.

This function compares TCP sequence numbers, accounting for wraparound effects.

Parameters
seq1First sequence number
seq2Seconds sequence number
Returns
< 0 if seq1 < seq2, 0 if seq1 == seq2, > 0 if seq > seq2

◆ net_tcp_seq_greater()

static bool net_tcp_seq_greater ( uint32_t  seq1,
uint32_t  seq2 
)
inlinestatic

#include <zephyr/net/net_ip.h>

Check that one TCP sequence number is greater.

This is convenience function on top of net_tcp_seq_cmp().

Parameters
seq1First sequence number
seq2Seconds sequence number
Returns
True if seq > seq2

◆ net_tx_priority2tc()

int net_tx_priority2tc ( enum net_priority  prio)

#include <zephyr/net/net_ip.h>

Convert Tx network packet priority to traffic class so we can place the packet into correct Tx queue.

Parameters
prioNetwork priority
Returns
Tx traffic class that handles that priority network traffic.

◆ net_vlan2priority()

static enum net_priority net_vlan2priority ( uint8_t  priority)
inlinestatic

#include <zephyr/net/net_ip.h>

Convert network packet VLAN priority to network packet priority so we can place the packet into correct queue.

Parameters
priorityVLAN priority
Returns
Network priority