Microchip® Advanced Software Framework

ping.c File Reference

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"

static void ping_prepare_echo ( struct icmp_echo_hdr iecho,
u16_t  len 
)
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().

u16_t ping_seq_num
static

Referenced by ping_prepare_echo(), and ping_recv().

u32_t ping_time
static

Referenced by ping_function(), and ping_recv().