Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ping.h
00001 /** 00002 * @file ping.h 00003 * @brief Ping utility 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 #ifndef _PING_H 00030 #define _PING_H 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 #include "ipv4/icmp.h" 00035 #include "ipv6/icmpv6.h" 00036 00037 //Ping utility support 00038 #ifndef PING_SUPPORT 00039 #define PING_SUPPORT ENABLED 00040 #elif (PING_SUPPORT != ENABLED && PING_SUPPORT != DISABLED) 00041 #error PING_SUPPORT parameter is not valid 00042 #endif 00043 00044 //Default timeout value 00045 #ifndef PING_DEFAULT_TIMEOUT 00046 #define PING_DEFAULT_TIMEOUT 1000 00047 #elif (PING_DEFAULT_TIMEOUT < 0) 00048 #error PING_DEFAULT_TIMEOUT parameter is not valid 00049 #endif 00050 00051 //Maximum size of the data payload 00052 #ifndef PING_MAX_DATA_SIZE 00053 #define PING_MAX_DATA_SIZE 32 00054 #elif (PING_MAX_DATA_SIZE < 0) 00055 #error PING_MAX_DATA_SIZE parameter is not valid 00056 #endif 00057 00058 //Size of the internal buffer 00059 #define PING_BUFFER_SIZE (sizeof(IcmpEchoMessage) + PING_MAX_DATA_SIZE) 00060 00061 00062 /** 00063 * @brief Ping context 00064 **/ 00065 00066 typedef struct 00067 { 00068 NetInterface *interface; 00069 Socket *socket; 00070 size_t dataPayloadSize; 00071 uint16_t identifier; 00072 uint16_t sequenceNumber; 00073 systime_t timestamp; 00074 systime_t timeout; 00075 systime_t rtt; 00076 uint8_t buffer[PING_BUFFER_SIZE]; 00077 } PingContext; 00078 00079 00080 //Ping related functions 00081 error_t ping(NetInterface *interface, const IpAddr *targetIpAddr, 00082 size_t size, uint8_t ttl, systime_t timeout, systime_t *rtt); 00083 00084 void pingInit(PingContext *context); 00085 error_t pingSetTimeout(PingContext *context, systime_t timeout); 00086 error_t pingBindToInterface(PingContext *context, NetInterface *interface); 00087 00088 error_t pingSendRequest(PingContext *context, 00089 const IpAddr *targetIpAddr, size_t size, uint8_t ttl); 00090 00091 error_t pingWaitForReply(PingContext *context, 00092 IpAddr *targetIpAddr, systime_t *rtt); 00093 00094 void pingRelease(PingContext *context); 00095 00096 #endif 00097
Generated on Tue Jul 12 2022 17:10:15 by
1.7.2