Main Page   Namespace List   Alphabetical List   Compound List   File List   Compound Members   File Members  

ifpair.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                                  ifpair.h
00003                              -------------------
00004     begin                : Fri Feb 1 2002
00005     copyright            : (C) 2002 by Constantinos A. Kotsokalis
00006     email                : ckotso@grnet.gr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef IFPAIR_H
00019 #define IFPAIR_H
00020 
00026 class IfPair;
00027 
00028 #include "common.h"
00029 
00030 #include <map>
00031 
00032 // Represents an IP addres to which at least one flow headed
00033 class NetNode {
00034 public:
00035     NetNode() { flows = packets = octets = 0; }
00036     virtual ~NetNode() {;}
00037     virtual const uint32_t& getflows() { return flows; }
00038     virtual const uint32_t& getpackets() { return packets; }
00039     virtual const uint32_t& getoctets() { return octets; }
00040 
00041 private:
00042     uint32_t flows, packets, octets;
00043     
00044 friend class IfPair;
00045 };
00046 
00047 // The next line represents a tree with all the addresses to which
00048 // traffic headed
00049 typedef map<uint8_t, NetNode> level4;
00050 typedef map<uint8_t, level4> level3;
00051 typedef map<uint8_t, level3> level2;
00052 typedef map<uint8_t, level2> IPTree;
00053 
00054 class IfPair {
00055 public:
00056     IfPair(uint16_t&, uint16_t&);
00057     virtual ~IfPair();
00058     
00059     virtual const uint16_t& getinput();     
00060     virtual void setinput( const uint16_t& _newVal);
00061     virtual const uint16_t& getoutput();
00062     virtual void setoutput( const uint16_t& _newVal);
00063     
00064     virtual const uint32_t& getflows();
00065     virtual const uint32_t& getpackets();
00066     virtual const uint32_t& getoctets();
00067 
00068     virtual uint32_t& getflows(InetHostAddress&);
00069     virtual uint32_t& getpackets(InetHostAddress&);
00070         
00071     virtual void setflows(uint32_t fl) { flows = fl; }
00072     virtual void setpackets(uint32_t pk) { packets = pk; }
00073     virtual void setoctets(uint32_t oct) { octets = oct; }
00074 
00075     virtual void setFromIP(const char *s){ InputIP = InetHostAddress(s); }
00076     virtual void setOutIP(const char *s){ OutputIP = InetHostAddress(s); }
00077     virtual InetHostAddress& getFromIP() { return InputIP; }
00078     virtual InetHostAddress& getOutIP() { return OutputIP; }
00079     
00080     virtual void Add(const uint32_t&, const uint32_t&, const uint32_t&);
00081 
00082     virtual bool MarkedDos() {return marked_dos;}
00083     // Set potential DoS attack
00084     virtual void MarkedDos(bool b) {marked_dos = b;}
00085     // Return whether an attack is going on for this pair
00086     virtual bool IsDos() {return is_dos;}
00087     // Set the flag to indicate an attack is going on
00088     virtual void IsDos(bool b) {is_dos = b;}
00089     
00090     virtual InetHostAddress getTopTalker(int);
00091     virtual InetHostAddress fl_getTopTalker();
00092     virtual InetHostAddress pk_getTopTalker();
00093 
00094 private: // Private attributes
00095     IPTree iptree;
00096     uint16_t input, output;
00097     uint32_t flows, packets, octets;
00098     bool marked_dos, is_dos;
00099     InetHostAddress InputIP, OutputIP;
00100 };
00101 
00102 #endif

Generated on Thu Jun 26 00:23:12 2003 for Panoptis by doxygen1.2.18