if LwIP supports sockets, the ping example will switch to the socket interface

This commit is contained in:
Stefan Lankes 2011-07-04 10:51:30 -07:00
parent 351a0f6391
commit 0fe5027a63

View file

@ -43,7 +43,7 @@
#include <metalsvm/processor.h>
#include <lwip/opt.h>
#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
#if LWIP_RAW || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
#include <lwip/mem.h>
#include <lwip/raw.h>
@ -53,6 +53,10 @@
#include <lwip/timers.h>
#include <lwip/inet_chksum.h>
#if LWIP_SOCKET
#define PING_USE_SOCKETS 1
#endif
#if PING_USE_SOCKETS
#include <lwip/sockets.h>
#include <lwip/inet.h>
@ -194,7 +198,7 @@ ping_recv(int s)
static void
ping_thread(void *arg)
{
int s;
int s, i;
int timeout = PING_RCV_TIMEO;
ip_addr_t ping_target;
@ -207,7 +211,7 @@ ping_thread(void *arg)
lwip_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
while (1) {
for(i=0; i<10; i++) {
ping_target = PING_TARGET;
if (ping_send(s, &ping_target) == ERR_OK) {
@ -224,6 +228,8 @@ ping_thread(void *arg)
}
sys_msleep(PING_DELAY);
}
lwip_close(s);
}
#else /* PING_USE_SOCKETS */