-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcpdump.h
125 lines (106 loc) · 3.09 KB
/
tcpdump.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Andreas Langer <an.langer@gmx.de>, Marek Lindner <lindner_marek@yahoo.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include <netpacket/packet.h>
#include <net/ethernet.h>
#include <netinet/if_ether.h>
#include "list-batman.h"
#ifndef ARPHRD_IEEE80211_PRISM
#define ARPHRD_IEEE80211_PRISM 802
#endif
#ifndef ARPHRD_IEEE80211_RADIOTAP
#define ARPHRD_IEEE80211_RADIOTAP 803
#endif
#define DUMP_TYPE_BATOGM 1
#define DUMP_TYPE_BATICMP 2
#define DUMP_TYPE_BATUCAST 4
#define DUMP_TYPE_BATBCAST 8
#define DUMP_TYPE_BATVIS 16
#define DUMP_TYPE_BATFRAG 32
#define DUMP_TYPE_BATTT 64
#define DUMP_TYPE_NONBAT 128
#define IEEE80211_FCTL_FTYPE 0x0c00
#define IEEE80211_FCTL_TODS 0x0001
#define IEEE80211_FCTL_FROMDS 0x0002
#define IEEE80211_FCTL_PROTECTED 0x0040
#define IEEE80211_FTYPE_DATA 0x0800
#define IEEE80211_STYPE_QOS_DATA 0x8000
struct dump_if {
struct list_head list;
char *dev;
int32_t raw_sock;
struct sockaddr_ll addr;
int32_t hw_type;
};
struct vlanhdr {
unsigned short vid;
u_int16_t ether_type;
} __attribute__ ((packed));
struct ieee80211_hdr {
u_int16_t frame_control;
u_int16_t duration_id;
u_int8_t addr1[ETH_ALEN];
u_int8_t addr2[ETH_ALEN];
u_int8_t addr3[ETH_ALEN];
u_int16_t seq_ctrl;
u_int8_t addr4[ETH_ALEN];
} __attribute__ ((packed));
struct radiotap_header {
u_int8_t it_version;
u_int8_t it_pad;
u_int16_t it_len;
u_int32_t it_present;
} __attribute__((__packed__));
struct prism_item {
u_int32_t did;
u_int16_t status;
u_int16_t len;
u_int32_t data;
};
struct prism_header {
u_int32_t msgcode;
u_int32_t msglen;
u_int8_t devname[16];
struct prism_item hosttime;
struct prism_item mactime;
struct prism_item channel;
struct prism_item rssi;
struct prism_item sq;
struct prism_item signal;
struct prism_item noise;
struct prism_item rate;
struct prism_item istx;
struct prism_item frmlen;
};
struct ether_arp {
struct arphdr ea_hdr; /* fixed-size header */
u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */
u_int8_t arp_spa[4]; /* sender protocol address */
u_int8_t arp_tha[ETHER_ADDR_LEN]; /* target hardware address */
u_int8_t arp_tpa[4]; /* target protocol address */
} __packed;
#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
#define arp_hln ea_hdr.ar_hln
#define arp_pln ea_hdr.ar_pln
#define arp_op ea_hdr.ar_op
#define PRISM_HEADER_LEN sizeof(struct prism_header)
#define RADIOTAP_HEADER_LEN sizeof(struct radiotap_header)
int tcpdump(int argc, char **argv);