Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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 <logging/log.h>
20#include <sys/__assert.h>
21#include <kernel.h>
22
23#include <net/net_timeout.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
45/* Network subsystem logging helpers */
46#ifdef CONFIG_THREAD_NAME
47#define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt, \
48 log_strdup(k_thread_name_get(k_current_get())), \
49 ##__VA_ARGS__)
50#else
51#define NET_DBG(fmt, ...) LOG_DBG("(%p): " fmt, k_current_get(), \
52 ##__VA_ARGS__)
53#endif /* CONFIG_THREAD_NAME */
54#define NET_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
55#define NET_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
56#define NET_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
57
58#define NET_HEXDUMP_DBG(_data, _length, _str) LOG_HEXDUMP_DBG(_data, _length, _str)
59#define NET_HEXDUMP_ERR(_data, _length, _str) LOG_HEXDUMP_ERR(_data, _length, _str)
60#define NET_HEXDUMP_WARN(_data, _length, _str) LOG_HEXDUMP_WRN(_data, _length, _str)
61#define NET_HEXDUMP_INFO(_data, _length, _str) LOG_HEXDUMP_INF(_data, _length, _str)
62
63#define NET_ASSERT(cond, ...) __ASSERT(cond, "" __VA_ARGS__)
64
65/* This needs to be here in order to avoid circular include dependency between
66 * net_pkt.h and net_if.h
67 */
68#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
69 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
70#if !defined(NET_PKT_DETAIL_STATS_COUNT)
71#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
72
73#if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
74#define NET_PKT_DETAIL_STATS_COUNT 4
75#else
76#define NET_PKT_DETAIL_STATS_COUNT 3
77#endif /* CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
78
79#else
80#define NET_PKT_DETAIL_STATS_COUNT 4
81#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL */
82
83#endif /* !NET_PKT_DETAIL_STATS_COUNT */
84#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
85 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
86
89struct net_buf;
90struct net_pkt;
91struct net_context;
92struct net_if;
93
106};
107
118int net_recv_data(struct net_if *iface, struct net_pkt *pkt);
119
132int net_send_data(struct net_pkt *pkt);
133
136/* Some helper defines for traffic class support */
137#if defined(CONFIG_NET_TC_TX_COUNT) && defined(CONFIG_NET_TC_RX_COUNT)
138#define NET_TC_TX_COUNT CONFIG_NET_TC_TX_COUNT
139#define NET_TC_RX_COUNT CONFIG_NET_TC_RX_COUNT
140
141#if NET_TC_TX_COUNT > NET_TC_RX_COUNT
142#define NET_TC_COUNT NET_TC_TX_COUNT
143#else
144#define NET_TC_COUNT NET_TC_RX_COUNT
145#endif
146#else /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
147#define NET_TC_TX_COUNT 0
148#define NET_TC_RX_COUNT 0
149#define NET_TC_COUNT 0
150#endif /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
151
152/* @endcond */
153
158#ifdef __cplusplus
159}
160#endif
161
162#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:97
@ NET_OK
Definition: net_core.h:99
@ NET_DROP
Definition: net_core.h:105
@ NET_CONTINUE
Definition: net_core.h:103
Network timer with wrap around.
Network buffer representation.
Definition: buf.h:919
Definition: net_context.h:201
Network Interface structure.
Definition: net_if.h:468
Network packet.
Definition: net_pkt.h:62