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