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

Method sendAuthOKMessage

SIP/SIPTransaction.cpp:110–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void SipTransaction::sendAuthOKMessage(SipMessage *sipmsg)
111{
112 string imsi = sipmsg->msmTo.uriUsername(); // The To: and From: have the same value for a REGISTER message.
113 // Validate the imsi:
114 if (imsi.empty()) {
115 LOG(ERR) << "can't find imsi to store kc";
116 sendAuthFailMessage(400,"","");
117 return;
118 }
119 if (0 == strncasecmp(imsi.c_str(),"imsi",4)) {
120 // happiness
121 } else if (0 == strncasecmp(imsi.c_str(),"tmsi",4)) {
122 // TODO: In future the user name could be a TMSI.
123 LOG(ERR) << "SIP REGISTER message with TMSI not supported, userid="<<imsi;
124 sendAuthFailMessage(400,"","");
125 return;
126 } else {
127 LOG(ERR) << "SIP REGISTER message with invalid IMSI:"<<imsi<<" Message:"<<sipmsg->msmContent;
128 sendAuthFailMessage(400,"","");
129 return;
130 }
131
132 DialogAuthMessage *dmsg = new DialogAuthMessage(mstTranId, DialogState::dialogActive,200);
133 dmsg->dmPAssociatedUri = sipmsg->msmHeaders.paramFind("P-Associated-URI"); // case doesnt matter
134 dmsg->dmPAssertedIdentity = sipmsg->msmHeaders.paramFind("P-Asserted-Identity");
135
136 string authinfo = sipmsg->msmHeaders.paramFind("Authentication-Info");
137 if (! authinfo.empty()) {
138 SipParamList params;
139 parseToParams(authinfo, params);
140 dmsg->dmKc = params.paramFind("cnonce"); // This is the way SR passes the Kc.
141 } else {
142 // There will not be a cnonce if the Registrar does not know it. Dont worry about it.
143 //LOG(INFO) << "No Authenticate-Info header in SIP REGISTER response:"<<sipmsg->msmContent;
144 }
145
146 if (dmsg->dmKc.empty()) {
147 dmsg->dmKc = sipmsg->msmHeaders.paramFind("P-GSM-Kc"); // This is the way Yate passes the Kc.
148 }
149
150 WATCHF("CNONCE: imsi=%s Kc=%s\n",imsi.c_str(),dmsg->dmKc.c_str());
151 if (! dmsg->dmKc.empty()) {
152 LOG(DEBUG) << "Storing Kc:"<<LOGVAR(imsi)<<LOGVAR(dmsg->dmKc.size()); // We dont put Kc itself in the log.
153 //gTMSITable.putKc(imsi.c_str()+4, kc, pAssociatedUri, pAssertedIdentity);
154 } else {
155 LOG(NOTICE) << "No Kc in SIP REGISTER response:"<<sipmsg->msmContent;
156 }
157
158 NewTransactionTable_ttAddMessage(mstTranId,dmsg);
159}
160
161// The cause is not currently used.
162void SipTransaction::stSetDialogState(SipState newState, int code, char timer) const

Callers

nothing calls this directly

Calls 5

parseToParamsFunction · 0.85
uriUsernameMethod · 0.45
paramFindMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected