00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00041 public:
00043 enum TS_TYPE{
00044 TS_IPV4_ADDR_RANGE = 7,
00045 TS_IPV6_ADDR_RANGE = 8,
00046 };
00047
00048
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
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