File: packetracker.h

package info (click to toggle)
kismet 2008-05-R1-4.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,236 kB
  • ctags: 3,998
  • sloc: cpp: 33,568; sh: 5,544; ansic: 459; makefile: 457; perl: 62; sql: 41
file content (169 lines) | stat: -rw-r--r-- 5,109 bytes parent folder | download | duplicates (2)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
    This file is part of Kismet

    Kismet is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Kismet 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 Kismet; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef __PACKETRACKER_H__
#define __PACKETRACKER_H__

#include "config.h"

#include <stdio.h>
#include <time.h>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <string>

#include "util.h"
#include "gpsd.h"
#include "packet.h"
#include "tracktypes.h"
#include "manuf.h"
#include "alertracker.h"
#include "finitestate.h"

class Packetracker {
public:
    Packetracker();
    ~Packetracker();

    // Do regular maintenance
    int Tick();

    // Get the error
    char *FetchError() { return errstr; }

    // Set up the alert handler
    void AddAlertracker(Alertracker *in_tracker);
    // Pass in enabled alerts from the config file
    int EnableAlert(string in_alname, alert_time_unit in_unit,
                    int in_rate, alert_time_unit in_bunit, int in_burstrate);

    // Set up filters
    void AddExportFilters(macmap<int> *bssid_map, macmap<int> *source_map,
                          macmap<int> *dest_map, int *bssid_invert,
                          int *source_invert, int *dest_invert);

    // Set up filtering - removed.  we do this in the server now before processing
    // anything else.
    //    void AddFilter(string in_filter) { filter = in_filter; }

    // Packet tracker stuff -- kluged up to handle processing wep after the
	// network classifier
    void ProcessPacket(kis_packet *packet, packet_info *info,
					   macmap<wep_key_info *> *bssid_wep_map,
					   unsigned char *identity);
    void ProcessDataPacket(kis_packet *packet, packet_info *info, 
						   wireless_network *net,
						   macmap<wep_key_info *> *bssid_wep_map,
						   unsigned char *identity);

    void UpdateIpdata(wireless_network *net);

    // Get all the networks
    vector<wireless_network *> FetchNetworks();

    wireless_network *MatchNetwork(const packet_info *in_packet);

    int ExpireNetworks(int expiry);
    int WriteNetworks(string in_fname);
    int WriteCSVNetworks(string in_fname);
    int WriteXMLNetworks(string in_fname);
    int WriteCisco(string in_fname);

    int WriteGpsdriveWaypt(FILE *in_file);

    void WriteSSIDMap(FILE *in_file);
    void ReadSSIDMap(FILE *in_file);

    void WriteIPMap(FILE *in_file);
    void ReadIPMap(FILE *in_file);

    // Tell the tracker to load maps of the manufacturer info
    void ReadAPManufMap(FILE *in_file);
    void ReadClientManufMap(FILE *in_file);

    // Convert the MAC
    static string Mac2String(uint8_t *mac, char seperator);
    // Utility to find strings that are empty or contain all spaces
    static bool IsBlank(const char *s);

    int FetchNumNetworks() { return num_networks; }
    //int FetchNumNetworks() { return bssid_map.size(); }
    int FetchNumPackets() { return num_packets; }
    int FetchNumDropped() { return num_dropped; }
    int FetchNumNoise() { return num_noise; }
    int FetchNumCrypt() { return num_crypt; }
    int FetchNumInteresting() { return num_interesting; }
    int FetchNumCisco() { return num_cisco; }

    void RemoveNetwork(mac_addr in_bssid);

protected:
    wireless_client *CreateClient(const packet_info *info, wireless_network *net,
								  int destclient);
    string SanitizeCSV(string in_data);
    string SanitizeXML(string in_data);

    char errstr[1024];

    Alertracker *alertracker;

    int num_networks, num_packets, num_dropped, num_noise,
        num_crypt, num_interesting, num_cisco;

    int best_signal, worst_signal;

    // all the networks
    vector<wireless_network *> network_list;

    // Several maps to refer to networks
    map<mac_addr, wireless_network *> bssid_map;

    // Map BSSID's to SSID for storage and cloaking
    map<mac_addr, string> bssid_cloak_map;

    // Map BSSID's to IP ranges for storage
    map<mac_addr, net_ip_data> bssid_ip_map;

    // Map probe responses for clients so we know we need to merge
    map<mac_addr, mac_addr> probe_map;

    // Manufacturer maps
    macmap<vector<manuf *> > ap_manuf_map;
    macmap<vector<manuf *> > client_manuf_map;

    // Finite state trackers
    vector<FiniteAutomata *> fsa_vec;

    // Filters
    macmap<int> *filter_export_bssid;
    int *filter_export_bssid_invert;
    macmap<int> *filter_export_source;
    int *filter_export_source_invert;
    macmap<int> *filter_export_dest;
    int *filter_export_dest_invert;
    int filter_export;

    // Alert references
    int *arefs;

};

#endif