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"
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 | |
static void | ping_prepare_echo (struct icmp_echo_hdr *iecho, u16_t len) |
Prepare a echo ICMP request. More... | |
static void | ping_raw_init (void) |
static u8_t | ping_recv (void *arg, struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *addr) |
static void | ping_send (struct raw_pcb *raw, ip_addr_t *addr) |
void | ping_send_now () |
static void | ping_timeout (void *arg) |
Variables | |
static struct raw_pcb * | ping_pcb |
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_recv(), and ping_send().
#define PING_DELAY 1000 |
ping delay - in milliseconds
Referenced by ping_raw_init(), and ping_timeout().
#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
#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"
Referenced by ping_send_now(), and ping_timeout().
|
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().
References IP_ADDR_ANY, IP_PROTO_ICMP, LWIP_ASSERT, NULL, PING_DELAY, ping_recv(), ping_timeout(), raw_bind(), raw_new(), raw_recv(), and sys_timeout().
|
static |
References htons, if(), ip_addr_debug_print, LWIP_ASSERT, LWIP_DEBUGF, NULL, pbuf::payload, pbuf_free(), pbuf_header(), PBUF_IP_HLEN, PING_DEBUG, PING_ID, PING_RESULT, ping_seq_num, ping_time, sys_now(), pbuf::tot_len, and U32_F.
Referenced by ping_raw_init().
References ip_addr_debug_print, pbuf::len, LWIP_ASSERT, LWIP_DEBUGF, pbuf::next, NULL, pbuf::payload, pbuf_alloc(), pbuf_free(), PBUF_IP, PBUF_RAM, PING_DEBUG, ping_prepare_echo(), ping_time, raw_sendto(), sys_now(), and pbuf::tot_len.
Referenced by ping_send_now(), and ping_timeout().
References LWIP_ASSERT, NULL, ping_send(), and PING_TARGET.
References LWIP_ASSERT, NULL, PING_DELAY, ping_send(), PING_TARGET, and sys_timeout().
Referenced by ping_raw_init().
|
static |
|
static |
Referenced by ping_prepare_echo(), and ping_recv().
|
static |
Referenced by ping_recv(), and ping_send().