Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
icmp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
20
21#ifndef ZEPHYR_INCLUDE_NET_ICMP_H_
22#define ZEPHYR_INCLUDE_NET_ICMP_H_
23
24#include <stddef.h>
25
26#include <zephyr/kernel.h>
27#include <zephyr/types.h>
28#include <zephyr/net/net_ip.h>
29#include <zephyr/net/net_if.h>
30#include <zephyr/net/net_pkt.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#define NET_ICMPV4_ECHO_REQUEST 8
37#define NET_ICMPV4_ECHO_REPLY 0
38#define NET_ICMPV6_ECHO_REQUEST 128
39#define NET_ICMPV6_ECHO_REPLY 129
40
41struct net_icmp_ctx;
42struct net_icmp_ip_hdr;
44
55typedef int (*net_icmp_handler_t)(struct net_icmp_ctx *ctx,
56 struct net_pkt *pkt,
57 struct net_icmp_ip_hdr *ip_hdr,
58 struct net_icmp_hdr *icmp_hdr,
59 void *user_data);
60
78 struct net_if *iface,
79 struct net_sockaddr *dst,
80 struct net_icmp_ping_params *params,
81 void *user_data);
82
108
113 union {
115 struct net_ipv4_hdr *ipv4;
116
118 struct net_ipv6_hdr *ipv6;
119 };
120
123};
124
159
171int net_icmp_init_ctx(struct net_icmp_ctx *ctx, uint8_t family, uint8_t type,
172 uint8_t code, net_icmp_handler_t handler);
173
181
196 struct net_if *iface,
197 struct net_sockaddr *dst,
198 struct net_icmp_ping_params *params,
199 void *user_data);
200
220 struct net_if *iface,
221 struct net_sockaddr *dst,
222 struct net_icmp_ping_params *params,
223 void *user_data);
224
245
259 struct net_if *iface,
261
270
285 net_icmp_handler_t *resp_handler);
286
287#ifdef __cplusplus
288}
289#endif
290
291#endif /* ZEPHYR_INCLUDE_NET_ICMP_H */
292
int(* net_icmp_handler_t)(struct net_icmp_ctx *ctx, struct net_pkt *pkt, struct net_icmp_ip_hdr *ip_hdr, struct net_icmp_hdr *icmp_hdr, void *user_data)
Handler function that is called when ICMP response is received.
Definition icmp.h:55
int net_icmp_send_echo_request_no_wait(struct net_icmp_ctx *ctx, struct net_if *iface, struct net_sockaddr *dst, struct net_icmp_ping_params *params, void *user_data)
Send ICMP echo request message without waiting during send.
int net_icmp_send_echo_request(struct net_icmp_ctx *ctx, struct net_if *iface, struct net_sockaddr *dst, struct net_icmp_ping_params *params, void *user_data)
Send ICMP echo request message.
int net_icmp_register_offload_ping(struct net_icmp_offload *ctx, struct net_if *iface, net_icmp_offload_ping_handler_t ping_handler)
Register a handler function that is called when an Echo-Request is sent to the offloaded device.
int net_icmp_unregister_offload_ping(struct net_icmp_offload *ctx)
Unregister the offload handler.
int net_icmp_init_ctx(struct net_icmp_ctx *ctx, uint8_t family, uint8_t type, uint8_t code, net_icmp_handler_t handler)
Initialize the ICMP context structure.
int net_icmp_cleanup_ctx(struct net_icmp_ctx *ctx)
Cleanup the ICMP context structure.
int net_icmp_get_offload_rsp_handler(struct net_icmp_offload *ctx, net_icmp_handler_t *resp_handler)
Get a ICMP response handler function for an offloaded device.
int(* net_icmp_offload_ping_handler_t)(struct net_icmp_ctx *ctx, struct net_if *iface, struct net_sockaddr *dst, struct net_icmp_ping_params *params, void *user_data)
Handler function that is called when an Echo-Request is sent to offloaded device.
Definition icmp.h:77
unsigned short int net_sa_family_t
Socket address family type.
Definition net_ip.h:168
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
Public kernel APIs.
Public API for network interface.
IPv6 and IPv4 definitions.
Network packet buffer descriptor API.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
ICMP context structure.
Definition icmp.h:86
uint8_t family
Address family the handler is registered for.
Definition icmp.h:100
void * user_data
Opaque user supplied data.
Definition icmp.h:97
sys_snode_t node
List node.
Definition icmp.h:88
struct net_if * iface
Network interface where the ICMP request was sent.
Definition icmp.h:94
uint8_t code
ICMP code of the response type we are waiting.
Definition icmp.h:106
net_icmp_handler_t handler
ICMP response handler.
Definition icmp.h:91
uint8_t type
ICMP type of the response we are waiting.
Definition icmp.h:103
Struct presents either IPv4 or IPv6 header in ICMP response message.
Definition icmp.h:112
net_sa_family_t family
Is the header IPv4 or IPv6 one.
Definition icmp.h:122
struct net_ipv4_hdr * ipv4
IPv4 header in response message.
Definition icmp.h:115
struct net_ipv6_hdr * ipv6
IPv6 header in response message.
Definition icmp.h:118
ICMP offload context structure.
Definition icmp.h:228
net_icmp_handler_t handler
ICMP response handler.
Definition icmp.h:237
net_icmp_offload_ping_handler_t ping_handler
ICMP offloaded ping handler.
Definition icmp.h:240
sys_snode_t node
List node.
Definition icmp.h:230
struct net_if * iface
Offloaded network interface.
Definition icmp.h:243
Struct presents parameters that are needed when sending Echo-Request (ping) messages.
Definition icmp.h:129
uint16_t identifier
An identifier to aid in matching Echo Replies to this Echo Request.
Definition icmp.h:133
size_t data_size
Size of the Payload Data in bytes.
Definition icmp.h:157
uint16_t sequence
A sequence number to aid in matching Echo Replies to this Echo Request.
Definition icmp.h:138
int priority
Network packet priority.
Definition icmp.h:146
uint8_t tc_tos
Can be either IPv4 Type-of-service field value, or IPv6 Traffic Class field value.
Definition icmp.h:143
const void * data
Arbitrary payload data that will be included in the Echo Reply verbatim.
Definition icmp.h:151
Network Interface structure.
Definition net_if.h:726
Network packet.
Definition net_pkt.h:91
Generic sockaddr struct.
Definition net_ip.h:408