25 |
using namespace std; |
using namespace std; |
26 |
|
|
27 |
Dialog::Dialog(DialogUsageManager& dum, const SipMessage& msg, DialogSet& ds) |
Dialog::Dialog(DialogUsageManager& dum, const SipMessage& msg, DialogSet& ds) |
28 |
: mId(msg), |
: mDum(dum), |
|
mDum(dum), |
|
29 |
mDialogSet(ds), |
mDialogSet(ds), |
30 |
mClientSubscriptions(), |
mClientSubscriptions(), |
31 |
mServerSubscription(0), |
mServerSubscription(0), |
37 |
mClientOutOfDialogRequests(), |
mClientOutOfDialogRequests(), |
38 |
mServerOutOfDialogRequest(0), |
mServerOutOfDialogRequest(0), |
39 |
mType(Fake), |
mType(Fake), |
|
mCallId(msg.header(h_CallID)), |
|
40 |
mRouteSet(), |
mRouteSet(), |
41 |
mLocalContact(), |
mLocalContact(), |
42 |
mLocalCSeq(0), |
mLocalCSeq(0), |
43 |
mRemoteCSeq(0), |
mRemoteCSeq(0), |
44 |
|
mId("INVALID", "INVALID", "INVALID"), |
45 |
mRemoteTarget(), |
mRemoteTarget(), |
46 |
|
mLocalNameAddr(), |
47 |
|
mRemoteNameAddr(), |
48 |
|
mCallId(msg.header(h_CallID)), |
49 |
mDestroying(false) |
mDestroying(false) |
50 |
{ |
{ |
51 |
assert(msg.isExternal()); |
assert(msg.isExternal()); |
78 |
case INVITE: |
case INVITE: |
79 |
case SUBSCRIBE: |
case SUBSCRIBE: |
80 |
case REFER: |
case REFER: |
81 |
|
InfoLog ( << "UAS dialog ID creation, DS: " << ds.getId()); |
82 |
|
mId = DialogId(ds.getId(), request.header(h_From).param(p_tag)); |
83 |
|
mRemoteNameAddr = request.header(h_From); |
84 |
|
mLocalNameAddr = request.header(h_To); |
85 |
|
mLocalNameAddr.param(p_tag) = mId.getLocalTag(); |
86 |
if (request.exists(h_Contacts) && request.header(h_Contacts).size() == 1) |
if (request.exists(h_Contacts) && request.header(h_Contacts).size() == 1) |
87 |
{ |
{ |
88 |
const NameAddr& contact = request.header(h_Contacts).front(); |
const NameAddr& contact = request.header(h_Contacts).front(); |
113 |
mRemoteCSeq = request.header(h_CSeq).sequence(); |
mRemoteCSeq = request.header(h_CSeq).sequence(); |
114 |
mLocalCSeq = 1; |
mLocalCSeq = 1; |
115 |
|
|
116 |
|
InfoLog ( << "************** Created Dialog as UAS **************" ); |
117 |
|
InfoLog ( << "mRemoteNameAddr: " << mRemoteNameAddr ); |
118 |
|
InfoLog ( << "mLocalNameAddr: " << mLocalNameAddr ); |
119 |
|
InfoLog ( << "mLocalContact: " << mLocalContact ); |
120 |
|
InfoLog ( << "mRemoteTarget: " << mRemoteTarget ); |
121 |
} |
} |
122 |
else if (msg.isResponse()) |
else if (msg.isResponse()) |
123 |
{ |
{ |
124 |
|
mId = DialogId(msg); |
125 |
const SipMessage& response = msg; |
const SipMessage& response = msg; |
126 |
|
mRemoteNameAddr = response.header(h_To); |
127 |
|
mLocalNameAddr = response.header(h_From); |
128 |
|
|
129 |
switch (msg.header(h_CSeq).method()) |
switch (msg.header(h_CSeq).method()) |
130 |
{ |
{ |
188 |
|
|
189 |
mLocalCSeq = response.header(h_CSeq).sequence(); |
mLocalCSeq = response.header(h_CSeq).sequence(); |
190 |
mRemoteCSeq = 0; |
mRemoteCSeq = 0; |
191 |
|
InfoLog ( << "************** Created Dialog as UAC **************" ); |
192 |
|
InfoLog ( << "mRemoteNameAddr: " << mRemoteNameAddr ); |
193 |
|
InfoLog ( << "mLocalNameAddr: " << mLocalNameAddr ); |
194 |
|
InfoLog ( << "mLocalContact: " << mLocalContact ); |
195 |
|
InfoLog ( << "mRemoteTarget: " << mRemoteTarget ); |
196 |
|
|
197 |
|
|
198 |
} |
} |
199 |
mDialogSet.addDialog(this); |
mDialogSet.addDialog(this); |
667 |
rLine.uri() = mRemoteTarget.uri(); |
rLine.uri() = mRemoteTarget.uri(); |
668 |
|
|
669 |
request.header(h_RequestLine) = rLine; |
request.header(h_RequestLine) = rLine; |
670 |
request.header(h_To) = mRemoteTarget; |
request.header(h_To) = mRemoteNameAddr; |
671 |
request.header(h_To).param(p_tag) = mId.getRemoteTag(); |
// request.header(h_To).param(p_tag) = mId.getRemoteTag(); |
672 |
request.header(h_From) = mLocalContact; |
request.header(h_From) = mLocalNameAddr; |
673 |
request.header(h_From).param(p_tag) = mId.getLocalTag(); |
// request.header(h_From).param(p_tag) = mId.getLocalTag(); |
674 |
|
|
675 |
request.header(h_CallId) = mCallId; |
request.header(h_CallId) = mCallId; |
676 |
request.header(h_Routes) = mRouteSet; |
request.header(h_Routes) = mRouteSet; |
677 |
request.header(h_Contacts) = mLocalContact; |
request.remove(h_Contacts); |
678 |
|
request.header(h_Contacts).push_front(mLocalContact); |
679 |
request.header(h_CSeq).method() = method; |
request.header(h_CSeq).method() = method; |
680 |
request.header(h_MaxForwards).value() = 70; |
request.header(h_MaxForwards).value() = 70; |
681 |
|
|
696 |
{ |
{ |
697 |
request.header(h_CSeq).sequence() = ++mLocalCSeq; |
request.header(h_CSeq).sequence() = ++mLocalCSeq; |
698 |
} |
} |
699 |
|
InfoLog ( << "Dialog::makeRequest: " << request ); |
700 |
} |
} |
701 |
|
|
702 |
void |
void |