| 
    Zephyr Project API
    3.3.0
    
   A Scalable Open Source RTOS 
   | 
 
Network context definitions. More...
#include <zephyr/kernel.h>#include <zephyr/sys/atomic.h>#include <zephyr/net/net_ip.h>#include <zephyr/net/net_if.h>#include <zephyr/net/net_stats.h>Go to the source code of this file.
Data Structures | |
| struct | net_context | 
Macros | |
| #define | NET_CONTEXT_IN_USE BIT(0) | 
| #define | NET_CONTEXT_FAMILY (BIT(3) | BIT(4) | BIT(5)) | 
| #define | NET_CONTEXT_TYPE (BIT(6) | BIT(7)) | 
| #define | NET_CONTEXT_REMOTE_ADDR_SET BIT(8) | 
| #define | NET_CONTEXT_ACCEPTING_SOCK BIT(9) | 
| #define | NET_CONTEXT_CLOSING_SOCK BIT(10) | 
| #define | NET_CONTEXT_BOUND_TO_IFACE BIT(11) | 
| #define | NET_CONTEXT_STATE_SHIFT 1 | 
| #define | NET_CONTEXT_STATE_MASK 0x03 | 
| #define | net_context_setup_pools(context, tx_pool, data_pool) | 
| Set custom network buffer pools for context send operations.  More... | |
Typedefs | |
| typedef void(* | net_context_recv_cb_t) (struct net_context *context, struct net_pkt *pkt, union net_ip_header *ip_hdr, union net_proto_header *proto_hdr, int status, void *user_data) | 
| Network data receive callback.  More... | |
| typedef void(* | net_context_send_cb_t) (struct net_context *context, int status, void *user_data) | 
| Network data send callback.  More... | |
| typedef void(* | net_tcp_accept_cb_t) (struct net_context *new_context, struct sockaddr *addr, socklen_t addrlen, int status, void *user_data) | 
| Accept callback.  More... | |
| typedef void(* | net_context_connect_cb_t) (struct net_context *context, int status, void *user_data) | 
| Connection callback.  More... | |
| typedef struct k_mem_slab *(* | net_pkt_get_slab_func_t) (void) | 
| Function that is called to get the slab that is used for net_pkt allocations.  More... | |
| typedef struct net_buf_pool *(* | net_pkt_get_pool_func_t) (void) | 
| Function that is called to get the pool that is used for net_buf allocations.  More... | |
| typedef void(* | net_context_cb_t) (struct net_context *context, void *user_data) | 
| Callback used while iterating over network contexts.  More... | |
Enumerations | |
| enum | net_context_state {  NET_CONTEXT_IDLE = 0 , NET_CONTEXT_UNCONNECTED = 0 , NET_CONTEXT_CONFIGURING = 1 , NET_CONTEXT_CONNECTING = 1 , NET_CONTEXT_READY = 2 , NET_CONTEXT_CONNECTED = 2 , NET_CONTEXT_LISTENING = 3 }  | 
| enum | net_context_option {  NET_OPT_PRIORITY = 1 , NET_OPT_TXTIME = 2 , NET_OPT_SOCKS5 = 3 , NET_OPT_RCVTIMEO = 4 , NET_OPT_SNDTIMEO = 5 , NET_OPT_RCVBUF = 6 , NET_OPT_SNDBUF = 7 , NET_OPT_DSCP_ECN = 8 }  | 
Functions | |
| static bool | net_context_is_used (struct net_context *context) | 
| static bool | net_context_is_bound_to_iface (struct net_context *context) | 
| static bool | net_context_is_accepting (struct net_context *context) | 
| Is this context is accepting data now.  More... | |
| static void | net_context_set_accepting (struct net_context *context, bool accepting) | 
| Set this context to accept data now.  More... | |
| static bool | net_context_is_closing (struct net_context *context) | 
| Is this context closing.  More... | |
| static void | net_context_set_closing (struct net_context *context, bool closing) | 
| Set this context to closing.  More... | |
| static enum net_context_state | net_context_get_state (struct net_context *context) | 
| Get state for this network context.  More... | |
| static void | net_context_set_state (struct net_context *context, enum net_context_state state) | 
| Set state for this network context.  More... | |
| static sa_family_t | net_context_get_family (struct net_context *context) | 
| Get address family for this network context.  More... | |
| static void | net_context_set_family (struct net_context *context, sa_family_t family) | 
| Set address family for this network context.  More... | |
| static enum net_sock_type | net_context_get_type (struct net_context *context) | 
| Get context type for this network context.  More... | |
| static void | net_context_set_type (struct net_context *context, enum net_sock_type type) | 
| Set context type for this network context.  More... | |
| static void | net_context_set_can_filter_id (struct net_context *context, int filter_id) | 
| Set CAN filter id for this network context.  More... | |
| static int | net_context_get_can_filter_id (struct net_context *context) | 
| Get CAN filter id for this network context.  More... | |
| static uint16_t | net_context_get_proto (struct net_context *context) | 
| Get context IP protocol for this network context.  More... | |
| static void | net_context_set_proto (struct net_context *context, uint16_t proto) | 
| Set context IP protocol for this network context.  More... | |
| static struct net_if * | net_context_get_iface (struct net_context *context) | 
| Get network interface for this context.  More... | |
| static void | net_context_set_iface (struct net_context *context, struct net_if *iface) | 
| Set network interface for this context.  More... | |
| static uint8_t | net_context_get_ipv4_ttl (struct net_context *context) | 
| static void | net_context_set_ipv4_ttl (struct net_context *context, uint8_t ttl) | 
| static uint8_t | net_context_get_ipv6_hop_limit (struct net_context *context) | 
| static void | net_context_set_ipv6_hop_limit (struct net_context *context, uint8_t hop_limit) | 
| static void | net_context_set_proxy_enabled (struct net_context *context, bool enable) | 
| static bool | net_context_is_proxy_enabled (struct net_context *context) | 
| int | net_context_get (sa_family_t family, enum net_sock_type type, uint16_t ip_proto, struct net_context **context) | 
| Get network context.  More... | |
| int | net_context_put (struct net_context *context) | 
| Close and unref a network context.  More... | |
| int | net_context_ref (struct net_context *context) | 
| Take a reference count to a net_context, preventing destruction.  More... | |
| int | net_context_unref (struct net_context *context) | 
| Decrement the reference count to a network context.  More... | |
| static int | net_context_create_ipv4_new (struct net_context *context, struct net_pkt *pkt, const struct in_addr *src, const struct in_addr *dst) | 
| Create IPv4 packet in provided net_pkt from context.  More... | |
| static int | net_context_create_ipv6_new (struct net_context *context, struct net_pkt *pkt, const struct in6_addr *src, const struct in6_addr *dst) | 
| Create IPv6 packet in provided net_pkt from context.  More... | |
| int | net_context_bind (struct net_context *context, const struct sockaddr *addr, socklen_t addrlen) | 
| Assign a socket a local address.  More... | |
| int | net_context_listen (struct net_context *context, int backlog) | 
| Mark the context as a listening one.  More... | |
| int | net_context_connect (struct net_context *context, const struct sockaddr *addr, socklen_t addrlen, net_context_connect_cb_t cb, k_timeout_t timeout, void *user_data) | 
| Create a network connection.  More... | |
| int | net_context_accept (struct net_context *context, net_tcp_accept_cb_t cb, k_timeout_t timeout, void *user_data) | 
| Accept a network connection attempt.  More... | |
| int | net_context_send (struct net_context *context, const void *buf, size_t len, net_context_send_cb_t cb, k_timeout_t timeout, void *user_data) | 
| Send data to a peer.  More... | |
| int | net_context_sendto (struct net_context *context, const void *buf, size_t len, const struct sockaddr *dst_addr, socklen_t addrlen, net_context_send_cb_t cb, k_timeout_t timeout, void *user_data) | 
| Send data to a peer specified by address.  More... | |
| int | net_context_sendmsg (struct net_context *context, const struct msghdr *msghdr, int flags, net_context_send_cb_t cb, k_timeout_t timeout, void *user_data) | 
| Send data in iovec to a peer specified in msghdr struct.  More... | |
| int | net_context_recv (struct net_context *context, net_context_recv_cb_t cb, k_timeout_t timeout, void *user_data) | 
| Receive network data from a peer specified by context.  More... | |
| int | net_context_update_recv_wnd (struct net_context *context, int32_t delta) | 
| Update TCP receive window for context.  More... | |
| int | net_context_set_option (struct net_context *context, enum net_context_option option, const void *value, size_t len) | 
| Set an connection option for this context.  More... | |
| int | net_context_get_option (struct net_context *context, enum net_context_option option, void *value, size_t *len) | 
| Get connection option value for this context.  More... | |
| void | net_context_foreach (net_context_cb_t cb, void *user_data) | 
| Go through all the network connections and call callback for each network context.  More... | |
| bool | net_context_port_in_use (enum net_ip_protocol ip_proto, uint16_t local_port, const struct sockaddr *local_addr) | 
| Check if a port is in use (bound)  More... | |
Network context definitions.
An API for applications to define a network connection.