|
| 1 | +/**************************************************************************** |
| 2 | + * apps/include/netutils/icmp_pub.h |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + * |
| 6 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 7 | + * contributor license agreements. See the NOTICE file distributed with |
| 8 | + * this work for additional information regarding copyright ownership. The |
| 9 | + * ASF licenses this file to you under the Apache License, Version 2.0 (the |
| 10 | + * "License"); you may not use this file except in compliance with the |
| 11 | + * License. You may obtain a copy of the License at |
| 12 | + * |
| 13 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | + * |
| 15 | + * Unless required by applicable law or agreed to in writing, software |
| 16 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 17 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 18 | + * License for the specific language governing permissions and limitations |
| 19 | + * under the License. |
| 20 | + * |
| 21 | + ****************************************************************************/ |
| 22 | + |
| 23 | +#ifndef __APPS_INCLUDE_NETUTILS_ICMP_PUB_H |
| 24 | +#define __APPS_INCLUDE_NETUTILS_ICMP_PUB_H |
| 25 | + |
| 26 | +#define ICMP_E_HOSTIP -1 /* extra: not used */ |
| 27 | + |
| 28 | +struct ping_result_s; |
| 29 | + |
| 30 | +struct ping_info_s |
| 31 | +{ |
| 32 | + FAR const char *hostname; /* Host name to ping */ |
| 33 | +#ifdef CONFIG_NET_BINDTODEVICE |
| 34 | + FAR const char *devname; /* Device name to bind */ |
| 35 | +#endif |
| 36 | + uint16_t flag; /* v4 or v6 */ |
| 37 | + uint16_t count; /* Number of pings requested */ |
| 38 | + uint16_t datalen; /* Number of bytes to be sent */ |
| 39 | + uint16_t delay; /* Deciseconds to delay between pings */ |
| 40 | + uint16_t timeout; /* Deciseconds to wait response before timeout */ |
| 41 | + FAR void *priv; /* Private context for callback */ |
| 42 | + void (*callback)(FAR const struct ping_result_s *result); |
| 43 | +}; |
| 44 | + |
| 45 | +struct ping_result_s |
| 46 | +{ |
| 47 | + int code; /* Notice code ICMPv6_I/E/W_XXX */ |
| 48 | + long extra; /* Extra information for code */ |
| 49 | + union |
| 50 | + { |
| 51 | +#ifdef CONFIG_SYSTEM_PING |
| 52 | + struct in_addr v4; /* Target address to ping */ |
| 53 | +#endif |
| 54 | +#ifdef CONFIG_SYSTEM_PING6 |
| 55 | + struct in6_addr v6; /* Target address to ping */ |
| 56 | +#endif |
| 57 | + } dest; |
| 58 | + uint16_t nrequests; /* Number of ICMP ECHO requests sent */ |
| 59 | + uint16_t nreplies; /* Number of matching ICMP ECHO replies received */ |
| 60 | + uint16_t outsize; /* Bytes(include ICMP header) to be sent */ |
| 61 | + uint16_t id; /* ICMPv6_ECHO id */ |
| 62 | + uint16_t seqno; /* ICMPv6_ECHO seqno */ |
| 63 | + FAR const struct ping_info_s *info; |
| 64 | +}; |
| 65 | + |
| 66 | +#undef EXTERN |
| 67 | +#if defined(__cplusplus) |
| 68 | +#define EXTERN extern "C" |
| 69 | +extern "C" |
| 70 | +{ |
| 71 | +#else |
| 72 | +#define EXTERN extern |
| 73 | +#endif |
| 74 | + |
| 75 | +void icmp_ping(FAR const struct ping_info_s *info); |
| 76 | +void icmp6_ping(FAR const struct ping_info_s *info); |
| 77 | + |
| 78 | +#undef EXTERN |
| 79 | +#ifdef __cplusplus |
| 80 | +} |
| 81 | +#endif |
| 82 | +#endif /* __APPS_INCLUDE_NETUTILS_ICMP_PUB_H */ |
0 commit comments