1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
/*
* Includes, defines and global variables used between functions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
extern int errno;
#include <time.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
/* On Linux you might also need to symlink /usr/include/netinet/in_system.h
to /usr/src/linux/include/linux/in_system.h */
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
/* maybe change this when linux will include a complete include tree : */
#ifdef linux
#include "linux_ip_icmp.h"
#else
#include <netinet/ip_icmp.h>
#endif
#include <netinet/tcp.h>
#include <netdb.h>
#include <syslog.h>
#include <unistd.h>
/*
* Beware that the outgoing packet starts with the ICMP header and
* does not include the IP header (the kernel prepends that for us).
* But, the received packet includes the IP header.
*/
#define MAXPACKET 4096 /* max packet size */
#ifndef DCLARE
#define DCLARE extern
#endif
DCLARE int verbose; /* enables additional error messages */
DCLARE u_char recvpack[MAXPACKET]; /* the received packet */
DCLARE int sockfd; /* socket file descriptor */
char *inet_ntoa(); /* BSD library routine */
DCLARE int nonamequery; /* flag for query/noquery of ip -> name */
DCLARE int showsrcip; /* flag for showing or not src ip */
DCLARE int syslogdoutput; /* flag for stdoutput / syslogd output */
DCLARE int noportquery; /* flag for query/noquery of port -> serv name */
int err_ret(char *);
int pr_pack(char *, int, struct sockaddr_in *);
void pid_file(void);
void pid_kill(void);
int err_quit(char *);
int err_sys(char *);
void recv_ping(void);
/* on some hosts (linux) netinet/ip_icmp.h is missing/empty : */
#ifndef ICMP_MINLEN
int bug=You_need_an_non_empty_netinet_ip_icmp_h;
#endif
|