Ping sender module.
#include "lwip/opt.h"
#include "ping.h"
#include "lwip/mem.h"
#include "lwip/raw.h"
#include "lwip/icmp.h"
#include "lwip/netif.h"
#include "lwip/sys.h"
#include "lwip/timers.h"
#include "lwip/inet_chksum.h"
#include "lwip/sockets.h"
#include "lwip/inet.h"
Macros | |
#define | PING_DATA_SIZE 32 |
ping additional data size to include in the packet More... | |
#define | PING_DEBUG LWIP_DBG_ON |
This is an example of a "ping" sender (with raw API and socket API). More... | |
#define | PING_DELAY 1000 |
ping delay - in milliseconds More... | |
#define | PING_ID 0xAFAF |
ping identifier - must fit on a u16_t More... | |
#define | PING_RCV_TIMEO 5000 |
ping receive timeout - in milliseconds More... | |
#define | PING_RESULT(ping_ok) |
ping result action - no default action More... | |
#define | PING_TARGET (netif_default?netif_default->gw:ip_addr_any) |
ping target - should be a "ip_addr_t" More... | |
Functions | |
void | ping_function (char *addr, u32_t PingCount) |
static void | ping_prepare_echo (struct icmp_echo_hdr *iecho, u16_t len) |
Prepare a echo ICMP request. More... | |
static void | ping_recv (int s) |
static err_t | ping_send (int s, ip_addr_t *addr) |
Variables | |
static u16_t | ping_seq_num |
static u32_t | ping_time |
#define PING_DATA_SIZE 32 |
ping additional data size to include in the packet
#define PING_DEBUG LWIP_DBG_ON |
This is an example of a "ping" sender (with raw API and socket API).
It can be used as a start point to maintain opened a network connection, or like a network "watchdog" for your device. PING_DEBUG: Enable debugging for PING.
Referenced by ping_function(), and ping_recv().
#define PING_DELAY 1000 |
ping delay - in milliseconds
Referenced by ping_function().
#define PING_ID 0xAFAF |
ping identifier - must fit on a u16_t
Referenced by ping_prepare_echo(), and ping_recv().
#define PING_RCV_TIMEO 5000 |
ping receive timeout - in milliseconds
Referenced by ping_function().
#define PING_RESULT | ( | ping_ok | ) |
ping result action - no default action
Referenced by ping_recv().
#define PING_TARGET (netif_default?netif_default->gw:ip_addr_any) |
ping target - should be a "ip_addr_t"
References AF_INET, close, ERR_OK, inet_pton, ip_addr_debug_print, IP_PROTO_ICMP, LWIP_DEBUGF, lwip_setsockopt(), lwip_socket(), osprintf(), PING_DEBUG, PING_DELAY, PING_RCV_TIMEO, ping_recv(), ping_send(), ping_time, SO_RCVTIMEO, SOCK_RAW, SOL_SOCKET, sys_msleep(), sys_now(), and timeout.
Referenced by wilc_task_1().
|
static |
Prepare a echo ICMP request.
References htons, ICMP_ECHO, ICMPH_CODE_SET, ICMPH_TYPE_SET, inet_chksum(), PING_ID, and ping_seq_num.
Referenced by ping_send().
|
static |
References htons, ICMP_ER, ICMPH_TYPE, inet_addr_to_ipaddr, ip_addr_debug_print, IPH_HL, LWIP_DEBUGF, lwip_recvfrom(), MSG_DONTWAIT, PING_DEBUG, PING_ID, PING_RESULT, ping_seq_num, ping_time, sockaddr_in::sin_addr, sys_now(), and U32_F.
Referenced by ping_function().
References AF_INET, ERR_MEM, ERR_OK, ERR_VAL, inet_addr_from_ipaddr, LWIP_ASSERT, lwip_sendto(), mem_free, mem_malloc, ping_prepare_echo(), sockaddr_in::sin_addr, sockaddr_in::sin_family, and sockaddr_in::sin_len.
Referenced by ping_function().
|
static |
Referenced by ping_prepare_echo(), and ping_recv().
|
static |
Referenced by ping_function(), and ping_recv().