trafficselector.h

00001 /***************************************************************************
00002 *   Copyright (C) 2005 by                                                 *
00003 *   Pedro J. Fernandez Ruiz    pedroj.fernandez@dif.um.es                 *
00004 *   Alejandro Perez Mendez     alejandro_perez@dif.um.es                  *
00005 *                                                                         *
00006 *   This library is free software; you can redistribute it and/or         *
00007 *   modify it under the terms of the GNU Lesser General Public            *
00008 *   License as published by the Free Software Foundation; either          *
00009 *   version 2.1 of the License, or (at your option) any later version.    *
00010 *                                                                         *
00011 *   This library is distributed in the hope that it will be useful,       *
00012 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014 *   Lesser General Public License for more details.                       *
00015 *                                                                         *
00016 *   You should have received a copy of the GNU Lesser General Public      *
00017 *   License along with this library; if not, write to the Free Software   *
00018 *   Foundation, Inc., 51 Franklin St, Fifth Floor,                        *
00019 *   Boston, MA  02110-1301  USA                                           *
00020 ***************************************************************************/
00021 #ifndef TRAFFICSELECTOR_H
00022 #define TRAFFICSELECTOR_H
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include "config.h"
00026 #endif
00027 
00028 #include "printable.h"
00029 #include "ipaddress.h"
00030 #include "bytebuffer.h"
00031 
00032 namespace openikev2 {
00033 
00038     class TrafficSelector : public Printable {
00039 
00040             /****************************** ENUMS ******************************/
00041         public:
00043             enum TS_TYPE{
00044                 TS_IPV4_ADDR_RANGE = 7,           
00045                 TS_IPV6_ADDR_RANGE = 8,           
00046         };
00047 
00048             /****************************** ATTRIBUTES ******************************/
00049         public:
00050             TS_TYPE ts_type;                
00051             auto_ptr<ByteArray> start_addr;
00052             auto_ptr<ByteArray> end_addr;   
00053             uint16_t start_port;            
00054             uint16_t end_port;              
00055             uint8_t ip_protocol_id;         
00057             /****************************** METHODS ******************************/
00058         protected:
00059 
00065             static uint16_t getExpectedAddressSize( TS_TYPE ts_type);
00066             
00076             void construct(TS_TYPE ts_type, auto_ptr<ByteArray> start_addr, auto_ptr<ByteArray> end_addr, uint16_t start_port, uint16_t end_port, uint8_t ip_protocol_id );
00077 
00085             void construct( IpAddress& address, uint8_t prefixlen, uint16_t port , uint8_t ip_protocol_id );
00086 
00087         public:
00097             TrafficSelector(TS_TYPE ts_type, auto_ptr<ByteArray> start_addr, auto_ptr<ByteArray> end_addr, uint16_t start_port, uint16_t end_port, uint8_t ip_protocol_id );
00098 
00110             TrafficSelector(TS_TYPE ts_type, auto_ptr<ByteArray> start_addr, auto_ptr<ByteArray> end_addr, uint8_t start_icmp_type, uint8_t start_icmp_code, uint8_t end_icmp_type, uint8_t end_icmp_code, uint8_t ip_protocol_id );
00111 
00119             TrafficSelector( IpAddress& address, uint8_t prefixlen, uint16_t port, uint8_t ip_protocol_id );
00120 
00130             TrafficSelector( IpAddress& address, uint8_t prefixlen, uint8_t icmp_type, uint8_t icmp_code, uint8_t ip_protocol_id );
00131 
00136             TrafficSelector( const TrafficSelector& other );
00137 
00142             TrafficSelector( ByteBuffer& byte_buffer );
00143 
00149             static string TS_TYPE_STR( TS_TYPE ts_type );
00150 
00156             static auto_ptr<TrafficSelector> intersection( const TrafficSelector& ts1, const TrafficSelector& ts2 );
00157 
00163             virtual bool operator>=( const TrafficSelector& other ) const;
00164             
00170             virtual bool operator<=( const TrafficSelector& other ) const;
00171             
00177             virtual bool operator==( const TrafficSelector& other ) const;
00178 
00183             virtual uint16_t getStartPort() const ;
00184 
00189             virtual uint16_t getEndPort() const ;
00190 
00195             virtual uint8_t getStartIcmpType() const ;
00196 
00201             virtual uint8_t getStartIcmpCode() const ;
00202 
00207             virtual uint8_t getEndIcmpType() const;
00208 
00213             virtual uint8_t getEndIcmpCode() const;
00214 
00219             virtual auto_ptr<TrafficSelector> clone() const;
00220 
00221             virtual void getBinaryRepresentation( ByteBuffer& byte_buffer ) const;
00222 
00223             virtual string toStringTab( uint8_t tabs ) const;
00224 
00225             virtual ~TrafficSelector();
00226     };
00227 }
00228 #endif

Generated on Fri Jul 27 11:04:45 2007 for libopenikev2 by  doxygen 1.5.1