forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mirrorip.h
70 lines (58 loc) · 1.28 KB
/
mirrorip.h
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
67
68
69
70
#ifndef MIRRORIP_H
#define MIRRORIP_H
#include "voipmonitor.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/time.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifndef FREEBSD
#include <netinet/ether.h>
#endif
#include <sys/times.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <netinet/ip.h>
#include <syslog.h>
#include <errno.h>
#include <netinet/udp.h>
#include <netinet/ip_icmp.h>
#if 0
#include <features.h> /* for the glibc version number */
#if (__GLIBC__ >= 2 && __GLIBC_MINOR >= 1 ) || (defined( __FreeBSD__ ) || defined ( __NetBSD__ ))
#include <netpacket/packet.h>
#include <net/ethernet.h> /* the L2 protocols */
#else
#include <asm/types.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h> /* The L2 protocols */
#endif
#endif
using namespace std;
struct pseudohdr
{
u_int32_t saddr;
u_int32_t daddr;
u_int8_t zero;
u_int8_t proto;
u_int16_t len;
};
class MirrorIP {
public:
MirrorIP(const char*, const char*);
int send(char *, int);
private:
int sockraw;
char mirror_packet[4092];
struct sockaddr_in src_addr;
struct sockaddr_in dest_addr;
void socket_broadcast(int);
void socket_iphdrincl(int);
};
#endif