22#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
38RegSyncClient::delaySeconds(
unsigned int seconds)
41 for(
unsigned int i = 0; i < seconds && !
mShutdown; i++)
54 closesocket(mSocketDesc);
69 memset(&hint, 0,
sizeof(hint));
70 hint.ai_family = AF_UNSPEC;
71 hint.ai_flags = AI_PASSIVE;
72 hint.ai_socktype = SOCK_STREAM;
74 rc = getaddrinfo(mAddress.
c_str(), 0, &hint, &results);
77 ErrLog(<<
"RegSyncClient: unknown host " << mAddress);
82 Tuple servAddr(*results->ai_addr,
TCP);
87 freeaddrinfo(results);
92 mSocketDesc = (int)socket(servAddr.
ipVersion() ==
V6 ? PF_INET6 : PF_INET , SOCK_STREAM, 0);
96 ErrLog(<<
"RegSyncClient: cannot open socket, err=" << e);
106 ErrLog(<<
"RegSyncClient: error binding locally, err=" << e);
117 if(!
mShutdown)
ErrLog(<<
"RegSyncClient: error connecting to " << mAddress <<
":" << mPort <<
", err=" << e);
129 "</InitialSync>\r\n");
130 rc = ::send(mSocketDesc, request.
c_str(), (
int)request.
size(), 0);
145 ErrLog(<<
"RegSyncClient: Could not make HTTP socket non-blocking, err=" << e);
162 rc = ::recv(mSocketDesc, (
char*)&mRxBuffer,
sizeof(mRxBuffer), 0);
185 if ( e != EAGAIN && e != EWOULDBLOCK )
187 if(!
mShutdown)
ErrLog(<<
"RegSyncClient: error sending keepalive, err=" << e);
201 if(!
mShutdown)
ErrLog(<<
"RegSyncClient: error calling select, err=" << e);
213RegSyncClient::tryParse()
217 const char* start = pb.position();
223 const char* anchor = pb.position();
227 initialTag = pb.
data(anchor);
229 pb.skipToChars(
"</" + initialTag +
">");
232 pb.skipN(initialTag.
size() + 3);
233 handleXml(pb.data(start));
239 anchor = pb.position();
241 mRxDataBuffer = pb.
data(anchor);
246 mRxDataBuffer.
clear();
255RegSyncClient::handleXml(
const Data& xmlData)
267 InfoLog(<<
"RegSyncClient::handleXml: InitialSync complete.");
273 handleRegInfoEvent(xml);
277 ErrLog(<<
"RegSyncClient::handleXml: exception: " << e);
284 handlePubInfoEvent(xml);
288 ErrLog(<<
"RegSyncClient::handleXml: exception: " << e);
293 WarningLog(<<
"RegSyncClient::handleXml: Ignoring XML message with unknown method: " << xml.getTag());
298 WarningLog(<<
"RegSyncClient::handleXml: Ignoring XML message due to ParseException: " << e);
308 DebugLog(<<
"RegSyncClient::handleRegInfoEvent");
344 rec.
mRegExpires = (expires == 0 ? 0 : now+expires);
416 contacts.push_back(rec);
426 processModify(aor, contacts);
438 InfoLog(<<
"RegSyncClient::processModify: for aor=" << aor <<
439 ", numSyncContacts=" << syncContacts.size() <<
440 ", numCurrentContacts=" << currentContacts.size());
443 ContactList::iterator itSync = syncContacts.begin();
444 ContactList::iterator itCurrent;
446 for(; itSync != syncContacts.end(); itSync++)
448 InfoLog(<<
" RegSyncClient::processModify: contact=" << itSync->mContact <<
", instance=" << itSync->mInstance <<
", regid=" << itSync->mRegId);
452 for(itCurrent = currentContacts.begin(); itCurrent != currentContacts.end(); itCurrent++)
454 if(*itSync == *itCurrent)
458 if(itSync->mLastUpdated > itCurrent->mLastUpdated)
478 DebugLog(<<
"RegSyncClient::handlePubInfoEvent");
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
Handles cross-platform sockets compatibility.
RegSyncClient(resip::InMemorySyncRegDb *regDb, resip::Data address, unsigned short port, resip::InMemorySyncPubDb *pubDb=0)
The abstract base-class for all exceptions thrown by resip code.
Base class for all SIP body types.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Data xmlCharDataDecode() const
Performs in-place XML Character Data un-escaping of a Data.
Data base64decode() const
Performs RFC 3548 Base 64 decoding of the contents of this data.
static const Data Empty
Constant that represents a zero-length data.
const char * c_str() const
Returns a null-terminated string representing.
@ Borrow
The Data instance is borrowing the memory from the passed in buffer.
unsigned long convertUnsignedLong() const
uint64_t convertUInt64() const
Takes the contents of the Data and converts them to an unsigned 64-bit integer.
size_type size() const noexcept
Returns the number of bytes in this Data.
Data & clear()
Clears the contents of this Data.
const char * data() const noexcept
Returns a pointer to the contents of this Data.
Object-oriented wrapper for your platform's file-descriptor set.
void setExcept(Socket fd)
SIP body type for holding PIDF contents (MIME content-type application/pidf+xml).
static const Mime & getStaticType()
Implementation of a persistence manager.
virtual void addUpdateDocument(const PubDocument &document)
virtual bool removeDocument(const Data &eventType, const Data &documentKey, const Data &eTag, uint64_t lastUpdated, bool syncPublication=false)
Implementation of a persistence manager.
virtual update_status_t updateContact(const resip::Uri &aor, const ContactInstanceRecord &rec)
virtual void unlockRecord(const Uri &aor)
virtual void getContacts(const Uri &aor, ContactList &container)
virtual void lockRecord(const Uri &aor)
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Provides string-parsing functionality with protection from buffer overflow.
void push_back(const T &t)
Inserts a header field value at the back of this container.
static const char * CRLFCRLF
static uint64_t getTimeSecs()
Returns the current clock time in seconds.
Represents a network address.
IpVersion ipVersion() const
Returns V4 or V6 as appropriate.
static Tuple makeTupleFromBinaryToken(const Data &binaryToken, const Data &salt=Data::Empty)
sockaddr & getMutableSockaddr()
Retrieve the binary representation of the socket address for this tuple.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
const Data & getValue() const
const Data & getTag() 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)
int closeSocket(Socket fd)
bool makeSocketNonBlocking(Socket fd)
std::list< ContactInstanceRecord > ContactList
unsigned __int64 uint64_t
std::shared_ptr< SecurityAttributes > mSecurityAttributes
std::shared_ptr< Contents > mContents