Webserver+3d print

Dependents:   Nucleo

Committer:
Sergunb
Date:
Sat Feb 04 18:15:49 2017 +0000
Revision:
0:8918a71cdbe9
nothing else

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sergunb 0:8918a71cdbe9 1 /**
Sergunb 0:8918a71cdbe9 2 * @file ping.h
Sergunb 0:8918a71cdbe9 3 * @brief Ping utility
Sergunb 0:8918a71cdbe9 4 *
Sergunb 0:8918a71cdbe9 5 * @section License
Sergunb 0:8918a71cdbe9 6 *
Sergunb 0:8918a71cdbe9 7 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
Sergunb 0:8918a71cdbe9 8 *
Sergunb 0:8918a71cdbe9 9 * This file is part of CycloneTCP Open.
Sergunb 0:8918a71cdbe9 10 *
Sergunb 0:8918a71cdbe9 11 * This program is free software; you can redistribute it and/or
Sergunb 0:8918a71cdbe9 12 * modify it under the terms of the GNU General Public License
Sergunb 0:8918a71cdbe9 13 * as published by the Free Software Foundation; either version 2
Sergunb 0:8918a71cdbe9 14 * of the License, or (at your option) any later version.
Sergunb 0:8918a71cdbe9 15 *
Sergunb 0:8918a71cdbe9 16 * This program is distributed in the hope that it will be useful,
Sergunb 0:8918a71cdbe9 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Sergunb 0:8918a71cdbe9 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Sergunb 0:8918a71cdbe9 19 * GNU General Public License for more details.
Sergunb 0:8918a71cdbe9 20 *
Sergunb 0:8918a71cdbe9 21 * You should have received a copy of the GNU General Public License
Sergunb 0:8918a71cdbe9 22 * along with this program; if not, write to the Free Software Foundation,
Sergunb 0:8918a71cdbe9 23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Sergunb 0:8918a71cdbe9 24 *
Sergunb 0:8918a71cdbe9 25 * @author Oryx Embedded SARL (www.oryx-embedded.com)
Sergunb 0:8918a71cdbe9 26 * @version 1.7.6
Sergunb 0:8918a71cdbe9 27 **/
Sergunb 0:8918a71cdbe9 28
Sergunb 0:8918a71cdbe9 29 #ifndef _PING_H
Sergunb 0:8918a71cdbe9 30 #define _PING_H
Sergunb 0:8918a71cdbe9 31
Sergunb 0:8918a71cdbe9 32 //Dependencies
Sergunb 0:8918a71cdbe9 33 #include "core/net.h"
Sergunb 0:8918a71cdbe9 34 #include "ipv4/icmp.h"
Sergunb 0:8918a71cdbe9 35 #include "ipv6/icmpv6.h"
Sergunb 0:8918a71cdbe9 36
Sergunb 0:8918a71cdbe9 37 //Ping utility support
Sergunb 0:8918a71cdbe9 38 #ifndef PING_SUPPORT
Sergunb 0:8918a71cdbe9 39 #define PING_SUPPORT ENABLED
Sergunb 0:8918a71cdbe9 40 #elif (PING_SUPPORT != ENABLED && PING_SUPPORT != DISABLED)
Sergunb 0:8918a71cdbe9 41 #error PING_SUPPORT parameter is not valid
Sergunb 0:8918a71cdbe9 42 #endif
Sergunb 0:8918a71cdbe9 43
Sergunb 0:8918a71cdbe9 44 //Default timeout value
Sergunb 0:8918a71cdbe9 45 #ifndef PING_DEFAULT_TIMEOUT
Sergunb 0:8918a71cdbe9 46 #define PING_DEFAULT_TIMEOUT 1000
Sergunb 0:8918a71cdbe9 47 #elif (PING_DEFAULT_TIMEOUT < 0)
Sergunb 0:8918a71cdbe9 48 #error PING_DEFAULT_TIMEOUT parameter is not valid
Sergunb 0:8918a71cdbe9 49 #endif
Sergunb 0:8918a71cdbe9 50
Sergunb 0:8918a71cdbe9 51 //Maximum size of the data payload
Sergunb 0:8918a71cdbe9 52 #ifndef PING_MAX_DATA_SIZE
Sergunb 0:8918a71cdbe9 53 #define PING_MAX_DATA_SIZE 32
Sergunb 0:8918a71cdbe9 54 #elif (PING_MAX_DATA_SIZE < 0)
Sergunb 0:8918a71cdbe9 55 #error PING_MAX_DATA_SIZE parameter is not valid
Sergunb 0:8918a71cdbe9 56 #endif
Sergunb 0:8918a71cdbe9 57
Sergunb 0:8918a71cdbe9 58 //Size of the internal buffer
Sergunb 0:8918a71cdbe9 59 #define PING_BUFFER_SIZE (sizeof(IcmpEchoMessage) + PING_MAX_DATA_SIZE)
Sergunb 0:8918a71cdbe9 60
Sergunb 0:8918a71cdbe9 61
Sergunb 0:8918a71cdbe9 62 /**
Sergunb 0:8918a71cdbe9 63 * @brief Ping context
Sergunb 0:8918a71cdbe9 64 **/
Sergunb 0:8918a71cdbe9 65
Sergunb 0:8918a71cdbe9 66 typedef struct
Sergunb 0:8918a71cdbe9 67 {
Sergunb 0:8918a71cdbe9 68 NetInterface *interface;
Sergunb 0:8918a71cdbe9 69 Socket *socket;
Sergunb 0:8918a71cdbe9 70 size_t dataPayloadSize;
Sergunb 0:8918a71cdbe9 71 uint16_t identifier;
Sergunb 0:8918a71cdbe9 72 uint16_t sequenceNumber;
Sergunb 0:8918a71cdbe9 73 systime_t timestamp;
Sergunb 0:8918a71cdbe9 74 systime_t timeout;
Sergunb 0:8918a71cdbe9 75 systime_t rtt;
Sergunb 0:8918a71cdbe9 76 uint8_t buffer[PING_BUFFER_SIZE];
Sergunb 0:8918a71cdbe9 77 } PingContext;
Sergunb 0:8918a71cdbe9 78
Sergunb 0:8918a71cdbe9 79
Sergunb 0:8918a71cdbe9 80 //Ping related functions
Sergunb 0:8918a71cdbe9 81 error_t ping(NetInterface *interface, const IpAddr *targetIpAddr,
Sergunb 0:8918a71cdbe9 82 size_t size, uint8_t ttl, systime_t timeout, systime_t *rtt);
Sergunb 0:8918a71cdbe9 83
Sergunb 0:8918a71cdbe9 84 void pingInit(PingContext *context);
Sergunb 0:8918a71cdbe9 85 error_t pingSetTimeout(PingContext *context, systime_t timeout);
Sergunb 0:8918a71cdbe9 86 error_t pingBindToInterface(PingContext *context, NetInterface *interface);
Sergunb 0:8918a71cdbe9 87
Sergunb 0:8918a71cdbe9 88 error_t pingSendRequest(PingContext *context,
Sergunb 0:8918a71cdbe9 89 const IpAddr *targetIpAddr, size_t size, uint8_t ttl);
Sergunb 0:8918a71cdbe9 90
Sergunb 0:8918a71cdbe9 91 error_t pingWaitForReply(PingContext *context,
Sergunb 0:8918a71cdbe9 92 IpAddr *targetIpAddr, systime_t *rtt);
Sergunb 0:8918a71cdbe9 93
Sergunb 0:8918a71cdbe9 94 void pingRelease(PingContext *context);
Sergunb 0:8918a71cdbe9 95
Sergunb 0:8918a71cdbe9 96 #endif
Sergunb 0:8918a71cdbe9 97