23#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
30 std::shared_ptr<SipMessage> request,
35 mStaleCallTimerSeq(1),
36 mCancelledTimerSeq(1),
37 mServerSub(serverSub),
38 mAllowOfferInPrack(false)
71 if(mAllowOfferInPrack)
153 std::shared_ptr<SipMessage> ack =
sendAck(&answer);
167 auto response = std::make_shared<SipMessage>();
172 InfoLog (<<
"Sending " << response->brief());
261 reject(statusCode,
nullptr, warning);
273 auto response = std::make_shared<SipMessage>();
278 response->setContents(contents);
282 response->header(h_Warnings).push_back(*warning);
320ClientInviteSession::cancel()
347ClientInviteSession::onForkAccepted()
370ClientInviteSession::startCancelTimer()
377ClientInviteSession::startStaleCallTimer()
385 ++mStaleCallTimerSeq);
389ClientInviteSession::sendSipFrag(
const SipMessage& msg)
411 mServerSub->
send(mServerSub->
update(&contents));
423ClientInviteSession::dispatch(
const SipMessage& msg)
456 dispatchEarlyWithOffer(msg);
459 dispatchEarlyWithAnswer(msg);
462 dispatchAnswered(msg);
465 dispatchSentUpdateEarly(msg);
468 dispatchSentUpdateEarlyGlare(msg);
471 dispatchReceivedUpdateEarly(msg);
474 dispatchSentAnswer(msg);
477 dispatchQueuedUpdate(msg);
480 dispatchCancelled(msg);
496ClientInviteSession::dispatch(
const DumTimeout& timer)
500 if(timer.
seq() == mCancelledTimerSeq)
506 sendSipFrag(response);
515 if(timer.
seq() == mStaleCallTimerSeq)
532 InfoLog (<<
"Retransmitting the UPDATE (glare condition timer)");
548ClientInviteSession::handleRedirect (
const SipMessage& msg)
553 if (
mDum.mDialogEventStateManager)
563ClientInviteSession::handleProvisional(
const SipMessage& msg)
576 InfoLog (<<
"Failure: CSeq doesn't match invite: " << msg.
brief());
585 InfoLog (<<
"Failure: No RSeq in 1xx: " << msg.
brief());
592 startStaleCallTimer();
597ClientInviteSession::handleFinalResponse(
const SipMessage& msg)
605 ++mStaleCallTimerSeq;
613 handleProvisional(msg);
627 handleProvisional(msg);
633 mAllowOfferInPrack =
true;
638 mAllowOfferInPrack =
false;
647 sendPrackIfNeeded(msg);
653ClientInviteSession::sendPrackIfNeeded(
const SipMessage& msg)
661 auto prack = std::make_shared<SipMessage>();
663 prack->header(h_RAck) = mRelRespInfo;
675 auto prack = std::make_shared<SipMessage>();
677 prack->header(h_RAck)= mRelRespInfo;
686ClientInviteSession::dispatchStart (
const SipMessage& msg)
704 handleProvisional(msg);
705 sendPrackIfNeeded(msg);
721 handleProvisional(msg);
734 handle1xxOffer(msg, *offerAnswer);
743 handle1xxAnswer(msg, *offerAnswer);
749 handleFinalResponse(msg);
767 handleFinalResponse(msg);
785 InfoLog(<<
"Failure: 2xx with no answer: " << msg.
brief());
799 InfoLog (<<
"Failure: error response: " << msg.
brief());
813 WarningLog (<<
"Don't know what this is : " << msg);
819ClientInviteSession::dispatchEarly (
const SipMessage& msg)
824 switch (
toEvent(msg, offerAnswer.get()))
828 handleProvisional(msg);
829 sendPrackIfNeeded(msg);
834 handleProvisional(msg);
844 handle1xxOffer(msg, *offerAnswer);
849 handle1xxAnswer(msg, *offerAnswer);
854 handleFinalResponse(msg);
870 handleFinalResponse(msg);
884 InfoLog (<<
"Failure: 2xx with no answer: " << msg.
brief());
897 InfoLog (<<
"Failure: error response: " << msg.
brief());
911 WarningLog (<<
"Invalid UPDATE with offer received in early state with pending offer: " << msg.
brief());
912 auto response = std::make_shared<SipMessage>();
930 auto response = std::make_shared<SipMessage>();
942 WarningLog (<<
"Don't know what this is : " << msg);
948ClientInviteSession::dispatchAnswered (
const SipMessage& msg)
953 switch (
toEvent(msg, offerAnswer.get()))
977 InfoLog (<<
"Failure: error response: " << msg.
brief());
993 WarningLog (<<
"Don't know what this is : " << msg);
1000ClientInviteSession::dispatchEarlyWithOffer (
const SipMessage& msg)
1005 switch (
toEvent(msg, offerAnswer.get()))
1008 handleProvisional(msg);
1009 sendPrackIfNeeded(msg);
1015 InfoLog (<<
"Failure: no answer sent: " << msg.
brief());
1028 InfoLog (<<
"Failure: error response: " << msg.
brief());
1041 WarningLog (<<
"Invalid UPDATE with offer received in early state with pending offer: " << msg.
brief());
1042 auto response = std::make_shared<SipMessage>();
1052 auto response = std::make_shared<SipMessage>();
1061 WarningLog (<<
"Don't know what this is : " << msg);
1067ClientInviteSession::dispatchSentAnswer (
const SipMessage& msg)
1072 switch (
toEvent(msg, offerAnswer.get()))
1081 handleFinalResponse(msg);
1090 handleFinalResponse(msg);
1109 handleProvisional(msg);
1110 sendPrackIfNeeded(msg);
1119 InfoLog (<<
"Failure: error response: " << msg.
brief());
1133 WarningLog (<<
"Don't know what this is : " << msg);
1139ClientInviteSession::dispatchQueuedUpdate (
const SipMessage& msg)
1144 switch (
toEvent(msg, offerAnswer.get()))
1162 auto update = std::make_shared<SipMessage>();
1168 handleFinalResponse(msg);
1177 handleFinalResponse(msg);
1196 handleProvisional(msg);
1197 sendPrackIfNeeded(msg);
1206 InfoLog (<<
"Failure: error response: " << msg.
brief());
1220 WarningLog (<<
"Don't know what this is : " << msg);
1228ClientInviteSession::dispatchEarlyWithAnswer (
const SipMessage& msg)
1233 switch (
toEvent(msg, offerAnswer.get()))
1240 handleProvisional(msg);
1241 sendPrackIfNeeded(msg);
1247 handleFinalResponse(msg);
1256 handleFinalResponse(msg);
1280 auto response = std::make_shared<SipMessage>();
1292 InfoLog (<<
"Failure: error response: " << msg.
brief());
1318 WarningLog (<<
"Don't know what this is : " << msg);
1324ClientInviteSession::dispatchSentUpdateEarly (
const SipMessage& msg)
1329 switch (
toEvent(msg, offerAnswer.get()))
1341 auto response = std::make_shared<SipMessage>();
1350 auto response = std::make_shared<SipMessage>();
1373 InfoLog (<<
"Failure: error response: " << msg.
brief());
1384 WarningLog (<<
"Don't know what this is : " << msg);
1390ClientInviteSession::dispatchSentUpdateEarlyGlare (
const SipMessage& msg)
1395 switch (
toEvent(msg, offerAnswer.get()))
1400 dispatchEarlyWithAnswer(msg);
1417 InfoLog (<<
"Failure: error response: " << msg.
brief());
1425 WarningLog (<<
"Don't know what this is : " << msg);
1431ClientInviteSession::dispatchReceivedUpdateEarly(
const SipMessage& msg)
1435 switch (
toEvent(msg, offerAnswer.get()))
1442 auto u500 = std::make_shared<SipMessage>();
1450 WarningLog (<<
"Don't know what this is : " << msg);
1453 WarningLog (<<
"Ignoring message received in ReceivedUpdateEarly: " << msg);
1457ClientInviteSession::dispatchCancelled (
const SipMessage& msg)
1462 switch (
toEvent(msg, offerAnswer.get()))
1485 mCancelledTimerSeq++;
1497 std::shared_ptr<SipMessage> rsp(
new SipMessage);
1507ClientInviteSession::isBadRseq(
const SipMessage& msg)
1510 if (msg.
method() == INVITE && code > 100 && code < 200)
1515 unsigned int rseq = (
unsigned int) msg.
header(h_RSeq).value();
1516 unsigned int lastRseq = (
unsigned int) mRelRespInfo.
rSequence();
1518 if (rseq == lastRseq)
1520 DebugLog(<<
"Discarding reliable 1xx retranmission with rseq " << rseq);
1523 else if (lastRseq != 0 && rseq > lastRseq + 1)
1525 DebugLog(<<
"Discarding out of order reliable 1xx with rseq " << rseq);
1539 if (
mDum.mDialogEventStateManager)
1549 if (
mDum.mDialogEventStateManager)
1559 if (
mDum.mDialogEventStateManager)
1573 mDum.mDialogEventStateManager->onTerminated(
mDialog, msg, reason);
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
std::shared_ptr< SipMessage > getLastRequest() const noexcept
The abstract base-class for all exceptions thrown by resip code.
BaseUsageHandle getBaseHandle() const
DialogUsageManager & mDum
ClientInviteSession(DialogUsageManager &dum, Dialog &dialog, std::shared_ptr< SipMessage > request, const Contents *initialOffer, DialogUsageManager::EncryptionLevel level, ServerSubscriptionHandle serverSub=ServerSubscriptionHandle::NotValid())
ClientInviteSessionHandle getHandle()
const Contents & getEarlyMedia() const
void reject(int statusCode, WarningCategory *warning=nullptr) override
Rejects an offer at the SIP level.
void provideAnswer(const Contents &answer) override
Similar to provideOffer - called to set the answer to be signaled to the peer.
void provideOffer(const Contents &offer) override
Called to set the offer that will be used in the next message that sends an offer.
Base class for all SIP body types.
virtual Contents * clone() const =0
returns a copy of a Contents object
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
BaseCreator * getCreator() const noexcept
std::shared_ptr< UserProfile > getUserProfile() const
virtual void send(std::shared_ptr< SipMessage > msg)
dcm! – kill typedef std::list<DialogId> DialogIdSet;
void makeRequest(SipMessage &request, MethodTypes method, bool incrementCSeq=true)
void makeResponse(SipMessage &response, const SipMessage &request, int responseCode)
static void setOutgoingEncryptionLevel(SipMessage &message, DialogUsageManager::EncryptionLevel level)
virtual void onOfferRejected(InviteSessionHandle, const SipMessage *msg)=0
called if an offer in a UPDATE or re-INVITE was rejected - not real useful.
virtual void terminate(ClientInviteSessionHandle h)
called when an early dialog decides it wants to terminate the dialog.
virtual void onForkDestroyed(ClientInviteSessionHandle)=0
called when a fork that was created through a 1xx never receives a 2xx because another fork answered ...
virtual void onAnswer(InviteSessionHandle, const SipMessage &msg, const SdpContents &)=0
called when an answer is received - has nothing to do with user answering the call
virtual void onEarlyMedia(ClientInviteSessionHandle, const SipMessage &, const SdpContents &)=0
called when an in-dialog provisional response is received that contains a body
virtual void onProvisional(ClientInviteSessionHandle, const SipMessage &)=0
called when dialog enters the Early state - typically after getting 18x
virtual void onRedirected(ClientInviteSessionHandle, const SipMessage &msg)=0
called when a 3xx with valid targets is encountered in an early dialog This is different then getti...
virtual void onStaleCallTimeout(ClientInviteSessionHandle h)
UAC gets no final response within the stale call timeout (default is 3 minutes).
virtual void onTerminated(InviteSessionHandle, InviteSessionHandler::TerminatedReason reason, const SipMessage *related=0)=0
virtual void onOffer(InviteSessionHandle, const SipMessage &msg, const SdpContents &)=0
called when an offer is received - must send an answer soon after this
virtual void onNewSession(ClientInviteSessionHandle, InviteSession::OfferAnswerType oat, const SipMessage &msg)=0
called when an initial INVITE or the intial response to an outoing invite
TerminatedReason
called when an dialog enters the terminated state - this can happen after getting a BYE,...
virtual void onFailure(ClientInviteSessionHandle, const SipMessage &msg)=0
Received a failure response from UAS.
virtual void onConnected(ClientInviteSessionHandle, const SipMessage &msg)=0
called when a dialog initiated as a UAC enters the connected state
Base class for class ClientInviteSession and class ServerInviteSession.
std::unique_ptr< Contents > getOfferAnswer(const SipMessage &msg)
void transition(State target)
void setCurrentLocalOfferAnswer(const SipMessage &msg)
std::shared_ptr< SipMessage > sendBye()
virtual void reject(int statusCode, WarningCategory *warning=0)
Rejects an offer at the SIP level.
std::unique_ptr< Contents > mProposedRemoteOfferAnswer
std::unique_ptr< Contents > mProposedLocalOfferAnswer
std::unique_ptr< Contents > mCurrentLocalOfferAnswer
std::shared_ptr< SipMessage > mLastRemoteSessionModification
std::shared_ptr< SipMessage > mLastLocalSessionModification
virtual void end() override
static std::unique_ptr< Contents > makeOfferAnswer(const Contents &offerAnswer)
DialogUsageManager::EncryptionLevel mProposedEncryptionLevel
void storePeerCapabilities(const SipMessage &msg)
InviteSessionHandle getSessionHandle()
virtual void provideAnswer(const Contents &answer)
Similar to provideOffer - called to set the answer to be signaled to the peer.
void handleSessionTimerResponse(const SipMessage &msg)
void dispatchMessage(const SipMessage &msg)
@ UAC_ReceivedUpdateEarly
@ UAC_SentUpdateEarlyGlare
static void setOfferAnswer(SipMessage &msg, const Contents &offerAnswer, const Contents *alternative=0)
std::unique_ptr< Contents > mCurrentRemoteOfferAnswer
void dispatchInfo(const SipMessage &msg)
void dispatch(const SipMessage &msg) override
Event toEvent(const SipMessage &msg, const Contents *offeranswer)
void dispatchBye(const SipMessage &msg)
bool isTerminated() const
DialogUsageManager::EncryptionLevel getEncryptionLevel(const SipMessage &msg)
bool isReliable(const SipMessage &msg) const
virtual void provideOffer(const Contents &offer)
Called to set the offer that will be used in the next message that sends an offer.
static Data toData(State state)
std::shared_ptr< SipMessage > sendAck(const Contents *answer=0)
ParserContainer< Token > mUserEndReasons
DialogUsageManager::EncryptionLevel mCurrentEncryptionLevel
virtual Brief brief() const
return a facet for brief encoding of message
Container class for ParserCategory, used by SipMessage to represent multi-valued headers (Contact,...
unsigned int & rSequence()
unsigned int & cSequence()
static int getRandom()
Returns a postive integer (31 bits) of randomness.
void end(TerminateReason reason, const Contents *document=0, int retryAfter=0)
std::shared_ptr< SipMessage > update(const Contents *document)
void send(std::shared_ptr< SipMessage > msg) override
SIP body type for holding SipFrag contents (MIME content-type message/sipfrag).
Represents a SIP message.
bool isRequest() const
Returns true if message is a request, false otherwise.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool isResponse() const
Returns true if message is a response, false otherwise.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
resip::MethodTypes method() const
returns the method type of the message
Represents the "warning-value" element in the RFC 3261 grammar.
This file is used to handle compatibility fixes/tweaks so reSIProcate can function on multiple platfo...
dcm! – add UnusedChecking(_enum) below;
StatusLineType h_StatusLine
Handle< ClientInviteSession > ClientInviteSessionHandle
RequestLineType h_RequestLine