MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / makeRegisterMsg

Method makeRegisterMsg

SIP/SIPBase.cpp:456–494  ·  view source on GitHub ↗

We wrap our REGISTER messages inside a dialog object, even though it is technically not a dialog.

Source from the content-addressed store, hash-verified

454
455// We wrap our REGISTER messages inside a dialog object, even though it is technically not a dialog.
456SipMessage *SipBase::makeRegisterMsg(DialogType wMethod, const L3LogicalChannel* chan, string RAND, const FullMobileId &msid, const char *SRES)
457{
458 // TODO: We need to make a transaction here...
459 static const string registerStr("REGISTER");
460 // The request URI is special for REGISTER;
461 string reqUri = string("sip:") + proxyIP();
462 // We formerly allocated a new Dialog for each REGISTER message so the IMSI was stashed in the dialog, and localSipUri() worked.
463 //SipPreposition myUri(localSipUri());
464 string username = msid.fmidUsername();
465 // RFC3261 is somewhat contradictory on the From-tag and To-tag.
466 // The documentation for 'from' says the from-tag is always included.
467 // The examples in 24.1 show a From-tag but no To-tag.
468 // The To-tag includes the optional <>, and Paul at null team incorrectly thought the <> were required,
469 // so we will include them as that appears to be common practice.
470 string myUriString = makeUri(username,dsPeer()->mipName,0); // The port, if any, is already in mipName.
471 //string fromUriString = makeUriWithTag(username,dsPeer()->mipName,make_tag()); // The port, if any, is already in mipName.
472 SipPreposition toHeader("",myUriString,"");
473 SipPreposition fromHeader("",myUriString,make_tag());
474 dsNextCSeq(); // Advance CSeqNum.
475 SipMessage *msg = makeRequest(registerStr,reqUri,username,&toHeader,&fromHeader,make_branch());
476
477 // Replace the Contact header so we can set the expires option. What a botched up spec.
478 // Replace the P-Preferred-Identity
479 unsigned expires;
480 if (wMethod == SIPDTRegister ) {
481 expires = 60*gConfig.getNum("SIP.RegistrationPeriod");
482 if (SRES && strlen(SRES)) {
483 msg->msmAuthorizationValue = format("Digest, nonce=%s, uri=%s, response=%s",RAND.c_str(),msid.mImsi.c_str(),SRES);
484 }
485 } else if (wMethod == SIPDTUnregister ) {
486 expires = 0;
487 } else { assert(0); }
488 // We use myURI instead of localContact because the SIPDialog for REGISTER is shared by all REGISTER
489 // users and does not contain the personal info for this user.
490 //msg->msmContactValue = format("<%s>;expires=%u",myUriString.c_str(),expires);
491 msg->msmContactValue = localContact(username,expires);
492 writePrivateHeaders(msg,chan);
493 return msg;
494}
495
496
497

Callers 1

startRegisterFunction · 0.80

Calls 5

makeUriFunction · 0.85
make_tagFunction · 0.85
make_branchFunction · 0.85
writePrivateHeadersFunction · 0.85
fmidUsernameMethod · 0.80

Tested by

no test coverage detected