lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RE : [lwip-devel] Outgoing Ping support for LWIP...


From: Kieran Mansley
Subject: Re: RE : [lwip-devel] Outgoing Ping support for LWIP...
Date: Wed, 18 Jul 2007 16:19:31 +0100

On Wed, 2007-07-18 at 17:13 +0200, Frédéric BERNON wrote:
> Hi Steve,
>  
> What API layer do you use? socket or raw/native ? For the second one,
> I remember there is a sample for that in the contrib/ports/unix. 
>  

So there is, I didn't realise we supported that, but makes sense now I
see it:

static void
ping_send(int s, struct ip_addr *addr)
{
  struct icmp_echo_hdr *iecho;
  struct sockaddr_in to;

  if (!(iecho = malloc(sizeof(struct icmp_echo_hdr))))
    return;

  ICMPH_TYPE_SET(iecho,ICMP_ECHO);
  iecho->chksum = 0;
  iecho->seqno = htons(seq_num);
  iecho->chksum = inet_chksum(iecho, sizeof(*iecho));

  to.sin_len = sizeof(to);
  to.sin_family = AF_INET;
  to.sin_addr.s_addr = addr->addr;

  lwip_sendto(s,iecho,sizeof(*iecho),0,(struct sockaddr*)&to,sizeof
(to));

  free(iecho);
  seq_num++;
}

Kieran





reply via email to

[Prev in Thread] Current Thread [Next in Thread]