/// Encodes identity info void SipXauthIdentity::encode(UtlString & identityValue, const UtlString & callId, const UtlString & fromTag, const OsDateTime & timestamp, DialogRule bindRule ) { // calculate timestamp OsTime osTime; timestamp.cvtToTimeSinceEpoch(osTime); long seconds = osTime.seconds(); char stamp[65]; sprintf(stamp, "%lX", seconds); UtlString strSignature(stamp); strSignature.append(SignatureFieldSeparator); // signature-hash=MD5(<timestamp><secret><from-tag><call-id><identity>) NetMd5Codec signatureHash; signatureHash.hash(stamp); signatureHash.hash(sSignatureSecret); if (requireDialogBinding == bindRule) { signatureHash.hash(fromTag); signatureHash.hash(callId); } else { strSignature.append(SignatureFieldSeparator); } signatureHash.hash(mIdentity); UtlString strSignatureHash; signatureHash.appendHashValue(strSignature); Url encodedUrl(mIdentity); encodedUrl.setScheme(Url::SipUrlScheme); encodedUrl.setUrlParameter(SignatureUrlParamName, strSignature.data()); encodedUrl.toString(identityValue); Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "SipXauthIdentity::encode " "identity '%s'", identityValue.data() ); }
/// Start the timer to fire once at the indicated date/time bool OsTimer::Timer::oneshotAt(const OsDateTime& t) { OsTimer::Time now = OsTimer::now(); OsTime t_os; t.cvtToTimeSinceEpoch(t_os); OsTimer::Time expireFromNow = (OsTimer::Time)(t_os.seconds()) * TIMER_TIME_UNIT + t_os.usecs(); { mutex_lock lock(_mutex); if (_isRunning) return false; else _isRunning = true; if (expireFromNow <= now) { OS_LOG_ERROR(FAC_KERNEL, "OsTimer::Timer::oneshotAt timer expiration is in the past. Call ignored."); _isRunning = false; return false; } _expiresAt = expireFromNow; } // // This function sets the expiry time. Any pending asynchronous wait // operations will be cancelled. The handler for each cancelled operation will // be invoked with the boost::asio::error::operation_aborted error code. // { mutex_lock lock(gTimerServiceMutex); boost::system::error_code ec; _pDeadline->expires_from_now(boost::posix_time::microseconds(expireFromNow - now), ec); // // Perform an assynchronous wait on the timer // _pDeadline->async_wait(boost::bind(&OsTimer::Timer::onTimerFire, shared_from_this(), boost::asio::placeholders::error, &_owner)); } return _isRunning; }
// Arm the timer to fire periodically starting at the indicated date/time OsStatus OsTimer::periodicAt(const OsDateTime& when, const OsTime &period) { OsTime whenTime; when.cvtToTimeSinceEpoch(whenTime); return startTimer(whenTime, TRUE, period); }
// Arm the timer to fire once at the indicated date and time OsStatus OsTimer::oneshotAt(const OsDateTime& when) { OsTime whenTime; when.cvtToTimeSinceEpoch(whenTime); return startTimer(whenTime, FALSE, OsTime::NO_WAIT_TIME); }