Definition in file cx.c.
#include "cx.h"
#include "../tm/tm_load.h"
#include "cx_avp.h"
#include "sip.h"
#include "registrar_storage.h"
#include "registrar_parser.h"
#include "registration.h"
#include "ims_pm_scscf.h"
Go to the source code of this file.
Functions | |
| int | CxAnswerHandler (AAAMessage *response, AAATransaction *t) |
| Handler for incoming Diameter answers. | |
| int | CxFailureHandler (AAATransaction *t, int reason) |
| Handler for incoming Diameter failures This is not used as all diameter failures are handled transactionaly. | |
| AAAMessage * | CxRequestHandler (AAAMessage *request, void *param) |
| Handler for Diameter incoming requests Not used now as here there are no expected incoming requests. | |
| AAAMessage * | Cx_MAR (struct sip_msg *msg, str public_identity, str private_identity, unsigned int count, str algorithm, str authorization, str server_name, str realm) |
| Create and send a Multimedia-Authentication-Request and returns the Answer received for it. | |
| AAAMessage * | Cx_SAR (struct sip_msg *msg, str public_identity, str private_identity, str server_name, str realm, int assignment_type, int data_available) |
| Create and send a Server-Assignment-Request and returns the Answer received for it. | |
| AAAMessage * | Cx_RTA (AAAMessage *rtr) |
| Process a Registration Termination Request and return the Answer for it. | |
| AAAMessage * | Cx_PPA (AAAMessage *ppr) |
| Process a Push Profile Request and return the Answer for it. | |
Variables | |
| tm_binds | tmb |
| Structure with pointers to tm funcs. | |
| cdp_binds | cdpb |
| Structure with pointers to cdp funcs. | |
| str | scscf_forced_hss_peer_str |
| FQDN of the forced Diameter Peer (HSS). | |
| int | r_hash_size |
| records tables parameters | |
| r_hash_slot * | registrar |
| the contacts | |
| static str | s_empty = {0,0} |
| str | auth_scheme_types [] |
| int CxAnswerHandler | ( | AAAMessage * | response, | |
| AAATransaction * | t | |||
| ) |
Handler for incoming Diameter answers.
This is not used as all diameter answers are handled transactionaly
| response | - received response | |
| t | - transaction |
Definition at line 81 of file cx.c.
References _message_t::commandCode, and M_NAME.
00082 { 00083 #ifdef WITH_IMS_PM 00084 ims_pm_diameter_answer(response); 00085 #endif 00086 switch(response->commandCode){ 00087 default: 00088 LOG(L_ERR,"ERR:"M_NAME":CxAnswerHandler: Unkown Command Code %d\n", 00089 response->commandCode); 00090 } 00091 return 1; 00092 }
| int CxFailureHandler | ( | AAATransaction * | t, | |
| int | reason | |||
| ) |
Handler for incoming Diameter failures This is not used as all diameter failures are handled transactionaly.
| t | - transaction | |
| reason | - failure reason |
Definition at line 101 of file cx.c.
References _AAATransaction::command_code, _AAATransaction::hash, _AAATransaction::label, and M_NAME.
00102 { 00103 LOG(L_INFO,"INF:"M_NAME":AAAFailureHandler: SIP transaction %u %u Reason %d\n", 00104 t->hash,t->label,reason); 00105 switch(t->command_code){ 00106 default: 00107 LOG(L_ERR,"ERR:"M_NAME":CxFailureHandler: Unkown Command Code %d\n", 00108 t->command_code); 00109 } 00110 return 0; 00111 }
| AAAMessage* CxRequestHandler | ( | AAAMessage * | request, | |
| void * | param | |||
| ) |
Handler for Diameter incoming requests Not used now as here there are no expected incoming requests.
| request | - the received request | |
| param | - generic pointer |
Definition at line 119 of file cx.c.
References _message_t::applicationId, _message_t::commandCode, Cx_PPA(), Cx_RTA(), IMS_Cx, IMS_PPR, IMS_RTR, is_req, and M_NAME.
00120 { 00121 if (is_req(request)){ 00122 LOG(L_INFO,"INFO:"M_NAME":CxRequestHandler(): We have received a request\n"); 00123 #ifdef WITH_IMS_PM 00124 ims_pm_diameter_request(request); 00125 #endif 00126 switch(request->applicationId){ 00127 case IMS_Cx: 00128 switch(request->commandCode){ 00129 case IMS_RTR: 00130 LOG(L_INFO,"INFO:"M_NAME":CxRequestHandler():- Received an IMS_RTR \n"); 00131 return Cx_RTA(request); 00132 break; 00133 case IMS_PPR: 00134 LOG(L_INFO,"INFO:"M_NAME":CxRequestHandler(): - Received an IMS_PPR \n"); 00135 return Cx_PPA(request); 00136 break; 00137 default : 00138 LOG(L_ERR,"ERR:"M_NAME":CxRequestHandler(): - Received unknown request for Cx command %d\n",request->commandCode); 00139 break; 00140 } 00141 break; 00142 default: 00143 LOG(L_ERR,"ERR:"M_NAME":CxRequestHandler(): - Received unknown request for app %d command %d\n", 00144 request->applicationId, 00145 request->commandCode); 00146 break; 00147 } 00148 } 00149 return 0; 00150 }
| AAAMessage* Cx_MAR | ( | struct sip_msg * | msg, | |
| str | public_identity, | |||
| str | private_identity, | |||
| unsigned int | count, | |||
| str | algorithm, | |||
| str | authorization, | |||
| str | server_name, | |||
| str | realm | |||
| ) |
Create and send a Multimedia-Authentication-Request and returns the Answer received for it.
This function retrieves authentication vectors from the HSS.
| msg | - the SIP message to send for public_identity - the public identity of the user | |
| private_identity | - the private identity of the user | |
| count | - how many authentication vectors to ask for | |
| algorithm | - for which algorithm | |
| authorization | - the authorization value | |
| server_name | - local name of the S-CSCF to save on the HSS | |
| realm | - Realm of the user |
Definition at line 169 of file cx.c.
References cdp_binds::AAACreateRequest, cdp_binds::AAACreateSession, cdp_binds::AAACreateTransaction, cdp_binds::AAADropSession, cdp_binds::AAADropTransaction, cdp_binds::AAAFreeMessage, cdp_binds::AAASendRecvMessage, cdp_binds::AAASendRecvMessageToPeer, _AAATransaction::application_id, _message_t::applicationId, AUTH_HTTP_DIGEST_MD5, auth_scheme_types, cdpb, _AAATransaction::command_code, _message_t::commandCode, Cx_add_auth_session_state(), Cx_add_destination_realm(), Cx_add_public_identity(), Cx_add_server_name(), Cx_add_sip_auth_data_item_request(), Cx_add_sip_number_auth_items(), Cx_add_user_name(), Cx_add_vendor_specific_appid(), Flag_Proxyable, _AAATransaction::hash, IMS_Cx, IMS_MAR, IMS_vendor_id_3GPP, _AAATransaction::label, M_NAME, s_empty, scscf_forced_hss_peer_str, and tmb.
Referenced by S_MAR().
00171 { 00172 AAAMessage *mar=0,*maa=0; 00173 AAASessionId sessId={0,0}; 00174 AAATransaction *trans=0; 00175 unsigned int hash=0,label=0; 00176 00177 sessId = cdpb.AAACreateSession(); 00178 trans=cdpb.AAACreateTransaction(IMS_Cx,IMS_MAR); 00179 00180 mar = cdpb.AAACreateRequest(IMS_Cx,IMS_MAR,Flag_Proxyable,&sessId); 00181 if (!mar) goto error; 00182 00183 if (!Cx_add_destination_realm(mar,realm)) goto error; 00184 00185 if (!Cx_add_vendor_specific_appid(mar,IMS_vendor_id_3GPP,IMS_Cx,0 /*IMS_Cx*/)) goto error; 00186 if (!Cx_add_auth_session_state(mar,1)) goto error; 00187 00188 if (!Cx_add_public_identity(mar,public_identity)) goto error; 00189 if (!Cx_add_user_name(mar,private_identity)) goto error; 00190 if (!Cx_add_sip_number_auth_items(mar, count)) goto error; 00191 if (algorithm.len==auth_scheme_types[AUTH_HTTP_DIGEST_MD5].len && 00192 strncasecmp(algorithm.s,auth_scheme_types[AUTH_HTTP_DIGEST_MD5].s,algorithm.len)==0) { 00193 if (!Cx_add_sip_auth_data_item_request(mar, algorithm, authorization, private_identity, realm, 00194 msg->first_line.u.request.method, server_name)) goto error; 00195 }else{ 00196 if (!Cx_add_sip_auth_data_item_request(mar, algorithm, authorization, private_identity, realm, 00197 msg->first_line.u.request.method, s_empty)) goto error; 00198 } 00199 if (!Cx_add_server_name(mar,server_name)) goto error; 00200 //TODO - add the realm also - and don't add when sending if added here 00201 00202 if (tmb.t_get_trans_ident(msg,&hash,&label)<0){ 00203 LOG(L_ERR,"INF:"M_NAME":Cx_MAR: SIP message without transaction... very strange\n"); 00204 return 0; 00205 } 00206 00207 trans->hash=hash; 00208 trans->label=label; 00209 trans->application_id=mar->applicationId; 00210 trans->command_code=mar->commandCode; 00211 00212 #ifdef WITH_IMS_PM 00213 ims_pm_diameter_request(mar); 00214 #endif 00215 if (scscf_forced_hss_peer_str.len) 00216 maa = cdpb.AAASendRecvMessageToPeer(mar,&scscf_forced_hss_peer_str); 00217 else 00218 maa = cdpb.AAASendRecvMessage(mar); 00219 #ifdef WITH_IMS_PM 00220 ims_pm_diameter_answer(maa); 00221 #endif 00222 00223 cdpb.AAADropSession(&sessId); 00224 cdpb.AAADropTransaction(trans); 00225 00226 return maa; 00227 00228 error: 00229 //free stuff 00230 if (trans) cdpb.AAADropTransaction(trans); 00231 if (sessId.s) cdpb.AAADropSession(&sessId); 00232 if (mar) cdpb.AAAFreeMessage(&mar); 00233 return 0; 00234 }
| AAAMessage* Cx_SAR | ( | struct sip_msg * | msg, | |
| str | public_identity, | |||
| str | private_identity, | |||
| str | server_name, | |||
| str | realm, | |||
| int | assignment_type, | |||
| int | data_available | |||
| ) |
Create and send a Server-Assignment-Request and returns the Answer received for it.
This function performs the Server Assignment operation.
| msg | - the SIP message to send for public_identity - the public identity of the user | |
| server_name | - local name of the S-CSCF to save on the HSS | |
| realm | - Realm of the user | |
| assignment_type | - type of the assignment | |
| data_available | - if the data is already available |
Definition at line 248 of file cx.c.
References cdp_binds::AAACreateRequest, cdp_binds::AAACreateSession, cdp_binds::AAACreateTransaction, cdp_binds::AAADropSession, cdp_binds::AAADropTransaction, cdp_binds::AAAFreeMessage, cdp_binds::AAASendRecvMessage, cdp_binds::AAASendRecvMessageToPeer, _AAATransaction::application_id, _message_t::applicationId, cdpb, _AAATransaction::command_code, _message_t::commandCode, Cx_add_auth_session_state(), Cx_add_destination_realm(), Cx_add_public_identity(), Cx_add_server_assignment_type(), Cx_add_server_name(), Cx_add_user_name(), Cx_add_userdata_available(), Cx_add_vendor_specific_appid(), Flag_Proxyable, _AAATransaction::hash, IMS_Cx, IMS_SAR, IMS_vendor_id_3GPP, _AAATransaction::label, scscf_forced_hss_peer_str, and tmb.
Referenced by SAR().
00250 { 00251 AAAMessage *sar=0,*saa=0; 00252 AAASessionId sessId={0,0}; 00253 AAATransaction *trans=0; 00254 // struct cell* t; 00255 unsigned int hash=0,label=0; 00256 00257 sessId = cdpb.AAACreateSession(); 00258 trans=cdpb.AAACreateTransaction(IMS_Cx,IMS_SAR); 00259 00260 sar = cdpb.AAACreateRequest(IMS_Cx,IMS_SAR,Flag_Proxyable,&sessId); 00261 if (!sar) goto error; 00262 00263 if (!Cx_add_destination_realm(sar,realm)) goto error; 00264 00265 if (!Cx_add_vendor_specific_appid(sar,IMS_vendor_id_3GPP,IMS_Cx,0 /*IMS_Cx*/)) goto error; 00266 if (!Cx_add_auth_session_state(sar,1)) goto error; 00267 00268 if (!Cx_add_public_identity(sar,public_identity)) goto error; 00269 if (!Cx_add_server_name(sar,server_name)) goto error; 00270 if (private_identity.len) 00271 if (!Cx_add_user_name(sar,private_identity)) goto error; 00272 if (!Cx_add_server_assignment_type(sar,assignment_type)) goto error; 00273 if (!Cx_add_userdata_available(sar,data_available)) goto error; 00274 00275 if (msg&&tmb.t_get_trans_ident(msg,&hash,&label)<0){ 00276 // it's ok cause we can call this async with a message 00277 //LOG(L_ERR,"INF:"M_NAME":Cx_MAR: SIP message without transaction... very strange\n"); 00278 //return 0; 00279 } 00280 00281 trans->hash=hash; 00282 trans->label=label; 00283 trans->application_id=sar->applicationId; 00284 trans->command_code=sar->commandCode; 00285 00286 #ifdef WITH_IMS_PM 00287 ims_pm_diameter_request(sar); 00288 #endif 00289 if (scscf_forced_hss_peer_str.len) 00290 saa = cdpb.AAASendRecvMessageToPeer(sar,&scscf_forced_hss_peer_str); 00291 else 00292 saa = cdpb.AAASendRecvMessage(sar); 00293 #ifdef WITH_IMS_PM 00294 ims_pm_diameter_answer(saa); 00295 #endif 00296 00297 cdpb.AAADropSession(&sessId); 00298 cdpb.AAADropTransaction(trans); 00299 00300 return saa; 00301 00302 error: 00303 //free stuff 00304 if (trans) cdpb.AAADropTransaction(trans); 00305 if (sessId.s) cdpb.AAADropSession(&sessId); 00306 if (sar) cdpb.AAAFreeMessage(&sar); 00307 return 0; 00308 }
| AAAMessage* Cx_RTA | ( | AAAMessage * | rtr | ) |
Process a Registration Termination Request and return the Answer for it.
| rtr | - the RTR Diameter request |
Definition at line 315 of file cx.c.
References cdp_binds::AAACreateResponse, cdp_binds::AAAGetNextAVP, AVP_IMS_Public_Identity, cdpb, Cx_add_auth_session_state(), Cx_add_result_code(), Cx_add_vendor_specific_appid(), Cx_get_next_public_identity(), Cx_get_user_name(), avp::data, DIAMETER_SUCCESS, IMS_Cx, IMS_vendor_id_3GPP, r_private_expire(), and r_public_expire().
Referenced by CxRequestHandler().
00316 { 00317 AAAMessage *rta_msg; 00318 AAA_AVP* avp; 00319 str public_id; 00320 str private_id; 00321 00322 rta_msg = cdpb.AAACreateResponse(rtr);//session ID? 00323 if (!rta_msg) return 0; 00324 00325 avp = Cx_get_next_public_identity(rtr,0,AVP_IMS_Public_Identity,IMS_vendor_id_3GPP,__FUNCTION__); 00326 if(avp==0){ 00327 private_id=Cx_get_user_name(rtr); 00328 r_private_expire(private_id); 00329 }else{ 00330 public_id=avp->data; 00331 r_public_expire(public_id); 00332 while(cdpb.AAAGetNextAVP(avp) && (avp=Cx_get_next_public_identity(rtr,cdpb.AAAGetNextAVP(avp),AVP_IMS_Public_Identity,IMS_vendor_id_3GPP,__FUNCTION__))!=0){ 00333 public_id=avp->data; 00334 r_public_expire(public_id); 00335 } 00336 } 00337 Cx_add_vendor_specific_appid(rta_msg,IMS_vendor_id_3GPP,IMS_Cx,0 /*IMS_Cx*/); 00338 Cx_add_auth_session_state(rta_msg,1); 00339 00340 /* send an RTA back to the HSS */ 00341 Cx_add_result_code(rta_msg,DIAMETER_SUCCESS); 00342 #ifdef WITH_IMS_PM 00343 ims_pm_diameter_answer(rta_msg); 00344 #endif 00345 00346 return rta_msg; 00347 }
| AAAMessage* Cx_PPA | ( | AAAMessage * | ppr | ) |
Process a Push Profile Request and return the Answer for it.
| ppr | - the PPR Diameter request |
Definition at line 355 of file cx.c.
References cdp_binds::AAACreateResponse, cdpb, Cx_add_auth_session_state(), Cx_add_result_code(), Cx_add_vendor_specific_appid(), Cx_get_charging_info(), Cx_get_user_data(), DIAMETER_SUCCESS, _r_public::hash, if, IMS_Cx, IMS_vendor_id_3GPP, M_NAME, parse_user_data(), print_user_data(), ims_service_profile::public_identities, ims_service_profile::public_identities_cnt, ims_public_identity::public_identity, r_unlock(), ims_subscription::service_profiles, ims_subscription::service_profiles_cnt, and update_r_public().
Referenced by CxRequestHandler().
00356 { 00357 AAAMessage *ppa_msg; 00358 str ppr_data; 00359 ims_subscription *imss; 00360 int i,j; 00361 r_public *pu; 00362 str ccf1,ccf2,ecf1,ecf2; 00363 00364 ppa_msg = cdpb.AAACreateResponse(ppr); 00365 if (!ppa_msg) return 0; 00366 00367 if((ppr_data=Cx_get_user_data(ppr)).len != 0){ 00368 LOG(L_INFO,"INFO:"M_NAME":Cx_PPA(): Received a User_Data PPR!\n"); 00369 imss=parse_user_data(ppr_data); 00370 print_user_data(L_ALERT,imss); 00371 00372 for(i=0;i<imss->service_profiles_cnt;i++) 00373 for(j=0;j<imss->service_profiles[i].public_identities_cnt;j++){ 00374 pu = update_r_public(imss->service_profiles[i].public_identities[j].public_identity, 00375 0,&imss,0,0,0,0); 00376 if (!pu) continue; 00377 r_unlock(pu->hash); 00378 } 00379 } 00380 else{ 00381 if (Cx_get_charging_info(ppr,&ccf1,&ccf2,&ecf1,&ecf2)){ 00382 LOG(L_INFO,"INFO:"M_NAME":Cx_PPA(): Received a Charging Info PPR - NOT IMPLEMENTED\n"); 00383 //TODO find all r_public that should be updated and update 00384 } 00385 } 00386 Cx_add_vendor_specific_appid(ppa_msg,IMS_vendor_id_3GPP,IMS_Cx,0 /*IMS_Cx*/); 00387 Cx_add_auth_session_state(ppa_msg,1); 00388 00389 Cx_add_result_code(ppa_msg,DIAMETER_SUCCESS); 00390 #ifdef WITH_IMS_PM 00391 ims_pm_diameter_answer(ppa_msg); 00392 #endif 00393 return ppa_msg; 00394 }
FQDN of the forced Diameter Peer (HSS).
Definition at line 166 of file mod.c.
Referenced by Cx_MAR(), Cx_SAR(), and mod_init().
| int r_hash_size |
| str auth_scheme_types[] |
Definition at line 101 of file registration.c.
Referenced by Cx_MAR(), get_auth_scheme_type(), S_challenge(), and S_is_authorized().
1.5.2