The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
libping.h
Go to the documentation of this file.
1 
22 #ifndef PING_H
23 #define PING_H
24 
25 #include "includes.h"
26 
27 #if defined( __linux__ )
28 
29 #define ICMP_ECHOREPLY 0
30 #define ICMP_ECHO 8
31 #define ICMP_MINLEN 8
32 
33 struct ip {
34 #if (BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN)
35  u_char ip_hl:4, /* header length */
36  ip_v:4; /* version */
37 #else
38  u_char ip_v:4, /* version */
39  ip_hl:4; /* header length */
40 #endif
41  u_char ip_tos; /* type of service */
42  short ip_len; /* total length */
43  u_short ip_id; /* identification */
44  short ip_off; /* fragment offset field */
45 #define IP_DF 0x4000 /* dont fragment flag */
46 #define IP_MF 0x2000 /* more fragments flag */
47  u_char ip_ttl; /* time to live */
48  u_char ip_p; /* protocol */
49  u_short ip_sum; /* checksum */
50  struct in_addr ip_src,ip_dst; /* source and dest address */
51 };
52 
53 #define n_short u_short /* normally defined in in_systm.h */
54 #define n_long u_int /* redefine for 64-bit machines */
55 #define n_time u_int /* redefine for 64-bit machines */
56 
57 struct icmp {
58  u_char icmp_type; /* type of message, see below */
59  u_char icmp_code; /* type sub code */
60  u_short icmp_cksum; /* ones complement cksum of struct */
61  union {
62  u_char ih_pptr; /* ICMP_PARAMPROB */
63  struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
64  struct ih_idseq {
65  n_short icd_id;
66  n_short icd_seq;
67  } ih_idseq;
68  int ih_void;
69  } icmp_hun;
70 #define icmp_pptr icmp_hun.ih_pptr
71 #define icmp_gwaddr icmp_hun.ih_gwaddr
72 #define icmp_id icmp_hun.ih_idseq.icd_id
73 #define icmp_seq icmp_hun.ih_idseq.icd_seq
74 #define icmp_void icmp_hun.ih_void
75  union {
76  struct id_ts {
77  n_time its_otime;
78  n_time its_rtime;
79  n_time its_ttime;
80  } id_ts;
81  struct id_ip {
82  struct ip idi_ip;
83  /* options and then 64 bits of data */
84  } id_ip;
85  n_long id_mask;
86  char id_data[1];
87  } icmp_dun;
88 #define icmp_otime icmp_dun.id_ts.its_otime
89 #define icmp_rtime icmp_dun.id_ts.its_rtime
90 #define icmp_ttime icmp_dun.id_ts.its_ttime
91 #define icmp_ip icmp_dun.id_ip.idi_ip
92 #define icmp_mask icmp_dun.id_mask
93 #define icmp_data icmp_dun.id_data
94 };
95 
96 #else
97 # include <netinet/ip.h>
98 # include <netinet/ip_icmp.h>
99 #endif /* defined(__linux__) */
100 
101 #define IDENT_DEFAULT 0
102 #define TIMO_DEFAULT 2
103 
104 struct ping_priv {
105  int ident;
106  int timo;
107  int rrt;
108  int sock;
109 };
110 
111 struct ping_priv ping_priv_default (void);
112 
113 int pinghost ( const char *hostname );
114 int pingthost ( const char *hostname, int t );
115 int tpinghost ( const char *hostname );
116 int tpingthost( const char *hostname, int t );
117 
118 #endif/*PING_H*/
int pingthost(const char *hostname, int t)
Definition: libping.c:349
int tpingthost(const char *hostname, int t)
Definition: libping.c:368
int pinghost(const char *hostname)
Definition: libping.c:342
int timo
Definition: libping.h:106
struct ping_priv ping_priv_default(void)
Definition: libping.c:44
int sock
Definition: libping.h:108
Definition: libping.h:104
int ident
Definition: libping.h:105
int tpinghost(const char *hostname)
Definition: libping.c:356
int rrt
Definition: libping.h:107