Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
net_core.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2015 Intel Corporation
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12
13#ifndef ZEPHYR_INCLUDE_NET_NET_CORE_H_
14#define ZEPHYR_INCLUDE_NET_NET_CORE_H_
15
16#include <stdbool.h>
17#include <string.h>
18
19#include <zephyr/logging/log.h>
20#include <zephyr/sys/__assert.h>
21#include <zephyr/kernel.h>
22
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
46/* Network subsystem logging helpers */
47#ifdef CONFIG_THREAD_NAME
48#define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt, \
49 k_thread_name_get(k_current_get()), \
50 ##__VA_ARGS__)
51#else
52#define NET_DBG(fmt, ...) LOG_DBG("(%p): " fmt, k_current_get(), \
53 ##__VA_ARGS__)
54#endif /* CONFIG_THREAD_NAME */
55#define NET_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
56#define NET_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
57#define NET_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
58
59#define NET_HEXDUMP_DBG(_data, _length, _str) LOG_HEXDUMP_DBG(_data, _length, _str)
60#define NET_HEXDUMP_ERR(_data, _length, _str) LOG_HEXDUMP_ERR(_data, _length, _str)
61#define NET_HEXDUMP_WARN(_data, _length, _str) LOG_HEXDUMP_WRN(_data, _length, _str)
62#define NET_HEXDUMP_INFO(_data, _length, _str) LOG_HEXDUMP_INF(_data, _length, _str)
63
64#define NET_ASSERT(cond, ...) __ASSERT(cond, "" __VA_ARGS__)
65
66/* This needs to be here in order to avoid circular include dependency between
67 * net_pkt.h and net_if.h
68 */
69#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
70 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
71#if !defined(NET_PKT_DETAIL_STATS_COUNT)
72#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
73
74#if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
75#define NET_PKT_DETAIL_STATS_COUNT 4
76#else
77#define NET_PKT_DETAIL_STATS_COUNT 3
78#endif /* CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
79
80#else
81#define NET_PKT_DETAIL_STATS_COUNT 4
82#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL */
83
84#endif /* !NET_PKT_DETAIL_STATS_COUNT */
85#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
86 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
87
90struct net_buf;
91struct net_pkt;
92struct net_context;
93struct net_if;
94
107};
108
119int net_recv_data(struct net_if *iface, struct net_pkt *pkt);
120
133int net_send_data(struct net_pkt *pkt);
134
137/* Some helper defines for traffic class support */
138#if defined(CONFIG_NET_TC_TX_COUNT) && defined(CONFIG_NET_TC_RX_COUNT)
139#define NET_TC_TX_COUNT CONFIG_NET_TC_TX_COUNT
140#define NET_TC_RX_COUNT CONFIG_NET_TC_RX_COUNT
141
142#if NET_TC_TX_COUNT > NET_TC_RX_COUNT
143#define NET_TC_COUNT NET_TC_TX_COUNT
144#else
145#define NET_TC_COUNT NET_TC_RX_COUNT
146#endif
147#else /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
148#define NET_TC_TX_COUNT 0
149#define NET_TC_RX_COUNT 0
150#define NET_TC_COUNT 0
151#endif /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
152
153/* @endcond */
154
159#ifdef __cplusplus
160}
161#endif
162
163#endif /* ZEPHYR_INCLUDE_NET_NET_CORE_H_ */
int net_send_data(struct net_pkt *pkt)
Send data to network.
int net_recv_data(struct net_if *iface, struct net_pkt *pkt)
Called by lower network stack or network device driver when a network packet has been received.
net_verdict
Net Verdict.
Definition: net_core.h:98
@ NET_OK
Packet has been taken care of.
Definition: net_core.h:100
@ NET_DROP
Packet must be dropped.
Definition: net_core.h:106
@ NET_CONTINUE
Packet has not been touched, other part should decide about its fate.
Definition: net_core.h:104
Public kernel APIs.
Network timer with wrap around.
Network buffer representation.
Definition: buf.h:906
Note that we do not store the actual source IP address in the context because the address is already ...
Definition: net_context.h:201
Network Interface structure.
Definition: net_if.h:595
Network packet.
Definition: net_pkt.h:63