Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
50/* Network subsystem logging helpers */
51#ifdef CONFIG_THREAD_NAME
52#define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt, \
53 k_thread_name_get(k_current_get()), \
54 ##__VA_ARGS__)
55#else
56#define NET_DBG(fmt, ...) LOG_DBG("(%p): " fmt, k_current_get(), \
57 ##__VA_ARGS__)
58#endif /* CONFIG_THREAD_NAME */
59#define NET_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
60#define NET_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
61#define NET_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
62
63#define NET_HEXDUMP_DBG(_data, _length, _str) LOG_HEXDUMP_DBG(_data, _length, _str)
64#define NET_HEXDUMP_ERR(_data, _length, _str) LOG_HEXDUMP_ERR(_data, _length, _str)
65#define NET_HEXDUMP_WARN(_data, _length, _str) LOG_HEXDUMP_WRN(_data, _length, _str)
66#define NET_HEXDUMP_INFO(_data, _length, _str) LOG_HEXDUMP_INF(_data, _length, _str)
67
68#define NET_ASSERT(cond, ...) __ASSERT(cond, "" __VA_ARGS__)
69
70/* This needs to be here in order to avoid circular include dependency between
71 * net_pkt.h and net_if.h
72 */
73#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
74 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
75#if !defined(NET_PKT_DETAIL_STATS_COUNT)
76#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
77
78#if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
79#define NET_PKT_DETAIL_STATS_COUNT 4
80#else
81#define NET_PKT_DETAIL_STATS_COUNT 3
82#endif /* CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
83
84#else
85#define NET_PKT_DETAIL_STATS_COUNT 4
86#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL */
87
88#endif /* !NET_PKT_DETAIL_STATS_COUNT */
89#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
90 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
91
94struct net_buf;
95struct net_pkt;
96struct net_context;
97struct net_if;
98
112
123int net_recv_data(struct net_if *iface, struct net_pkt *pkt);
124
137int net_send_data(struct net_pkt *pkt);
138
141/* Some helper defines for traffic class support */
142#if defined(CONFIG_NET_TC_TX_COUNT) && defined(CONFIG_NET_TC_RX_COUNT)
143#define NET_TC_TX_COUNT CONFIG_NET_TC_TX_COUNT
144#define NET_TC_RX_COUNT CONFIG_NET_TC_RX_COUNT
145
146#if NET_TC_TX_COUNT > NET_TC_RX_COUNT
147#define NET_TC_COUNT NET_TC_TX_COUNT
148#else
149#define NET_TC_COUNT NET_TC_RX_COUNT
150#endif
151#else /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
152#define NET_TC_TX_COUNT 0
153#define NET_TC_RX_COUNT 0
154#define NET_TC_COUNT 0
155#endif /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
156
157/* @endcond */
158
163#ifdef __cplusplus
164}
165#endif
166
167#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:102
@ NET_OK
Packet has been taken care of.
Definition net_core.h:104
@ NET_DROP
Packet must be dropped.
Definition net_core.h:110
@ NET_CONTINUE
Packet has not been touched, other part should decide about its fate.
Definition net_core.h:108
Public kernel APIs.
Network timer with wrap around.
Network buffer representation.
Definition net_buf.h:1006
Note that we do not store the actual source IP address in the context because the address is already ...
Definition net_context.h:207
Network Interface structure.
Definition net_if.h:692
Network packet.
Definition net_pkt.h:91