reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
resip::Tuple Class Reference

Represents a network address. More...

#include <Tuple.hxx>

Classes

class  AnyInterfaceCompare
 A "less than" comparator for Tuple, for use in map containers etc. More...
 
class  AnyPortAnyInterfaceCompare
 A "less than" comparator for Tuple, for use in map containers etc. More...
 
class  AnyPortCompare
 A "less than" comparator for Tuple, for use in map containers etc. More...
 
class  FlowKeyCompare
 

Public Member Functions

 RESIP_HeapCount (Tuple)
 
 Tuple ()
 
 Tuple (const GenericIPAddress &genericAddress, TransportType type=UNKNOWN_TRANSPORT, const Data &targetDomain=Data::Empty)
 
 Tuple (const Data &printableAddress, int port, IpVersion ipVer, TransportType type=UNKNOWN_TRANSPORT, const Data &targetDomain=Data::Empty, const Data &netNs=Data::Empty)
 
 Tuple (const Data &printableAddress, int port, TransportType type, const Data &targetDomain=Data::Empty, const Data &netNs=Data::Empty)
 
 Tuple (const in_addr &pipv4, int pport, TransportType ptype, const Data &targetDomain=Data::Empty, const Data &netNs=Data::Empty)
 
 Tuple (const sockaddr &addr, TransportType ptype, const Data &targetDomain=Data::Empty)
 
const sockaddr & getSockaddr () const
 Retrieve a const binary representation of the socket address for this tuple.
 
sockaddr & getMutableSockaddr ()
 Retrieve the binary representation of the socket address for this tuple.
 
void copySockaddrAnyPort (sockaddr *sa)
 Get a copy of the socket address including the interface and not the port number.
 
void setSockaddr (const GenericIPAddress &)
 Set the internal binary representation of the socket address from the GenericIPAddress.
 
TransportType getType () const
 
void setType (TransportType type)
 
void setPort (int port)
 
int getPort () const
 
FlowKey getFlowKey () const
 
void setFlowKey (FlowKey flowKey)
 
bool isV4 () const
 
IpVersion ipVersion () const
 Returns V4 or V6 as appropriate.
 
bool isAnyInterface () const
 TRUE if this address is equal to the "INADDR_ANY" value for this address family.
 
socklen_t length () const
 
bool isLoopback () const
 
bool isPrivateAddress () const
 
bool isSpecialPurposeAddress () const
 
bool operator< (const Tuple &rhs) const
 Compares TransportType, the binary address, port, and address family of the Tuple.
 
bool operator== (const Tuple &rhs) const
 Compares TransportType, the binary address, port, and address family of the Tuple.
 
bool isEqual (const Tuple &tuple, bool ignorePort=false, bool ignoreTransport=false) const
 compares this tuple with the one passed in for family, port and address equality.
 
Data presentationFormat () const
 Wrapper around the inet_top() method.
 
GenericIPAddress toGenericIPAddress () const
 
bool isEqualWithMask (const Tuple &tuple, short mask, bool ignorePort=false, bool ignoreTransport=false) const
 compares this tuple with the one passed in for family, port and address equality using the passed in address mask (mask is specified by number of bits)
 
bool isAddressAllowed (const std::vector< AddressMask > &allowed, const std::vector< AddressMask > &denied) const
 Tests whether this address is permitted by the supplied allow/deny address lists.
 
void setTargetDomain (const Data &target)
 Set the domain name this address tuple intends to represent.
 
const Data & getTargetDomain () const
 Get the domain name this address tuple intends to represent.
 
void setNetNs (const Data &netNs)
 Set the netns (network namespace) for this Tuple.
 
const Data & getNetNs () const
 Get the netns for this Tuple.
 
size_t hash () const
 Creates a 32-bit hash based on the contents of this Tuple.
 

Static Public Member Functions

static TransportType toTransport (const Data &)
 Converts a string representation of transport type, i.e.
 
static const Data & toData (TransportType)
 Converts the TransportType to a string representation of the transport type, e.g.
 
static const Data & toDataLower (TransportType type)
 
static Data inet_ntop (const Tuple &tuple)
 Converts the binary socket address to presentation format, via the DnsUtil::inet_ntop() method.
 
static void writeBinaryToken (const Tuple &tuple, Data &container, const Data &salt=Data::Empty)
 
static Tuple makeTupleFromBinaryToken (const Data &binaryToken, const Data &salt=Data::Empty)
 

Public Attributes

FlowKey mFlowKey
 This is a (largely) opaque key that subclasses of Transport will use to help record/find flows.
 
TransportKey mTransportKey
 
bool onlyUseExistingConnection
 

Friends

class AnyInterfaceCompare
 
class AnyPortCompare
 
class AnyPortAnyInterfaceCompare
 
class FlowKeyCompare
 
class DnsResult
 
EncodeStream & operator<< (EncodeStream &strm, const Tuple &tuple)
 

Detailed Description

Represents a network address.

This includes:

  • IP address
  • port
  • protocol (TransportType)
  • TLS hostname (since this is integral to connection establishment)

Internally the class is aware of the struct sockaddr/sin_addr/sin6addr binary representation of the address. The sa_family of struct sockaddr is used to keep track of whether a Tuple is representing a an IPv4 or IPv6 address.

Also included are some comparator classes that can be used for containers of Tuple.

Definition at line 58 of file Tuple.hxx.

Constructor & Destructor Documentation

◆ Tuple() [1/6]

Tuple::Tuple ( )

Definition at line 35 of file Tuple.cxx.

◆ Tuple() [2/6]

Tuple::Tuple ( const GenericIPAddress &  genericAddress,
TransportType  type = UNKNOWN_TRANSPORT,
const Data &  targetDomain = Data::Empty 
)
explicit

Definition at line 46 of file Tuple.cxx.

◆ Tuple() [3/6]

Tuple::Tuple ( const Data &  printableAddress,
int  port,
IpVersion  ipVer,
TransportType  type = UNKNOWN_TRANSPORT,
const Data &  targetDomain = Data::Empty,
const Data &  netNs = Data::Empty 
)

Definition at line 58 of file Tuple.cxx.

◆ Tuple() [4/6]

Tuple::Tuple ( const Data &  printableAddress,
int  port,
TransportType  type,
const Data &  targetDomain = Data::Empty,
const Data &  netNs = Data::Empty 
)

Definition at line 112 of file Tuple.cxx.

◆ Tuple() [5/6]

Tuple::Tuple ( const in_addr &  pipv4,
int  pport,
TransportType  ptype,
const Data &  targetDomain = Data::Empty,
const Data &  netNs = Data::Empty 
)

Definition at line 153 of file Tuple.cxx.

◆ Tuple() [6/6]

resip::Tuple::Tuple ( const sockaddr &  addr,
TransportType  ptype,
const Data &  targetDomain = Data::Empty 
)

Member Function Documentation

◆ copySockaddrAnyPort()

void Tuple::copySockaddrAnyPort ( sockaddr *  sa)

Get a copy of the socket address including the interface and not the port number.

Definition at line 218 of file Tuple.cxx.

◆ getFlowKey()

FlowKey resip::Tuple::getFlowKey ( ) const
inline

Definition at line 126 of file Tuple.hxx.

◆ getMutableSockaddr()

sockaddr & resip::Tuple::getMutableSockaddr ( )
inline

Retrieve the binary representation of the socket address for this tuple.

Definition at line 113 of file Tuple.hxx.

◆ getNetNs()

const Data & resip::Tuple::getNetNs ( ) const
inline

Get the netns for this Tuple.

Definition at line 271 of file Tuple.hxx.

◆ getPort()

int Tuple::getPort ( ) const

Definition at line 466 of file Tuple.cxx.

◆ getSockaddr()

const sockaddr & resip::Tuple::getSockaddr ( ) const
inline

Retrieve a const binary representation of the socket address for this tuple.

Definition at line 109 of file Tuple.hxx.

◆ getTargetDomain()

const Data & resip::Tuple::getTargetDomain ( ) const
inline

Get the domain name this address tuple intends to represent.

Useful with DnsUtil, for example.

Definition at line 259 of file Tuple.hxx.

◆ getType()

TransportType resip::Tuple::getType ( ) const
inline

Definition at line 122 of file Tuple.hxx.

◆ hash()

size_t Tuple::hash ( ) const

Creates a 32-bit hash based on the contents of this Tuple.

Definition at line 887 of file Tuple.cxx.

◆ inet_ntop()

Data Tuple::inet_ntop ( const Tuple &  tuple)
static

Converts the binary socket address to presentation format, via the DnsUtil::inet_ntop() method.

Definition at line 939 of file Tuple.cxx.

◆ ipVersion()

IpVersion Tuple::ipVersion ( ) const

Returns V4 or V6 as appropriate.

Definition at line 537 of file Tuple.cxx.

◆ isAddressAllowed()

bool Tuple::isAddressAllowed ( const std::vector< AddressMask > &  allowed,
const std::vector< AddressMask > &  denied 
) const

Tests whether this address is permitted by the supplied allow/deny address lists.

Deny wins: if this address matches any entry in denied the result is false. Otherwise, if allowed is non-empty, this address must match one of its entries to be permitted; an empty allowed list imposes no allow restriction. Port and transport are ignored; address family must match for an entry to apply (so an IPv4 address is never permitted by an IPv6 allow entry, and vice versa). Matching uses isEqualWithMask.

Definition at line 858 of file Tuple.cxx.

◆ isAnyInterface()

bool Tuple::isAnyInterface ( ) const

TRUE if this address is equal to the "INADDR_ANY" value for this address family.


Definition at line 485 of file Tuple.cxx.

◆ isEqual()

bool Tuple::isEqual ( const Tuple &  tuple,
bool  ignorePort = false,
bool  ignoreTransport = false 
) const

compares this tuple with the one passed in for family, port and address equality.

Potentially ignoring the port number and/or transport type.

Definition at line 680 of file Tuple.cxx.

◆ isEqualWithMask()

bool Tuple::isEqualWithMask ( const Tuple &  tuple,
short  mask,
bool  ignorePort = false,
bool  ignoreTransport = false 
) const

compares this tuple with the one passed in for family, port and address equality using the passed in address mask (mask is specified by number of bits)

Definition at line 956 of file Tuple.cxx.

◆ isLoopback()

bool Tuple::isLoopback ( ) const

Definition at line 503 of file Tuple.cxx.

◆ isPrivateAddress()

bool Tuple::isPrivateAddress ( ) const

Definition at line 552 of file Tuple.cxx.

◆ isSpecialPurposeAddress()

bool Tuple::isSpecialPurposeAddress ( ) const

Definition at line 611 of file Tuple.cxx.

◆ isV4()

bool Tuple::isV4 ( ) const
Deprecated:
use ipVersion()
Todo:
!dcm! – should deprecate asap

Definition at line 531 of file Tuple.cxx.

◆ length()

socklen_t Tuple::length ( ) const

Definition at line 655 of file Tuple.cxx.

◆ makeTupleFromBinaryToken()

Tuple Tuple::makeTupleFromBinaryToken ( const Data &  binaryToken,
const Data &  salt = Data::Empty 
)
static

Definition at line 328 of file Tuple.cxx.

◆ operator<()

bool Tuple::operator< ( const Tuple &  rhs) const

Compares TransportType, the binary address, port, and address family of the Tuple.

Definition at line 710 of file Tuple.cxx.

◆ operator==()

bool Tuple::operator== ( const Tuple &  rhs) const

Compares TransportType, the binary address, port, and address family of the Tuple.

Definition at line 674 of file Tuple.cxx.

◆ presentationFormat()

Data Tuple::presentationFormat ( ) const

Wrapper around the inet_top() method.

Definition at line 426 of file Tuple.cxx.

◆ RESIP_HeapCount()

resip::Tuple::RESIP_HeapCount ( Tuple  )

◆ setFlowKey()

void resip::Tuple::setFlowKey ( FlowKey  flowKey)
inline

Definition at line 127 of file Tuple.hxx.

◆ setNetNs()

void resip::Tuple::setNetNs ( const Data &  netNs)
inline

Set the netns (network namespace) for this Tuple.

Definition at line 265 of file Tuple.hxx.

◆ setPort()

void Tuple::setPort ( int  port)

Definition at line 449 of file Tuple.cxx.

◆ setSockaddr()

void Tuple::setSockaddr ( const GenericIPAddress &  addr)

Set the internal binary representation of the socket address from the GenericIPAddress.

Definition at line 239 of file Tuple.cxx.

◆ setTargetDomain()

void resip::Tuple::setTargetDomain ( const Data &  target)
inline

Set the domain name this address tuple intends to represent.

Definition at line 252 of file Tuple.hxx.

◆ setType()

void resip::Tuple::setType ( TransportType  type)
inline

Definition at line 123 of file Tuple.hxx.

◆ toData()

const Data & Tuple::toData ( TransportType  type)
static

Converts the TransportType to a string representation of the transport type, e.g.

"TCP"

Definition at line 927 of file Tuple.cxx.

◆ toDataLower()

const Data & Tuple::toDataLower ( TransportType  type)
static

Definition at line 933 of file Tuple.cxx.

◆ toGenericIPAddress()

GenericIPAddress Tuple::toGenericIPAddress ( ) const

Definition at line 1169 of file Tuple.cxx.

◆ toTransport()

TransportType Tuple::toTransport ( const Data &  transportName)
static

Converts a string representation of transport type, i.e.

"UDP" to a TransportType

Definition at line 921 of file Tuple.cxx.

◆ writeBinaryToken()

void Tuple::writeBinaryToken ( const Tuple &  tuple,
resip::Data &  container,
const Data &  salt = Data::Empty 
)
static

Definition at line 266 of file Tuple.cxx.

Friends And Related Symbol Documentation

◆ AnyInterfaceCompare

friend class AnyInterfaceCompare
friend

Definition at line 218 of file Tuple.hxx.

◆ AnyPortAnyInterfaceCompare

friend class AnyPortAnyInterfaceCompare
friend

Definition at line 241 of file Tuple.hxx.

◆ AnyPortCompare

friend class AnyPortCompare
friend

Definition at line 231 of file Tuple.hxx.

◆ DnsResult

friend class DnsResult
friend

Definition at line 299 of file Tuple.hxx.

◆ FlowKeyCompare

friend class FlowKeyCompare
friend

Definition at line 249 of file Tuple.hxx.

◆ operator<<

EncodeStream & operator<< ( EncodeStream &  strm,
const Tuple &  tuple 
)
friend

Member Data Documentation

◆ m_anonv4

sockaddr_in resip::Tuple::m_anonv4

Definition at line 285 of file Tuple.hxx.

◆ mFlowKey

FlowKey resip::Tuple::mFlowKey

This is a (largely) opaque key that subclasses of Transport will use to help record/find flows.

For UDP and DTLS, this is just the FD, and the rest of the information about the flow is carried in the Tuple. For TCP and TLS, the FD of the connection is used. For protocols where using the FD would not be appropriate (SCTP), the transport may use whatever method to generate these it likes. (It is highly recommended that these ids are unique across all instances of a transport type)

Definition at line 189 of file Tuple.hxx.

◆ mSockaddr

sockaddr resip::Tuple::mSockaddr

Definition at line 284 of file Tuple.hxx.

◆ mTransportKey

TransportKey resip::Tuple::mTransportKey

Definition at line 190 of file Tuple.hxx.

◆ onlyUseExistingConnection

bool resip::Tuple::onlyUseExistingConnection

Definition at line 192 of file Tuple.hxx.

◆ pad

char resip::Tuple::pad[RESIP_MAX_SOCKADDR_SIZE]

Definition at line 291 of file Tuple.hxx.


The documentation for this class was generated from the following files: