OmniSketch  0.1
Oh my sketch!
OmniSketch::FlowKey< key_len > Class Template Reference

Template class for flowkey. More...

#include <flowkey.h>

Public Member Functions

 FlowKey ()
 Void constructor. More...
 
 FlowKey (const int8_t *key)
 Construct by copying from a pointer. More...
 
 FlowKey (int32_t ipaddr)
 Construct by a 1-tuple. More...
 
 FlowKey (int32_t srcip, int32_t dstip)
 Construct by a 2-tuple. More...
 
 FlowKey (int32_t srcip, int32_t dstip, int16_t srcport, int16_t dstport, int8_t protocol)
 Construct by a 5-tuple. More...
 
bool operator== (const FlowKey &otherkey) const
 See if two flowkeys are identical. More...
 
bool operator< (const FlowKey &otherkey) const
 See if the first flowkey is less than the second key in lexicographic order. More...
 
FlowKey< key_len > & operator^= (const FlowKey &otherkey)
 XOR two flowkeys in place. More...
 
template<int32_t other_len>
FlowKey< key_len > & copy (int32_t pos, const FlowKey< other_len > &other_key, int32_t o_pos, int32_t len)
 Copy from another flowkey (probably of different length) More...
 
FlowKey< key_len > & copy (int32_t pos, const int8_t *key, int32_t len)
 Copy from a given pointer. More...
 
FlowKey< key_len > & swap (FlowKey< key_len > &the_other_key)
 Swap the content of two flowkey. More...
 
int8_t getBit (int32_t pos) const
 Get a single bit in flowkey. More...
 
void setBit (int32_t pos, bool one)
 Set a single bit in flowkey. More...
 
const int8_t * cKey () const
 Get the flowkey as a char array. More...
 
int32_t getIp () const
 Get the IP address. More...
 
int32_t getSrcIp () const
 Get the src IP address. More...
 
int32_t getDstIp () const
 Get the dst IP address. More...
 
int16_t getSrcPort () const
 Get the src port. More...
 
int16_t getDstPort () const
 Get the dst port. More...
 
int8_t getProtocol () const
 Get the protocol code. More...
 

Friends

template<int32_t other_len>
class FlowKey
 

Detailed Description

template<int32_t key_len>
class OmniSketch::FlowKey< key_len >

Template class for flowkey.

Template Parameters
key_lenlength of flowkey

Constructor & Destructor Documentation

◆ FlowKey() [1/5]

template<int32_t key_len>
OmniSketch::FlowKey< key_len >::FlowKey

Void constructor.

Initialized to an all-zero flowkey

◆ FlowKey() [2/5]

template<int32_t key_len>
OmniSketch::FlowKey< key_len >::FlowKey ( const int8_t *  key)

Construct by copying from a pointer.

Parameters
keythe pointer to be copied from

◆ FlowKey() [3/5]

template<int32_t key_len>
OmniSketch::FlowKey< key_len >::FlowKey ( int32_t  ipaddr)

Construct by a 1-tuple.

Parameters
ipaddrIP address of the flow
Warning
Be sure to have key_len=4 when invoking. Otherwise an exception would be thrown.

◆ FlowKey() [4/5]

template<int32_t key_len>
OmniSketch::FlowKey< key_len >::FlowKey ( int32_t  srcip,
int32_t  dstip 
)

Construct by a 2-tuple.

Parameters
srcipsource IP address
dstipdestination IP address
Warning
Be sure to have key_len=8 when invoking. Otherwise an exception would be thrown.

◆ FlowKey() [5/5]

template<int32_t key_len>
OmniSketch::FlowKey< key_len >::FlowKey ( int32_t  srcip,
int32_t  dstip,
int16_t  srcport,
int16_t  dstport,
int8_t  protocol 
)

Construct by a 5-tuple.

Parameters
srcipsource IP address
dstipdestination IP address
srcportsource port
dstportdestination port
protocolcode of network protocol in use
Warning
Be sure to have key_len=13 when invoking. Otherwise an exception would be thrown.

Member Function Documentation

◆ cKey()

template<int32_t key_len>
const int8_t* OmniSketch::FlowKey< key_len >::cKey ( ) const
inline

Get the flowkey as a char array.

Returns
const int8_t* pointer to flowkey

◆ copy() [1/2]

template<int32_t key_len>
template<int32_t other_len>
FlowKey< key_len > & OmniSketch::FlowKey< key_len >::copy ( int32_t  pos,
const FlowKey< other_len > &  other_key,
int32_t  o_pos,
int32_t  len 
)

Copy from another flowkey (probably of different length)

Template Parameters
other_lenLength of the other flowkey
Parameters
posdestination offset (into the current flowkey)
other_keythe other flowkey to be copied from
o_possource offset (into the other flowkey)
lenlength of the copied interval (in bytes)
Returns
the copied flowkey itself

◆ copy() [2/2]

template<int32_t key_len>
FlowKey< key_len > & OmniSketch::FlowKey< key_len >::copy ( int32_t  pos,
const int8_t *  key,
int32_t  len 
)

Copy from a given pointer.

Parameters
posdestination offset (into the current flowkey)
keythe pointer to be copied from
lenlength of the copied interval (in bytes)
Returns
the copied flowkey itself

◆ getBit()

template<int32_t key_len>
int8_t OmniSketch::FlowKey< key_len >::getBit ( int32_t  pos) const

Get a single bit in flowkey.

Parameters
posOffset into the flowkey
Returns
1 if the bit is on; 0 otherwise.

◆ getDstIp()

template<int32_t key_len>
int32_t OmniSketch::FlowKey< key_len >::getDstIp ( ) const
inline

Get the dst IP address.

Returns
destination IP address
Warning
Be sure to have key_len=8 or key_len=13 when invoking

◆ getDstPort()

template<int32_t key_len>
int16_t OmniSketch::FlowKey< key_len >::getDstPort ( ) const
inline

Get the dst port.

Returns
destination port no
Warning
Be sure to have key_len=13 when invoking

◆ getIp()

template<int32_t key_len>
int32_t OmniSketch::FlowKey< key_len >::getIp ( ) const
inline

Get the IP address.

Returns
IP address as 1-tuple
Warning
Be sure to have key_len=4 when invoking

◆ getProtocol()

template<int32_t key_len>
int8_t OmniSketch::FlowKey< key_len >::getProtocol ( ) const
inline

Get the protocol code.

Returns
the protocol code of the flow
Warning
Be sure to have key_len=13 when invoking

◆ getSrcIp()

template<int32_t key_len>
int32_t OmniSketch::FlowKey< key_len >::getSrcIp ( ) const
inline

Get the src IP address.

Returns
source IP address
Warning
Be sure to have key_len=8 or key_len=13 when invoking

◆ getSrcPort()

template<int32_t key_len>
int16_t OmniSketch::FlowKey< key_len >::getSrcPort ( ) const
inline

Get the src port.

Returns
source port no
Warning
Be sure to have key_len=13 when invoking

◆ operator<()

template<int32_t key_len>
bool OmniSketch::FlowKey< key_len >::operator< ( const FlowKey< key_len > &  otherkey) const

See if the first flowkey is less than the second key in lexicographic order.

Parameters
otherkeythe second flowkey to compare with (of the same length)
Returns
false if is smaller; true if equal or is greater

◆ operator==()

template<int32_t key_len>
bool OmniSketch::FlowKey< key_len >::operator== ( const FlowKey< key_len > &  otherkey) const

See if two flowkeys are identical.

Parameters
otherkeythe second flowkey to compare with (of the same length)
Returns
true if equal; false otherwise.

◆ operator^=()

template<int32_t key_len>
FlowKey< key_len > & OmniSketch::FlowKey< key_len >::operator^= ( const FlowKey< key_len > &  otherkey)

XOR two flowkeys in place.

◆ setBit()

template<int32_t key_len>
void OmniSketch::FlowKey< key_len >::setBit ( int32_t  pos,
bool  one 
)

Set a single bit in flowkey.

Parameters
posOffset into the flowkey
one1 if set to be on; 0 otherwise.

◆ swap()

template<int32_t key_len>
FlowKey< key_len > & OmniSketch::FlowKey< key_len >::swap ( FlowKey< key_len > &  the_other_key)

Swap the content of two flowkey.

No effect if one flowkey swaps with itself

Friends And Related Function Documentation

◆ FlowKey

template<int32_t key_len>
template<int32_t other_len>
friend class FlowKey
friend