1 #ifndef ETTERCAP_GLOBALS_H
2 #define ETTERCAP_GLOBALS_H
3 
4 #include <ec_sniff.h>
5 #include <ec_inet.h>
6 #include <ec_network.h>
7 #include <ec_ui.h>
8 #include <ec_set.h>
9 #include <ec_stats.h>
10 #include <ec_profiles.h>
11 #include <ec_filter.h>
12 #include <ec_interfaces.h>
13 #include <config.h>
14 #include <ec_encryption.h>
15 #include <ec_utils.h>
16 #include <pcap.h>
17 #include <libnet.h>
18 #include <regex.h>
19 
20 /* options form etter.conf */
21 struct ec_conf {
22    char *file;
23    int ec_uid;
24    int ec_gid;
25    int arp_storm_delay;
26    int arp_poison_smart;
27    int arp_poison_warm_up;
28    int arp_poison_delay;
29    int arp_poison_icmp;
30    int arp_poison_reply;
31    int arp_poison_request;
32    int arp_poison_equal_mac;
33    int dhcp_lease_time;
34    int port_steal_delay;
35    int port_steal_send_delay;
36 #ifdef WITH_IPV6
37    int ndp_poison_warm_up;
38    int ndp_poison_delay;
39    int ndp_poison_send_delay;
40    int ndp_poison_icmp;
41    int ndp_poison_equal_mac;
42    int icmp6_probe_delay;
43 #endif
44    int connection_timeout;
45    int connection_idle;
46    int connection_buffer;
47    int connect_timeout;
48    int sampling_rate;
49    int close_on_eof;
50    int aggressive_dissectors;
51    int skip_forwarded;
52    int checksum_check;
53    int submit_fingerprint;
54    int checksum_warning;
55    int sniffing_at_startup;
56    int geoip_support_enable;
57    int gtkui_prefer_dark_theme;
58    int store_profiles;
59    struct curses_color colors;
60    char *redir_command_on;
61    char *redir_command_off;
62 #ifdef WITH_IPV6
63    char *redir6_command_on;
64    char *redir6_command_off;
65 #endif
66    char *remote_browser;
67    char *utf8_encoding;
68    char *geoip_data_file;
69    char *geoip_data_file_v6;
70 };
71 
72 /* options from getopt */
73 struct ec_options {
74    char write:1;
75    char read:1;
76    char compress:1;
77    char quiet:1;
78    char superquiet:1;
79    char silent:1;
80    char ip6scan:1;
81    char unoffensive:1;
82    char ssl_mitm:1;
83    char load_hosts:1;
84    char save_hosts:1;
85    char resolve:1;
86    char ext_headers:1;
87    char mitm:1;
88    char only_mitm:1;
89    char remote:1;
90    char gateway:1;
91    char lifaces:1;
92    char broadcast:1;
93    char reversed;
94    char *hostsfile;
95    LIST_HEAD(plugin_list_t, plugin_list) plugins;
96    char *proto;
97    char *netmask;
98    char *address;
99    char *iface;
100    char *iface_bridge;
101    char **secondary;
102    char *pcapfile_in;
103    char *pcapfile_out;
104    char *target1;
105    char *target2;
106    char *script;
107    char *ssl_cert;
108    char *ssl_pkey;
109    FILE *msg_fd;
110    int (*format)(const u_char *, size_t, u_char *);
111    regex_t *regex;
112 };
113 
114 /* program name and version */
115 struct program_env {
116    char *name;
117    char *version;
118    char *debug_file;
119 };
120 
121 /* global pcap structure */
122 struct pcap_env {
123    pcap_if_t     *ifs;
124    u_int8         align;         /* alignment needed on sparc 4*n - sizeof(media_hdr) */
125    char           promisc;
126    char          *filter;        /* pcap filter */
127    int            snaplen;
128    int            dlt;
129    pcap_dumper_t *dump;
130    u_int32        dump_size;     /* total dump size */
131    u_int32        dump_off;      /* current offset */
132 };
133 
134 /* lnet structure */
135 struct lnet_env {
136    libnet_t *lnet_IP4;
137    libnet_t *lnet_IP6;
138 };
139 
140 /* ip list per target */
141 struct ip_list {
142    struct ip_addr ip;
143    LIST_ENTRY(ip_list) next;
144 };
145 
146 /* scanned hosts list */
147 struct hosts_list {
148    struct ip_addr ip;
149    u_int8 mac[MEDIA_ADDR_LEN];
150    char *hostname;
151    LIST_ENTRY(hosts_list) next;
152 };
153 
154 /* target specifications */
155 struct target_env {
156    char scan_all:1;
157    char all_mac:1;            /* these one bit flags are used as wildcards */
158    char all_ip:1;
159    char all_ip6:1;
160    char all_port:1;
161    char *proto;
162    u_char mac[MEDIA_ADDR_LEN];
163    LIST_HEAD(, ip_list) ips;
164    LIST_HEAD(, ip_list) ip6;
165    u_int8 ports[1<<13];       /* in 8192 byte we have 65535 bits, use one bit per port */
166 };
167 
168 /* wifi network structure */
169 struct wifi_env {
170 	char wireless;               /* if the send interface is wireless */
171 	u_char wifi_schema;
172       #define WIFI_WEP 0x01
173       #define WIFI_WPA 0x02
174 	char *wifi_key;              /* user specified wifi_key */
175 	u_char wkey[MAX_WKEY_LEN];   /* encoded wifi key, large enough for all encryption schemas */
176 	size_t wkey_len;
177 };
178 
179 /* the globals container */
180 struct ec_globals {
181    struct ec_conf *conf;
182    struct ec_options *options;
183    struct gbl_stats *stats;
184    struct ui_ops *ui;
185    struct program_env *env;
186    struct pcap_env *pcap;
187    struct lnet_env *lnet;
188    struct iface_env *iface;
189    struct iface_env *bridge;
190    struct sniffing_method *sm;
191    struct target_env *t1;
192    struct target_env *t2;
193    struct wifi_env *wifi;
194    LIST_HEAD(, hosts_list) hosts_list;
195    TAILQ_HEAD(gbl_ptail, host_profile) profiles_list_head;
196    struct filter_list *filters;
197 };
198 
199 EC_API_EXTERN struct ec_globals *ec_gbls;
200 
201 #define EC_GBLS ec_gbls
202 
203 #define EC_GBL_CONF           (EC_GBLS->conf)
204 #define EC_GBL_OPTIONS        (EC_GBLS->options)
205 #define EC_GBL_STATS          (EC_GBLS->stats)
206 #define EC_GBL_UI             (EC_GBLS->ui)
207 #define EC_GBL_ENV            (EC_GBLS->env)
208 #define EC_GBL_PCAP           (EC_GBLS->pcap)
209 #define EC_GBL_LNET           (EC_GBLS->lnet)
210 #define EC_GBL_IFACE          (EC_GBLS->iface)
211 #define EC_GBL_BRIDGE         (EC_GBLS->bridge)
212 #define EC_GBL_SNIFF          (EC_GBLS->sm)
213 #define EC_GBL_TARGET1        (EC_GBLS->t1)
214 #define EC_GBL_TARGET2        (EC_GBLS->t2)
215 #define EC_GBL_WIFI           (EC_GBLS->wifi)
216 #define EC_GBL_HOSTLIST       (EC_GBLS->hosts_list)
217 #define EC_GBL_PROFILES       (EC_GBLS->profiles_list_head)
218 #define EC_GBL_FILTERS        &(EC_GBLS->filters)
219 
220 #define EC_GBL_FORMAT         (EC_GBL_OPTIONS->format)
221 
222 #define EC_GBL_PROGRAM        (EC_GBL_ENV->name)
223 #define EC_GBL_VERSION        (EC_GBL_ENV->version)
224 #define EC_GBL_DEBUG_FILE     (EC_GBL_ENV->debug_file)
225 
226 /* exported functions */
227 
228 EC_API_EXTERN void ec_globals_alloc(void);
229 EC_API_EXTERN void ec_globals_free(void);
230 
231 #endif
232 
233 /* EOF */
234 
235 // vim:ts=3:expandtab
236 
237