nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * Copyright (c) 2007, 2008, Andrea Bittau <a.bittau@cs.ucl.ac.uk> |
||
3 | * All OS dependent crap should go here. |
||
4 | * |
||
5 | * This program is free software; you can redistribute it and/or |
||
6 | * modify it under the terms of the GNU General Public License as |
||
7 | * published by the Free Software Foundation; either version 2 of the |
||
8 | * License, or (at your option) any later version. |
||
9 | * |
||
10 | * This program is distributed in the hope that it will be useful, but |
||
11 | * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied |
||
12 | * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and |
||
13 | * NON-INFRINGEMENT. See the GNU General Public License for more details. |
||
14 | * |
||
15 | * You should have received a copy of the GNU General Public License |
||
16 | * along with this program; if not, write to the Free Software |
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
||
18 | * MA 02111-1307, USA. |
||
19 | * |
||
20 | * In addition, as a special exception, the copyright holders give |
||
21 | * permission to link the code of portions of this program with the |
||
22 | * OpenSSL library under certain conditions as described in each |
||
23 | * individual source file, and distribute linked combinations |
||
24 | * including the two. |
||
25 | * You must obey the GNU General Public License in all respects |
||
26 | * for all of the code used other than OpenSSL. If you modify |
||
27 | * file(s) with this exception, you may extend this exception to your |
||
28 | * version of the file(s), but you are not obligated to do so. If you |
||
29 | * do not wish to do so, delete this exception statement from your |
||
30 | * version. If you delete this exception statement from all source |
||
31 | * files in the program, then also delete it here. |
||
32 | */ |
||
33 | |||
34 | #ifndef __AIRCRACK_NG_OSEDEP_H__ |
||
35 | #define __AIRCRACK_NG_OSEDEP_H__ |
||
36 | |||
37 | #include <netinet/in.h> |
||
38 | #include <stdint.h> |
||
39 | |||
40 | #include "byteorder.h" |
||
41 | #include "packed.h" |
||
42 | |||
43 | #if defined(__APPLE_CC__) && defined(_XCODE) |
||
44 | #include <pcap/bpf.h> |
||
45 | #undef LINKTYPE_RADIOTAP_HDR |
||
46 | #define LINKTYPE_RADIOTAP_HDR DLT_IEEE802_11_RADIO |
||
47 | #undef LINKTYPE_IEEE802_11 |
||
48 | #define LINKTYPE_IEEE802_11 DLT_IEEE802_11 |
||
49 | #undef LINKTYPE_PRISM_HEADER |
||
50 | #define LINKTYPE_PRISM_HEADER DLT_PRISM_HEADER |
||
51 | #undef LINKTYPE_ETHERNET |
||
52 | #define LINKTYPE_ETHERNET DLT_ERF_ETH |
||
53 | #undef LINKTYPE_PPI_HDR |
||
54 | #define LINKTYPE_PPI_HDR DLT_PPI |
||
55 | #undef TCPDUMP_MAGIC |
||
56 | #define TCPDUMP_MAGIC 0xa1b2c3d4 |
||
57 | #endif |
||
58 | |||
59 | /* For all structures, when adding new fields, always append them to the end. |
||
60 | * This way legacy binary code does not need to be recompiled. This is |
||
61 | * particularly useful for DLLs. -sorbo |
||
62 | */ |
||
63 | |||
64 | struct tx_info { |
||
65 | unsigned int ti_rate; |
||
66 | }; |
||
67 | |||
68 | struct rx_info { |
||
69 | uint64_t ri_mactime; |
||
70 | int32_t ri_power; |
||
71 | int32_t ri_noise; |
||
72 | uint32_t ri_channel; |
||
73 | uint32_t ri_freq; |
||
74 | uint32_t ri_rate; |
||
75 | uint32_t ri_antenna; |
||
76 | } __packed; |
||
77 | |||
78 | /* Normal code should not access this directly. Only osdep. |
||
79 | * This structure represents a single interface. It should be created with |
||
80 | * wi_open and destroyed with wi_close. |
||
81 | */ |
||
82 | #define MAX_IFACE_NAME 64 |
||
83 | struct wif { |
||
84 | int (*wi_read)(struct wif *wi, unsigned char *h80211, int len, |
||
85 | struct rx_info *ri); |
||
86 | int (*wi_write)(struct wif *wi, unsigned char *h80211, int len, |
||
87 | struct tx_info *ti); |
||
88 | int (*wi_set_channel)(struct wif *wi, int chan); |
||
89 | int (*wi_get_channel)(struct wif *wi); |
||
90 | int (*wi_set_freq)(struct wif *wi, int freq); |
||
91 | int (*wi_get_freq)(struct wif *wi); |
||
92 | void (*wi_close)(struct wif *wi); |
||
93 | int (*wi_fd)(struct wif *wi); |
||
94 | int (*wi_get_mac)(struct wif *wi, unsigned char *mac); |
||
95 | int (*wi_set_mac)(struct wif *wi, unsigned char *mac); |
||
96 | int (*wi_set_rate)(struct wif *wi, int rate); |
||
97 | int (*wi_get_rate)(struct wif *wi); |
||
98 | int (*wi_set_mtu)(struct wif *wi, int mtu); |
||
99 | int (*wi_get_mtu)(struct wif *wi); |
||
100 | int (*wi_get_monitor)(struct wif *wi); |
||
101 | |||
102 | void *wi_priv; |
||
103 | char wi_interface[MAX_IFACE_NAME]; |
||
104 | }; |
||
105 | |||
106 | /* Routines to be used by client code */ |
||
107 | extern struct wif *wi_open(char *iface); |
||
108 | extern int wi_read(struct wif *wi, unsigned char *h80211, int len, |
||
109 | struct rx_info *ri); |
||
110 | extern int wi_write(struct wif *wi, unsigned char *h80211, int len, |
||
111 | struct tx_info *ti); |
||
112 | extern int wi_set_channel(struct wif *wi, int chan); |
||
113 | extern int wi_get_channel(struct wif *wi); |
||
114 | extern int wi_set_freq(struct wif *wi, int freq); |
||
115 | extern int wi_get_freq(struct wif *wi); |
||
116 | extern void wi_close(struct wif *wi); |
||
117 | extern char *wi_get_ifname(struct wif *wi); |
||
118 | extern int wi_get_mac(struct wif *wi, unsigned char *mac); |
||
119 | extern int wi_set_mac(struct wif *wi, unsigned char *mac); |
||
120 | extern int wi_get_rate(struct wif *wi); |
||
121 | extern int wi_set_rate(struct wif *wi, int rate); |
||
122 | extern int wi_get_monitor(struct wif *wi); |
||
123 | extern int wi_get_mtu(struct wif *wi); |
||
124 | extern int wi_set_mtu(struct wif *wi, int mtu); |
||
125 | |||
126 | /* wi_open_osdep should determine the type of card and setup the wif structure |
||
127 | * appropriately. There is one per OS. Called by wi_open. |
||
128 | */ |
||
129 | extern struct wif *wi_open_osdep(char *iface); |
||
130 | |||
131 | /* This will return the FD used for reading. This is required for using select |
||
132 | * on it. |
||
133 | */ |
||
134 | extern int wi_fd(struct wif *wi); |
||
135 | |||
136 | /* Helper routines for osdep code. */ |
||
137 | extern struct wif *wi_alloc(int sz); |
||
138 | extern void *wi_priv(struct wif *wi); |
||
139 | |||
140 | /* Client code can use this to determine the battery state. One per OS. */ |
||
141 | extern int get_battery_state(void); |
||
142 | |||
143 | /* Client code can create a tap interface */ |
||
144 | /* XXX we can unify the tap & wi stuff in the future, but for now, lets keep |
||
145 | * them seperate until we learn something. |
||
146 | */ |
||
147 | struct tif { |
||
148 | int (*ti_read)(struct tif *ti, void *buf, int len); |
||
149 | int (*ti_write)(struct tif *ti, void *buf, int len); |
||
150 | int (*ti_fd)(struct tif *ti); |
||
151 | char *(*ti_name)(struct tif *ti); |
||
152 | int (*ti_set_mtu)(struct tif *ti, int mtu); |
||
153 | int (*ti_get_mtu)(struct tif *ti); |
||
154 | int (*ti_set_ip)(struct tif *ti, struct in_addr *ip); |
||
155 | int (*ti_set_mac)(struct tif *ti, unsigned char *mac); |
||
156 | void (*ti_close)(struct tif *ti); |
||
157 | |||
158 | void *ti_priv; |
||
159 | }; |
||
160 | /* one per OS */ |
||
161 | extern struct tif *ti_open(char *iface); |
||
162 | |||
163 | /* osdep routines */ |
||
164 | extern struct tif *ti_alloc(int sz); |
||
165 | extern void *ti_priv(struct tif *ti); |
||
166 | |||
167 | /* client routines */ |
||
168 | extern char *ti_name(struct tif *ti); |
||
169 | extern int ti_set_mtu(struct tif *ti, int mtu); |
||
170 | extern int ti_get_mtu(struct tif *ti); |
||
171 | extern void ti_close(struct tif *ti); |
||
172 | extern int ti_fd(struct tif *ti); |
||
173 | extern int ti_read(struct tif *ti, void *buf, int len); |
||
174 | extern int ti_write(struct tif *ti, void *buf, int len); |
||
175 | extern int ti_set_mac(struct tif *ti, unsigned char *mac); |
||
176 | extern int ti_set_ip(struct tif *ti, struct in_addr *ip); |
||
177 | |||
178 | #endif /* __AIRCRACK_NG_OSEDEP_H__ */ |