summaryrefslogtreecommitdiff
path: root/other/3wahas/sniff.h
blob: af8fc7778474dcb9e81faa61460a1b71f9a42321 (plain)
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
/* snifflib
 *
 * by scut
 *
 */

#ifndef	Z_SNIFF_H
#define	Z_SNIFF_H

#include <pcap.h>
#include "packet.h"

#define	SNAPLEN		65535
#define	PROMISC		1
#define	READ_TIMEOUT	0

typedef struct	s_dev {
	int			error;		/* error flag */

	pcap_t			*pd;		/* packet capture descriptor */
	char			*interface;	/* interface name */
	int			linktype;	/* link layer type */
	unsigned long int	linkhdrlen;	/* length of the link layer frame header */
	bpf_u_int32		localnet;	/* local network address */
	bpf_u_int32		netmask;	/* netmask of local network */

} s_dev;

typedef struct	sniff_info {
	s_dev		*device;		/* device structure of the sniffing device */
	struct in_addr	ip_dst;
} sniff_info;

void		sniff_new (char *interface, char *ip_dst);
void		*sniff_handle (sniff_info *sinfo);
s_dev		*sniff_open (char *devname);
pcap_t		*sniff_pcap_open (char *device);
void		sniff_dev_free (s_dev *device);

#endif