mikroSDK Reference Manual
ping.h
Go to the documentation of this file.
1
31#ifndef _PING_H
32#define _PING_H
33
34//Dependencies
35#include "core/net.h"
36#include "ipv4/icmp.h"
37#include "ipv6/icmpv6.h"
38
39//Ping utility support
40#ifndef PING_SUPPORT
41 #define PING_SUPPORT ENABLED
42#elif (PING_SUPPORT != ENABLED && PING_SUPPORT != DISABLED)
43 #error PING_SUPPORT parameter is not valid
44#endif
45
46//Default timeout value
47#ifndef PING_DEFAULT_TIMEOUT
48 #define PING_DEFAULT_TIMEOUT 1000
49#elif (PING_DEFAULT_TIMEOUT < 0)
50 #error PING_DEFAULT_TIMEOUT parameter is not valid
51#endif
52
53//Maximum size of the data payload
54#ifndef PING_MAX_DATA_SIZE
55 #define PING_MAX_DATA_SIZE 32
56#elif (PING_MAX_DATA_SIZE < 0)
57 #error PING_MAX_DATA_SIZE parameter is not valid
58#endif
59
60//Size of the internal buffer
61#define PING_BUFFER_SIZE (sizeof(IcmpEchoMessage) + PING_MAX_DATA_SIZE)
62
63//C++ guard
64#ifdef __cplusplus
65extern "C" {
66#endif
67
68
73typedef struct
74{
75 NetInterface *interface;
76 Socket *socket;
77 size_t dataPayloadSize;
78 uint16_t identifier;
79 uint16_t sequenceNumber;
80 systime_t timestamp;
81 systime_t timeout;
82 systime_t rtt;
83 uint8_t buffer[PING_BUFFER_SIZE];
85
86
87//Ping related functions
88error_t ping(NetInterface *interface, const IpAddr *targetIpAddr,
89 size_t size, uint8_t ttl, systime_t timeout, systime_t *rtt);
90
91void pingInit(PingContext *context);
92error_t pingSetTimeout(PingContext *context, systime_t timeout);
93error_t pingBindToInterface(PingContext *context, NetInterface *interface);
94
95error_t pingSendRequest(PingContext *context,
96 const IpAddr *targetIpAddr, size_t size, uint8_t ttl);
97
98error_t pingWaitForReply(PingContext *context,
99 IpAddr *targetIpAddr, systime_t *rtt);
100
101void pingRelease(PingContext *context);
102
103//C++ guard
104#ifdef __cplusplus
105}
106#endif
107
108#endif
error_t
Error codes.
Definition error.h:43
ICMP (Internet Control Message Protocol)
ICMPv6 (Internet Control Message Protocol Version 6)
TCP/IP stack core.
uint32_t systime_t
System time.
Definition os_port_none.h:90
IP network address.
Definition ip.h:72
Ping context.
Definition ping.h:74