forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sniff.h
82 lines (69 loc) · 2.04 KB
/
sniff.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
71
72
73
74
75
76
77
78
79
80
81
/* Martin Vit [email protected]
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2.
*/
#include <queue>
#include "voipmonitor.h"
#ifdef QUEUE_NONBLOCK
extern "C" {
#include "liblfds.6/inc/liblfds.h"
}
#endif
void *rtp_read_thread_func(void *arg);
void *pcap_read_thread_func(void *arg);
void process_packet(unsigned int saddr, int source, unsigned int daddr, int dest, char *data, int datalen,
pcap_t *handle, pcap_pkthdr *header, const u_char *packet, int can_thread, int *was_rtp);
void readdump_libnids(pcap_t *handle);
void readdump_libpcap(pcap_t *handle);
typedef std::map<in_addr_t, in_addr_t> nat_aliases_t; //!<
/* this is copied from libpcap sll.h header file, which is not included in debian distribution */
#define SLL_ADDRLEN 8 /* length of address field */
struct sll_header {
u_int16_t sll_pkttype; /* packet type */
u_int16_t sll_hatype; /* link-layer address type */
u_int16_t sll_halen; /* link-layer address length */
u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
u_int16_t sll_protocol; /* protocol */
};
struct udphdr {
uint16_t source;
uint16_t dest;
uint16_t len;
uint16_t check;
};
typedef struct {
Call *call;
unsigned char *data;
int datalen;
u_int32_t saddr;
unsigned short port;
int iscaller;
struct pcap_pkthdr header;
} rtp_packet;
typedef struct {
pthread_t thread; // ID of worker storing CDR thread
#ifdef QUEUE_MUTEX
queue<rtp_packet*> pqueue;
pthread_mutex_t qlock;
sem_t semaphore;
#endif
#ifdef QUEUE_NONBLOCK
struct queue_state *pqueue;
#endif
} read_thread;
#if defined(QUEUE_MUTEX) || defined(QUEUE_NONBLOCK)
typedef struct {
struct pcap_pkthdr header;
u_char *packet;
int offset;
} pcap_packet;
#endif
#define MAXPACKETLENQRING 1600
#if defined(QUEUE_NONBLOCK2)
typedef struct {
struct pcap_pkthdr header;
u_char packet[MAXPACKETLENQRING];
int offset;
char free;
} pcap_packet;
#endif