2#if defined(HAVE_CONFIG_H)
28#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
34 while ( !key.
empty() )
42 mAddressList.push_back(addressRecord);
49 mTlsPeerNameList.push_back(tlsPeerNameRecord);
53 mTlsPeerNameCursor = mTlsPeerNameList.begin();
54 mAddressCursor = mAddressList.begin();
67 const short& transport)
69 Data key = buildKey(tlsPeerName, address, mask, port, family, transport);
70 InfoLog( <<
"Add ACL: key=" << key);
76 if(findAddressKey(key))
85 if(findTlsPeerNameKey(key))
112 addressRecord.
key = key;
115 mAddressList.push_back(addressRecord);
116 mAddressCursor = mAddressList.begin();
123 tlsPeerNameRecord.
key = key;
126 mTlsPeerNameList.push_back(tlsPeerNameRecord);
127 mTlsPeerNameCursor = mTlsPeerNameList.begin();
137 const short& transport)
153 const char* anchor = pb.
start();
170 pb.
data(hostOrIp, anchor);
187 pb.
data(hostOrIp, anchor);
204 pb.
data(hostOrIp, anchor);
219 pb.
data(hostOrIp, anchor);
242 if (mask < 8 || mask > 32)
249 if (mask < 64 || mask > 128)
284 ErrLog(<<
"Exception caught:" << e);
294 const short& transport)
296 Data key = buildKey(tlsPeerName, address, mask, port, family, transport);
297 InfoLog( <<
"Erase ACL: key=" << key);
311 if(findAddressKey(key))
313 mAddressCursor = mAddressList.erase(mAddressCursor);
319 if(findTlsPeerNameKey(key))
321 mTlsPeerNameCursor = mTlsPeerNameList.erase(mTlsPeerNameCursor);
333 const short& transport)
const
335 Data pKey = tlsPeerName+
":"+address+
"/"+
Data(mask)+
":"+
Data(port)+
":"+
Data(family)+
":"+
Data(transport);
344 mTlsPeerNameCursor = mTlsPeerNameList.begin();
345 if ( mTlsPeerNameCursor == mTlsPeerNameList.end() )
350 return mTlsPeerNameCursor->key;
355AclStore::findTlsPeerNameKey(
const Key& key)
358 if ( mTlsPeerNameCursor != mTlsPeerNameList.end() )
360 if ( mTlsPeerNameCursor->key == key )
367 mTlsPeerNameCursor = mTlsPeerNameList.begin();
368 while ( mTlsPeerNameCursor != mTlsPeerNameList.end() )
370 if ( mTlsPeerNameCursor->key == key )
374 mTlsPeerNameCursor++;
384 if ( !findTlsPeerNameKey(key) )
389 mTlsPeerNameCursor++;
391 if ( mTlsPeerNameCursor == mTlsPeerNameList.end() )
396 return mTlsPeerNameCursor->key;
404 mAddressCursor = mAddressList.begin();
405 if ( mAddressCursor == mAddressList.end() )
410 return mAddressCursor->key;
415AclStore::findAddressKey(
const Key& key)
418 if ( mAddressCursor != mAddressList.end() )
420 if ( mAddressCursor->key == key )
427 mAddressCursor = mAddressList.begin();
428 while ( mAddressCursor != mAddressList.end() )
430 if ( mAddressCursor->key == key )
444 if ( !findAddressKey(key) )
451 if ( mAddressCursor == mAddressList.end() )
456 return mAddressCursor->key;
464 if ( !findTlsPeerNameKey(key) )
468 return mTlsPeerNameCursor->mTlsPeerName;
476 if ( !findAddressKey(key) )
480 return mAddressCursor->mAddressTuple;
488 if ( !findAddressKey(key) )
492 return mAddressCursor->mMask;
500 for(std::list<Data>::const_iterator it = tlsPeerNames.begin(); it != tlsPeerNames.end(); it++)
502 for(TlsPeerNameList::iterator i = mTlsPeerNameList.begin(); i != mTlsPeerNameList.end(); i++)
506 InfoLog (<<
"AclStore - Tls peer name IS trusted: " << *it);
519 for(AddressList::iterator i = mAddressList.begin(); i != mAddressList.end(); i++)
521 if(i->mAddressTuple.isEqualWithMask(address, i->mMask, i->mAddressTuple.
getPort() == 0))
534 bool trusted =
false;
540 request.
header(h_Vias).front().transport());
544 StackLog(<<
"Not checking the TLS peer certificate names, that is now done by CertificateAuthenticator if enabled");
Handles cross-platform sockets compatibility.
virtual Key firstAclKey()
virtual AclRecord getAcl(const Key &key) const
virtual bool addAcl(const Key &key, const AclRecord &rec)
virtual void eraseAcl(const Key &key)
void eraseAcl(const resip::Data &tlsPeerName, const resip::Data &address, const short &mask, const short &port, const short &family, const short &transport)
resip::Data getTlsPeerName(const resip::Data &key)
bool isRequestTrusted(const resip::SipMessage &request)
short getAddressMask(const resip::Data &key)
Key getNextTlsPeerNameKey(Key &key)
Key getFirstTlsPeerNameKey()
bool isAddressTrusted(const resip::Tuple &address)
Key getNextAddressKey(Key &key)
resip::Tuple getAddressTuple(const resip::Data &key)
bool isTlsPeerNameTrusted(const std::list< resip::Data > &tlsPeerNames)
bool addAcl(const resip::Data &tlsPeerName, const resip::Data &address, const short &mask, const short &port, const short &family, const short &transport)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
const char * c_str() const
Returns a null-terminated string representing.
bool prefix(const Data &pre) const noexcept
Returns true if this Data starts with the bytes indicated by the passed-in Data.
bool empty() const noexcept
Checks whether the Data is empty.
Data & lowercase()
Converts this Data to lowercase.
static int inet_pton(const Data &printableIp, struct in_addr &dst)
Convert from the presentation format of the IPv4 address to struct in_addr.
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipToChar(char c)
CurrentPosition position() const
CurrentPosition skipToOneOf(const char *cs)
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
const char * skipToEndQuote(char quote='"')
BaseException used to indicate parse failures.
Represents a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
const Tuple & getSource() const
Returns the source tuple that the message was received from only makes sense for messages received fr...
Represents a network address.
Data presentationFormat() const
Wrapper around the inet_top() method.
static const Data & toData(TransportType)
Converts the TransportType to a string representation of the transport type, e.g.
TransportType getType() const
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
bool isEqualNoCase(const Data &left, const Data &right)
TransportType toTransportType(const resip::Data &transportName)
bool isSecure(TransportType type)
Returns true if passed in transport type is a secure transport protocol.
TransportType
An enumeration of transport protocols.