Branch data Line data Source code
1 : : // $Id: Frag.h 6219 2008-10-01 05:39:07Z vern $
2 : : //
3 : : // See the file "COPYING" in the main distribution directory for copyright.
4 : :
5 : : #ifndef frag_h
6 : : #define frag_h
7 : :
8 : : #include "util.h"
9 : : #include "IP.h"
10 : : #include "Net.h"
11 : : #include "Reassem.h"
12 : : #include "Timer.h"
13 : :
14 : : class HashKey;
15 : : class NetSessions;
16 : :
17 : : class FragReassembler;
18 : : class FragTimer;
19 : :
20 : : typedef void (FragReassembler::*frag_timer_func)(double t);
21 : :
22 : : class FragReassembler : public Reassembler {
23 : : public:
24 : : FragReassembler(NetSessions* s, const IP_Hdr* ip, const u_char* pkt,
25 : : uint32 frag_field, HashKey* k, double t);
26 : : ~FragReassembler();
27 : :
28 : : void AddFragment(double t, const IP_Hdr* ip, const u_char* pkt,
29 : : uint32 frag_field);
30 : :
31 : : void Expire(double t);
32 : : void DeleteTimer();
33 : 0 : void ClearTimer() { expire_timer = 0; }
34 : :
35 : 0 : const IP_Hdr* ReassembledPkt() { return reassembled_pkt; }
36 : 0 : HashKey* Key() const { return key; }
37 : :
38 : : protected:
39 : : void BlockInserted(DataBlock* start_block);
40 : : void Overlap(const u_char* b1, const u_char* b2, int n);
41 : :
42 : : struct ip* proto_hdr;
43 : : IP_Hdr* reassembled_pkt;
44 : : int proto_hdr_len;
45 : : NetSessions* s;
46 : : int frag_size; // size of fully reassembled fragment
47 : : HashKey* key;
48 : :
49 : : FragTimer* expire_timer;
50 : : };
51 : :
52 : : class FragTimer : public Timer {
53 : : public:
54 : 0 : FragTimer(FragReassembler* arg_f, double arg_t)
55 : 0 : : Timer(arg_t, TIMER_FRAG)
56 : 0 : { f = arg_f; }
57 : : ~FragTimer();
58 : :
59 : : void Dispatch(double t, int is_expire);
60 : :
61 : : // Break the association between this timer and its creator.
62 : 0 : void ClearReassembler() { f = 0; }
63 : :
64 : : protected:
65 : : FragReassembler* f;
66 : : };
67 : :
68 : : #endif
|