/*

icmp.h

Author: Liraz Siri <liraz@bigfoot.com>

Copyright (c) 1998 Liraz Siri <liraz@bigfoot.com>, Ariel, Israel
                   All rights reserved

Created: Fri Sep 11 19:46:44 GMT 1998

Handle simple icmp functions. send and recieve. 

*/

#define LOCAL_ICMP
#ifndef LOCAL_ICMP
#define icmp_type type
#define icmp_code code
#define icmp_cksum checksum
#define icmp_id un.echo.id
#define icmp_seq un.echo.sequence
#endif

#ifndef LOCAL_ICMP
#define icmp_echo	icmphdr
#endif

#define PKTSIZE		64
#define ICMP_ID		6666

#define ICMP_TIMEOUT	3	/* maximum response time (in seconds) */
/*
 *  ICMP_ECHO / ICMP_ECHOREPLY header prototype
 */

#ifdef LOCAL_ICMP
struct icmp_hdr
{
    u_char  icmp_type;          /* 1 byte type              */
    u_char  icmp_code;          /* 1 byte code              */
    u_short icmp_cksum;         /* 2 byte checksum          */
    u_short icmp_id;            /* 2 byte identification    */
    u_short icmp_seq;           /* 2 byte sequence number   */
};
#endif

/* calculate round trip time */
unsigned long icmp_get_rtt(struct sockaddr_in *addr, int packets);

/* Send an echo icmp request to `addr' */
int icmp_send_echo(struct sockaddr_in *addr);

/* Wait for an echo reply from `addr' */
int icmp_wait_reply(struct sockaddr_in *addr);

/* Just calculate the icmp checksum */
static int icmp_in_cksum(u_short *addr, int len);

