Merge pull request #286 from aozima/pulls

Pulls
This commit is contained in:
Bernard Xiong 2014-06-15 17:38:32 +08:00
commit 1dc376b2f4
2 changed files with 194 additions and 184 deletions

View File

@ -64,12 +64,12 @@ static void ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
}
/* Ping using the socket ip */
static err_t ping_send(int s, struct ip_addr *addr)
static err_t ping_send(int s, struct ip_addr *addr, int size)
{
int err;
struct icmp_echo_hdr *iecho;
struct sockaddr_in to;
size_t ping_size = sizeof(struct icmp_echo_hdr) + PING_DATA_SIZE;
size_t ping_size = sizeof(struct icmp_echo_hdr) + size;
LWIP_ASSERT("ping_size is too big", ping_size <= 0xffff);
iecho = rt_malloc(ping_size);
@ -138,6 +138,9 @@ rt_err_t ping(char* target, rt_uint32_t time, rt_size_t size)
send_time = 0;
if(size == 0)
size = PING_DATA_SIZE;
if (inet_aton(target, (struct in_addr*)&ping_target) == 0) return -RT_ERROR;
addr = (struct _ip_addr*)&ping_target;
@ -151,7 +154,7 @@ rt_err_t ping(char* target, rt_uint32_t time, rt_size_t size)
while (1)
{
if (ping_send(s, &ping_target) == ERR_OK)
if (ping_send(s, &ping_target, size) == ERR_OK)
{
rt_kprintf("ping: send %d.%d.%d.%d\n", addr->addr0, addr->addr1, addr->addr2, addr->addr3);
ping_recv(s);
@ -167,6 +170,8 @@ rt_err_t ping(char* target, rt_uint32_t time, rt_size_t size)
rt_thread_delay(PING_DELAY); /* take a delay */
}
lwip_close(s);
return RT_EOK;
}
#ifdef RT_USING_FINSH

View File

@ -64,12 +64,12 @@ static void ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
}
/* Ping using the socket ip */
static err_t ping_send(int s, struct ip_addr *addr)
static err_t ping_send(int s, struct ip_addr *addr, int size)
{
int err;
struct icmp_echo_hdr *iecho;
struct sockaddr_in to;
size_t ping_size = sizeof(struct icmp_echo_hdr) + PING_DATA_SIZE;
size_t ping_size = sizeof(struct icmp_echo_hdr) + size;
LWIP_ASSERT("ping_size is too big", ping_size <= 0xffff);
iecho = rt_malloc(ping_size);
@ -138,6 +138,9 @@ rt_err_t ping(char* target, rt_uint32_t time, rt_size_t size)
send_time = 0;
if(size == 0)
size = PING_DATA_SIZE;
if (inet_aton(target, (struct in_addr*)&ping_target) == 0) return -RT_ERROR;
addr = (struct _ip_addr*)&ping_target;
@ -151,7 +154,7 @@ rt_err_t ping(char* target, rt_uint32_t time, rt_size_t size)
while (1)
{
if (ping_send(s, &ping_target) == ERR_OK)
if (ping_send(s, &ping_target, size) == ERR_OK)
{
rt_kprintf("ping: send %d.%d.%d.%d\n", addr->addr0, addr->addr1, addr->addr2, addr->addr3);
ping_recv(s);
@ -167,6 +170,8 @@ rt_err_t ping(char* target, rt_uint32_t time, rt_size_t size)
rt_thread_delay(PING_DELAY); /* take a delay */
}
lwip_close(s);
return RT_EOK;
}
#ifdef RT_USING_FINSH