|
reSIProcate/stack
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include <iostream> 00006 #include "resip/stack/DeprecatedDialog.hxx" 00007 #include "resip/stack/SipMessage.hxx" 00008 #include "resip/stack/Uri.hxx" 00009 #include "resip/stack/NameAddr.hxx" 00010 #include "resip/stack/Helper.hxx" 00011 #include "rutil/Logger.hxx" 00012 #include "rutil/Inserter.hxx" 00013 #include "rutil/WinLeakCheck.hxx" 00014 00015 using namespace resip; 00016 00017 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00018 00019 00020 DeprecatedDialog::DeprecatedDialog(const NameAddr& localContact) 00021 : mContact(localContact), 00022 mCreated(false), 00023 mEarly(false), 00024 mRouteSet(), 00025 mRemoteTarget(), 00026 mRemoteSequence(0), 00027 mRemoteEmpty(true), 00028 mLocalSequence(0), 00029 mLocalEmpty(true), 00030 mCallId(), 00031 mLocalTag(), 00032 mRemoteTag(), 00033 mRemoteUri(), 00034 mLocalUri() 00035 { 00036 // .kw. members "secure" and "expireyTimeAbsoluteMs" are not initialized! 00037 } 00038 00039 SipMessage* 00040 DeprecatedDialog::makeResponse(const SipMessage& request, int code) 00041 { 00042 assert( code >= 100 ); 00043 00044 if ( (!mCreated) && (code < 300) && (code > 100) ) 00045 { 00046 assert (code > 100); 00047 assert (code < 300); 00048 assert(request.isRequest()); 00049 assert(request.header(h_RequestLine).getMethod() == INVITE || 00050 request.header(h_RequestLine).getMethod() == SUBSCRIBE || 00051 request.header(h_RequestLine).getMethod() == PUBLISH); 00052 00053 assert (request.header(h_Contacts).size() == 1); 00054 00055 SipMessage* response = Helper::makeResponse(request, code, mContact); 00056 if (request.exists(h_RecordRoutes)) 00057 { 00058 mRouteSet = request.header(h_RecordRoutes); 00059 } 00060 00061 if (!request.exists(h_Contacts) && request.header(h_Contacts).size() != 1) 00062 { 00063 InfoLog (<< "Request doesn't have a contact header or more than one contact, so can't create dialog"); 00064 DebugLog (<< request); 00065 throw Exception("Invalid or missing contact header in request", __FILE__,__LINE__); 00066 } 00067 00068 mRemoteTarget = request.header(h_Contacts).front(); 00069 mRemoteSequence = request.header(h_CSeq).sequence(); 00070 mRemoteEmpty = false; 00071 mLocalSequence = 0; 00072 mLocalEmpty = true; 00073 mCallId = request.header(h_CallId); 00074 response->header(h_To).param(p_tag) = Helper::computeTag(Helper::tagSize); 00075 assert (response->header(h_To).exists(p_tag)); 00076 mLocalTag = response->header(h_To).param(p_tag); // from response 00077 if (request.header(h_From).exists(p_tag)) // 2543 compat 00078 { 00079 mRemoteTag = request.header(h_From).param(p_tag); 00080 } 00081 00082 mRemoteUri = request.header(h_From); 00083 mLocalUri = request.header(h_To); 00084 00085 mDialogId = mCallId; 00086 mDialogId.param(p_toTag) = mLocalTag; 00087 mDialogId.param(p_fromTag) = mRemoteTag; 00088 00089 mEarly = (code < 200); 00090 mCreated = true; 00091 00092 return response; 00093 } 00094 else 00095 { 00096 SipMessage* response = Helper::makeResponse(request, code, mContact); 00097 if (mCreated) 00098 { 00099 response->header(h_To).param(p_tag) = mLocalTag; 00100 } 00101 //DebugLog(<< "Created response within dialog: " << *response); 00102 return response; 00103 } 00104 } 00105 00106 00107 void 00108 DeprecatedDialog::createDialogAsUAC(const SipMessage& msg) 00109 { 00110 if (!mCreated) 00111 { 00112 if(msg.isResponse()) 00113 { 00114 const SipMessage& response = msg; 00115 00116 int code = response.header(h_StatusLine).statusCode(); 00117 mEarly = (code > 100 && code < 200); 00118 00119 if (code >= 200 && code < 300) 00120 { 00121 if (!response.exists(h_Contacts) || response.header(h_Contacts).size() != 1) 00122 { 00123 InfoLog (<< "Response doesn't have a contact header or more than one contact, so can't create dialog"); 00124 DebugLog (<< response); 00125 throw Exception("Invalid or missing contact header in message", __FILE__,__LINE__); 00126 } 00127 } 00128 00129 // reverse order from response 00130 if (response.exists(h_RecordRoutes)) 00131 { 00132 mRouteSet = response.header(h_RecordRoutes).reverse(); 00133 } 00134 00135 if (response.exists(h_Contacts) && !response.header(h_Contacts).empty()) 00136 { 00137 mRemoteTarget = response.header(h_Contacts).front(); 00138 } 00139 00140 mRemoteSequence = 0; 00141 mRemoteEmpty = true; 00142 mLocalSequence = response.header(h_CSeq).sequence(); 00143 mLocalEmpty = false; 00144 mCallId = response.header(h_CallId); 00145 if ( response.header(h_From).exists(p_tag) ) // 2543 compat 00146 { 00147 mLocalTag = response.header(h_From).param(p_tag); 00148 } 00149 if ( response.header(h_To).exists(p_tag) ) // 2543 compat 00150 { 00151 mRemoteTag = response.header(h_To).param(p_tag); 00152 } 00153 mRemoteUri = response.header(h_To); 00154 mLocalUri = response.header(h_From); 00155 00156 mDialogId = mCallId; 00157 mDialogId.param(p_toTag) = mLocalTag; 00158 mDialogId.param(p_fromTag) = mRemoteTag; 00159 00160 mCreated = true; 00161 } 00162 else if (msg.isRequest() && msg.header(h_CSeq).method() == NOTIFY) 00163 { 00164 const SipMessage& notify = msg; 00165 if (notify.exists(h_RecordRoutes)) 00166 { 00167 mRouteSet = notify.header(h_RecordRoutes); 00168 } 00169 00170 if (!notify.exists(h_Contacts) && notify.header(h_Contacts).size() != 1) 00171 { 00172 InfoLog (<< "Notify doesn't have a contact header or more than one contact, so can't create dialog"); 00173 DebugLog (<< notify); 00174 throw Exception("Invalid or missing contact header in notify", __FILE__,__LINE__); 00175 } 00176 00177 mRemoteTarget = notify.header(h_Contacts).front(); 00178 mRemoteSequence = notify.header(h_CSeq).sequence(); 00179 mRemoteEmpty = false; 00180 mLocalSequence = 0; 00181 mLocalEmpty = true; 00182 mCallId = notify.header(h_CallId); 00183 if (notify.header(h_To).exists(p_tag)) 00184 { 00185 mLocalTag = notify.header(h_To).param(p_tag); 00186 } 00187 if (notify.header(h_From).exists(p_tag)) // 2543 compat 00188 { 00189 mRemoteTag = notify.header(h_From).param(p_tag); 00190 } 00191 00192 mRemoteUri = notify.header(h_From); 00193 mLocalUri = notify.header(h_To); 00194 00195 mDialogId = mCallId; 00196 mDialogId.param(p_toTag) = mLocalTag; 00197 mDialogId.param(p_fromTag) = mRemoteTag; 00198 00199 mCreated = true; 00200 mEarly = false; 00201 } 00202 } 00203 else if (msg.isResponse()) 00204 { 00205 mEarly = (msg.header(h_StatusLine).statusCode() < 200 && 00206 msg.header(h_StatusLine).statusCode() > 100); 00207 00208 // don't update target for register since contact is not a target 00209 if ( msg.header(h_CSeq).method() != REGISTER ) 00210 { 00211 targetRefreshResponse(msg); 00212 } 00213 } 00214 } 00215 00216 void 00217 DeprecatedDialog::targetRefreshResponse(const SipMessage& response) 00218 { 00219 if (response.exists(h_Contacts) && response.header(h_Contacts).size() == 1) 00220 { 00221 mRemoteTarget = response.header(h_Contacts).front(); 00222 } 00223 } 00224 00225 int 00226 DeprecatedDialog::targetRefreshRequest(const SipMessage& request) 00227 { 00228 assert (request.header(h_RequestLine).getMethod() != CANCEL); 00229 if (request.header(h_RequestLine).getMethod() != ACK) 00230 { 00231 unsigned long cseq = request.header(h_CSeq).sequence(); 00232 00233 if (mRemoteEmpty) 00234 { 00235 mRemoteSequence = cseq; 00236 mRemoteEmpty = false; 00237 } 00238 else if (cseq < mRemoteSequence) 00239 { 00240 InfoLog (<< "Got a cseq out of sequence: " << cseq << " < " << mRemoteSequence); 00241 throw Exception("out of order", __FILE__,__LINE__); 00242 } 00243 else 00244 { 00245 mRemoteSequence = cseq; 00246 } 00247 00248 if (request.exists(h_Contacts) && request.header(h_Contacts).size() == 1) 00249 { 00250 mRemoteTarget = request.header(h_Contacts).front(); 00251 } 00252 else 00253 { 00254 InfoLog (<< "Request doesn't have a contact header or more than one contact, so can't create dialog"); 00255 DebugLog (<< request); 00256 throw Exception("Invalid or missing contact header in message", __FILE__,__LINE__); 00257 } 00258 } 00259 00260 return 0; 00261 } 00262 00263 void 00264 DeprecatedDialog::updateRequest(SipMessage& request) 00265 { 00266 assert (request.isRequest()); 00267 if (mCreated) 00268 { 00269 request.header(h_RequestLine).uri() = mRemoteTarget.uri(); 00270 request.header(h_To) = mRemoteUri; 00271 if ( !mRemoteTag.empty() ) 00272 { 00273 request.header(h_To).param(p_tag) = mRemoteTag; 00274 } 00275 request.header(h_From) = mLocalUri; 00276 if ( !mLocalTag.empty() ) 00277 { 00278 request.header(h_From).param(p_tag) = mLocalTag; 00279 } 00280 request.header(h_CallId) = mCallId; 00281 request.header(h_Routes) = mRouteSet; 00282 request.header(h_Contacts).clear(); 00283 request.header(h_Contacts).push_back(mContact); 00284 copyCSeq(request); 00285 incrementCSeq(request); 00286 00287 request.header(h_MaxForwards).value() = 70; 00288 00289 Via via; 00290 via.param(p_branch); // will create the branch 00291 request.header(h_Vias).clear(); 00292 request.header(h_Vias).push_back(via); 00293 00294 request.clearForceTarget(); 00295 Helper::processStrictRoute(request); 00296 } 00297 else 00298 { 00299 DebugLog (<< "Updating a request when not in a dialog yet"); 00300 } 00301 } 00302 00303 void 00304 DeprecatedDialog::makeResponse(const SipMessage& request, SipMessage& response, int code) 00305 { 00306 assert(request.isRequest()); 00307 if ( (!mCreated) && (code < 300) && (code > 100) ) 00308 { 00309 assert(request.header(h_RequestLine).getMethod() == INVITE || 00310 request.header(h_RequestLine).getMethod() == SUBSCRIBE); 00311 assert (request.header(h_Contacts).size() == 1); 00312 00313 Helper::makeResponse(response, request, code, mContact); 00314 response.header(h_To).param(p_tag) = Helper::computeTag(Helper::tagSize); 00315 00316 if (request.exists(h_RecordRoutes)) 00317 { 00318 mRouteSet = request.header(h_RecordRoutes); 00319 } 00320 00321 if (!request.exists(h_Contacts) && request.header(h_Contacts).size() != 1) 00322 { 00323 InfoLog (<< "Request doesn't have a contact header or more than one contact, so can't create dialog"); 00324 DebugLog (<< request); 00325 throw Exception("Invalid or missing contact header in request", __FILE__,__LINE__); 00326 } 00327 00328 mRemoteTarget = request.header(h_Contacts).front(); 00329 mRemoteSequence = request.header(h_CSeq).sequence(); 00330 mRemoteEmpty = false; 00331 mLocalSequence = 0; 00332 mLocalEmpty = true; 00333 mCallId = request.header(h_CallId); 00334 assert (response.const_header(h_To).exists(p_tag)); 00335 mLocalTag = response.header(h_To).param(p_tag); // from response 00336 if (request.header(h_From).exists(p_tag)) // 2543 compat 00337 { 00338 mRemoteTag = request.header(h_From).param(p_tag); 00339 } 00340 00341 mRemoteUri = request.header(h_From); 00342 mLocalUri = request.header(h_To); 00343 00344 mDialogId = mCallId; 00345 mDialogId.param(p_toTag) = mLocalTag; 00346 mDialogId.param(p_fromTag) = mRemoteTag; 00347 00348 mEarly = (code > 100 && code < 200); 00349 00350 mCreated = true; 00351 } 00352 else 00353 { 00354 Helper::makeResponse(response, request, code, mContact); 00355 if (mCreated) 00356 { 00357 response.header(h_To).param(p_tag) = mLocalTag; 00358 mEarly = false; 00359 } 00360 } 00361 } 00362 00363 00364 SipMessage* 00365 DeprecatedDialog::makeInitialRegister(const NameAddr& registrar, const NameAddr& aor) 00366 { 00367 SipMessage* msg = Helper::makeRegister( registrar, aor, mContact ); 00368 assert( msg ); 00369 00370 mRequestUri = msg->const_header(h_RequestLine).uri(); 00371 mLocalEmpty = false; 00372 mLocalSequence = msg->const_header(h_CSeq).sequence(); 00373 mCallId = msg->const_header(h_CallId); 00374 assert(msg->const_header(h_From).exists(p_tag)); 00375 mLocalTag = msg->const_header(h_From).param(p_tag); 00376 mRemoteUri = msg->const_header(h_To); 00377 mLocalUri = msg->const_header(h_From); 00378 mCreated = true; 00379 00380 mRemoteTarget = mRemoteUri; 00381 00382 return msg; 00383 } 00384 00385 00386 SipMessage* 00387 DeprecatedDialog::makeInitialSubscribe(const NameAddr& target, const NameAddr& from) 00388 { 00389 SipMessage* msg = Helper::makeSubscribe( target, from, mContact ); 00390 assert( msg ); 00391 00392 mRequestUri = msg->const_header(h_RequestLine).uri(); 00393 mLocalEmpty = false; 00394 mLocalSequence = msg->const_header(h_CSeq).sequence(); 00395 mCallId = msg->const_header(h_CallId); 00396 assert(msg->const_header(h_From).exists(p_tag)); 00397 mLocalTag = msg->const_header(h_From).param(p_tag); 00398 mRemoteUri = msg->const_header(h_To); 00399 mLocalUri = msg->const_header(h_From); 00400 00401 return msg; 00402 } 00403 00404 00405 SipMessage* 00406 DeprecatedDialog::makeInitialPublish(const NameAddr& target, const NameAddr& from) 00407 { 00408 SipMessage* msg = Helper::makePublish( target, from, mContact ); 00409 assert( msg ); 00410 00411 mRequestUri = msg->const_header(h_RequestLine).uri(); 00412 mLocalEmpty = false; 00413 mLocalSequence = msg->const_header(h_CSeq).sequence(); 00414 mCallId = msg->const_header(h_CallId); 00415 assert(msg->const_header(h_From).exists(p_tag)); 00416 mLocalTag = msg->const_header(h_From).param(p_tag); 00417 mRemoteUri = msg->const_header(h_To); 00418 mLocalUri = msg->const_header(h_From); 00419 00420 return msg; 00421 } 00422 00423 00424 SipMessage* 00425 DeprecatedDialog::makeInitialMessage(const NameAddr& target, const NameAddr& from) 00426 { 00427 SipMessage* msg = Helper::makeMessage( target, from, mContact ); 00428 assert( msg ); 00429 00430 mRequestUri = msg->const_header(h_RequestLine).uri(); 00431 mLocalEmpty = false; 00432 mLocalSequence = msg->const_header(h_CSeq).sequence(); 00433 mCallId = msg->const_header(h_CallId); 00434 assert(msg->const_header(h_From).exists(p_tag)); 00435 mLocalTag = msg->const_header(h_From).param(p_tag); 00436 mRemoteUri = msg->const_header(h_To); 00437 mLocalUri = msg->const_header(h_From); 00438 00439 return msg; 00440 } 00441 00442 00443 SipMessage* 00444 DeprecatedDialog::makeInitialInvite(const NameAddr& target, const NameAddr& from) 00445 { 00446 SipMessage* msg = Helper::makeInvite( target, from, mContact ); 00447 assert( msg ); 00448 00449 mRequestUri = msg->const_header(h_RequestLine).uri(); 00450 mLocalEmpty = false; 00451 mLocalSequence = msg->const_header(h_CSeq).sequence(); 00452 mCallId = msg->const_header(h_CallId); 00453 assert(msg->const_header(h_From).exists(p_tag)); 00454 mLocalTag = msg->const_header(h_From).param(p_tag); 00455 mRemoteUri = msg->const_header(h_To); 00456 mLocalUri = msg->const_header(h_From); 00457 00458 return msg; 00459 } 00460 00461 00462 SipMessage* 00463 DeprecatedDialog::makeInvite() 00464 { 00465 SipMessage* request = makeRequestInternal(INVITE); 00466 incrementCSeq(*request); 00467 DebugLog(<< "DeprecatedDialog::makeInvite: " << *request); 00468 return request; 00469 } 00470 00471 SipMessage* 00472 DeprecatedDialog::makeUpdate() 00473 { 00474 SipMessage* request = makeRequestInternal(UPDATE); 00475 incrementCSeq(*request); 00476 DebugLog(<< "DeprecatedDialog::makeUpdate: " << *request); 00477 return request; 00478 } 00479 00480 SipMessage* 00481 DeprecatedDialog::makeRegister() 00482 { 00483 SipMessage* request = makeRequestInternal(REGISTER); 00484 incrementCSeq(*request); 00485 DebugLog(<< "DeprecatedDialog::makeRegister: " << *request); 00486 return request; 00487 } 00488 00489 SipMessage* 00490 DeprecatedDialog::makeSubscribe() 00491 { 00492 SipMessage* request = makeRequestInternal(SUBSCRIBE); 00493 incrementCSeq(*request); 00494 DebugLog(<< "DeprecatedDialog::makeSubscribe: " << *request); 00495 return request; 00496 } 00497 00498 SipMessage* 00499 DeprecatedDialog::makeBye() 00500 { 00501 SipMessage* request = makeRequestInternal(BYE); 00502 incrementCSeq(*request); 00503 00504 return request; 00505 } 00506 00507 00508 SipMessage* 00509 DeprecatedDialog::makeRefer(const NameAddr& referTo) 00510 { 00511 SipMessage* request = makeRequestInternal(REFER); 00512 request->header(h_ReferTo) = referTo; 00513 request->header(h_ReferredBy) = mLocalUri; 00514 incrementCSeq(*request); 00515 return request; 00516 } 00517 00518 SipMessage* 00519 DeprecatedDialog::makeNotify() 00520 { 00521 SipMessage* request = makeRequestInternal(NOTIFY); 00522 incrementCSeq(*request); 00523 return request; 00524 } 00525 00526 00527 SipMessage* 00528 DeprecatedDialog::makeOptions() 00529 { 00530 SipMessage* request = makeRequestInternal(OPTIONS); 00531 incrementCSeq(*request); 00532 return request; 00533 } 00534 00535 SipMessage* 00536 DeprecatedDialog::makePublish() 00537 { 00538 SipMessage* request = makeRequestInternal(PUBLISH); 00539 incrementCSeq(*request); 00540 return request; 00541 } 00542 00543 SipMessage* 00544 DeprecatedDialog::makeRequest(resip::MethodTypes method) 00545 { 00546 assert(method != ACK); 00547 assert(method != CANCEL); 00548 00549 SipMessage* request = makeRequestInternal(method); 00550 incrementCSeq(*request); 00551 return request; 00552 } 00553 00554 SipMessage* 00555 DeprecatedDialog::makeAck(const SipMessage& original) 00556 { 00557 SipMessage* request = makeRequestInternal(ACK); 00558 copyCSeq(*request); 00559 00560 // !dcm! should we copy the authorizations? 00561 // !jf! will this do the right thing if these headers weren't in original 00562 // we should be able to store this stuff in the DeprecatedDialog and not need to pass 00563 // in the original 00564 if (original.exists(h_ProxyAuthorizations)) 00565 { 00566 request->header(h_ProxyAuthorizations) = original.header(h_ProxyAuthorizations); 00567 } 00568 if (original.exists(h_Authorizations)) 00569 { 00570 request->header(h_Authorizations) = original.header(h_Authorizations); 00571 } 00572 request->header(h_CSeq).sequence() = original.header(h_CSeq).sequence(); 00573 return request; 00574 } 00575 00576 SipMessage* 00577 DeprecatedDialog::makeAck() 00578 { 00579 SipMessage* request = makeRequestInternal(ACK); 00580 copyCSeq(*request); 00581 return request; 00582 } 00583 00584 SipMessage* 00585 DeprecatedDialog::makeCancel(const SipMessage& request) 00586 { 00587 assert (request.header(h_Vias).size() >= 1); 00588 assert (request.header(h_RequestLine).getMethod() == INVITE); 00589 00590 SipMessage* cancel = new SipMessage; 00591 00592 cancel->header(h_RequestLine) = request.header(h_RequestLine); 00593 cancel->header(h_RequestLine).method() = CANCEL; 00594 00595 cancel->header(h_CallId) = request.header(h_CallId); 00596 cancel->header(h_To) = request.header(h_To); 00597 cancel->header(h_From) = request.header(h_From); 00598 cancel->header(h_CSeq) = request.header(h_CSeq); 00599 cancel->header(h_CSeq).method() = CANCEL; 00600 cancel->header(h_Vias).push_back(request.header(h_Vias).front()); 00601 00602 return cancel; 00603 } 00604 00605 00606 CallId 00607 DeprecatedDialog::makeReplaces() 00608 { 00609 return mDialogId; 00610 } 00611 00612 void 00613 DeprecatedDialog::clear() 00614 { 00615 mCreated = false; 00616 mEarly = false; 00617 00618 mRouteSet.clear(); 00619 mRemoteTarget = NameAddr(); 00620 mRemoteSequence = 0; 00621 mRemoteEmpty = true; 00622 mLocalSequence = 0; 00623 mLocalEmpty = true; 00624 mCallId.value() = Data::Empty; 00625 mLocalTag = Data::Empty; 00626 mRemoteTag = Data::Empty; 00627 mRemoteUri = NameAddr(); 00628 mLocalUri = NameAddr(); 00629 } 00630 00631 SipMessage* 00632 DeprecatedDialog::makeRequestInternal(MethodTypes method) 00633 { 00634 SipMessage* request = new SipMessage; 00635 RequestLine rLine(method); 00636 00637 if (!mCreated) 00638 { 00639 rLine.uri() = mRequestUri; 00640 } 00641 else 00642 { 00643 rLine.uri() = mRemoteTarget.uri(); 00644 } 00645 00646 request->header(h_RequestLine) = rLine; 00647 request->header(h_To) = mRemoteUri; 00648 if ( !mRemoteTag.empty() ) 00649 { 00650 request->header(h_To).param(p_tag) = mRemoteTag; 00651 } 00652 request->header(h_From) = mLocalUri; 00653 if ( !mLocalTag.empty() ) 00654 { 00655 request->header(h_From).param(p_tag) = mLocalTag; 00656 } 00657 request->header(h_CallId) = mCallId; 00658 request->header(h_Routes) = mRouteSet; 00659 request->header(h_Contacts).push_back(mContact); 00660 request->header(h_CSeq).method() = method; 00661 copyCSeq(*request); 00662 request->header(h_MaxForwards).value() = 70; 00663 00664 Via via; 00665 via.param(p_branch); // will create the branch 00666 request->header(h_Vias).push_front(via); 00667 00668 Helper::processStrictRoute(*request); 00669 return request; 00670 } 00671 00672 void 00673 DeprecatedDialog::copyCSeq(SipMessage& request) 00674 { 00675 if (mLocalEmpty) 00676 { 00677 mLocalSequence = 1; 00678 mLocalEmpty = false; 00679 } 00680 request.header(h_CSeq).sequence() = mLocalSequence; 00681 } 00682 00683 void 00684 DeprecatedDialog::incrementCSeq(SipMessage& request) 00685 { 00686 if (mLocalEmpty) 00687 { 00688 mLocalSequence = 1; 00689 mLocalEmpty = false; 00690 } 00691 //DebugLog ( << "mLocalSequence: " << mLocalSequence); 00692 request.header(h_CSeq).sequence() = ++mLocalSequence; 00693 } 00694 00695 EncodeStream& 00696 resip::operator<<(EncodeStream& strm, const DeprecatedDialog& d) 00697 { 00698 strm << "DeprecatedDialog: [" << d.dialogId() 00699 << " created=" << d.mCreated 00700 << ",remoteTarget=" << d.mRemoteTarget 00701 << ", routeset=" << Inserter(d.mRouteSet) 00702 << ",remoteSeq=" << d.mRemoteSequence 00703 << ",remote=" << d.mRemoteUri 00704 << ",remoteTag=" << d.mRemoteTag 00705 << ",localSeq=" << d.mLocalSequence 00706 << ",local=" << d.mLocalUri 00707 << ",localTag=" << d.mLocalTag 00708 << "]"; 00709 return strm; 00710 } 00711 00712 Data 00713 DeprecatedDialog::dialogId(const SipMessage& msg) 00714 { 00715 CallID id(msg.header(h_CallId)); 00716 if ((msg.isRequest() && msg.isExternal()) || 00717 (msg.isResponse() && !msg.isExternal())) 00718 { 00719 if (msg.header(h_To).exists(p_tag)) 00720 { 00721 id.param(p_toTag) = msg.header(h_To).param(p_tag); 00722 } 00723 if (msg.header(h_From).exists(p_tag)) 00724 { 00725 id.param(p_fromTag) = msg.header(h_From).param(p_tag); 00726 } 00727 } 00728 else 00729 { 00730 if (msg.header(h_From).exists(p_tag)) 00731 { 00732 id.param(p_toTag) = msg.header(h_From).param(p_tag); 00733 } 00734 if (msg.header(h_To).exists(p_tag)) 00735 { 00736 id.param(p_fromTag) = msg.header(h_To).param(p_tag); 00737 } 00738 } 00739 return Data::from(id); 00740 } 00741 00742 00743 const Data 00744 DeprecatedDialog::dialogId() const 00745 { 00746 return Data::from(mDialogId); 00747 } 00748 00749 00750 void 00751 DeprecatedDialog::setExpirySeconds( int secondsInFuture ) 00752 { 00753 expireyTimeAbsoluteMs = Timer::getTimeMs() + 1000*secondsInFuture; 00754 } 00755 00756 00757 int 00758 DeprecatedDialog::getExpirySeconds() 00759 { 00760 // !cj! TODO - may be bugs here when result is negative 00761 UInt64 delta = ( expireyTimeAbsoluteMs - Timer::getTimeMs() )/1000; 00762 00763 int ret = (int)delta; 00764 return ret; 00765 } 00766 00767 00768 00769 /* ==================================================================== 00770 * The Vovida Software License, Version 1.0 00771 * 00772 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00773 * 00774 * Redistribution and use in source and binary forms, with or without 00775 * modification, are permitted provided that the following conditions 00776 * are met: 00777 * 00778 * 1. Redistributions of source code must retain the above copyright 00779 * notice, this list of conditions and the following disclaimer. 00780 * 00781 * 2. Redistributions in binary form must reproduce the above copyright 00782 * notice, this list of conditions and the following disclaimer in 00783 * the documentation and/or other materials provided with the 00784 * distribution. 00785 * 00786 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00787 * and "Vovida Open Communication Application Library (VOCAL)" must 00788 * not be used to endorse or promote products derived from this 00789 * software without prior written permission. For written 00790 * permission, please contact vocal@vovida.org. 00791 * 00792 * 4. Products derived from this software may not be called "VOCAL", nor 00793 * may "VOCAL" appear in their name, without prior written 00794 * permission of Vovida Networks, Inc. 00795 * 00796 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00797 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00798 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00799 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00800 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00801 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00802 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00803 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00804 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00805 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00806 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00807 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00808 * DAMAGE. 00809 * 00810 * ==================================================================== 00811 * 00812 * This software consists of voluntary contributions made by Vovida 00813 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00814 * Inc. For more information on Vovida Networks, Inc., please see 00815 * <http://www.vovida.org/>. 00816 * 00817 */
1.7.5.1