Esempio n. 1
0
/**
 * Format and send a ICMP packet.
 * \note: src and dest are on network order.
 */
static int icmp_send (struct _pkt *pkt, DWORD src, DWORD dest, int length)
{
  in_Header *ip   = &pkt->ip;
  ICMP_PKT  *icmp = &pkt->icmp;

  icmp->unused.checksum = 0;
  icmp->unused.checksum = ~CHECKSUM (icmp, length);

  return IP4_OUTPUT (ip, src, dest, ICMP_PROTO, 0, 0, 0, length, NULL);
}
Esempio n. 2
0
static int ping_gateway (DWORD host, void *eth)
{
  struct ping_pkt  *pkt;
  struct icmp_echo *icmp;
  struct in_Header *ip;
  int    len;

  pkt  = (struct ping_pkt*) _eth_formatpacket (eth, IP4_TYPE);
  ip   = &pkt->in;
  icmp = &pkt->icmp;
  len  = sizeof (*icmp);
  icmp_id = (WORD) set_timeout (0);  /* "random" id */

  icmp->type       = ICMP_ECHO;
  icmp->code       = 0;
  icmp->index      = 1;
  icmp->identifier = icmp_id;
  icmp->sequence   = icmp_seq++;
  icmp->checksum   = 0;
  icmp->checksum   = ~CHECKSUM (icmp, len);

  return IP4_OUTPUT (ip, 0, intel(host), ICMP_PROTO, 1,
                     (BYTE)_default_tos, 0, len, NULL);
}