Example #1
0
/**
 * Handler for incoming Diameter requests.
 * @param request - the received request
 * @param param - generic pointer
 * @returns the answer to this request
 * but we wont/should not recieve any request here
 */
AAAMessage* RfRequestHandler(AAAMessage *request,void *param)
{
	if (is_req(request)){		
		LOG(L_INFO,"INFO: RfRequestHandler(): We have received a request!!!\n");
		#ifdef WITH_IMS_PM
			ims_pm_diameter_request(request);
		#endif		
		switch(request->applicationId){
        	case IMS_Rf:
				switch(request->commandCode){				
					
					default :
						LOG(L_ERR,"ERR: RfRequestHandler(): - Received unknown request for Rf command %d\n",request->commandCode);
						break;	
				}
				break;
			default:
				LOG(L_ERR,"ERR: RfRequestHandler(): - Received unknown request for app %d command %d\n",
					request->applicationId,
					request->commandCode);
				break;				
		}					
	}
	return 0;		
}
Example #2
0
/**
 * Handler for incoming Diameter requests.
 * @param request - the received request
 * @param param - generic pointer
 * @returns the answer to this request
 */
AAAMessage* CxRequestHandler(AAAMessage *request,void *param)
{
	if (is_req(request)){		
		LOG(L_INFO,"INFO:"M_NAME":CxRequestHandler(): We have received a request\n");
		#ifdef WITH_IMS_PM
			ims_pm_diameter_request(request);
		#endif		
		switch(request->applicationId){
        	case IMS_Cx:
				switch(request->commandCode){				
					case IMS_RTR:
						LOG(L_INFO,"INFO:"M_NAME":CxRequestHandler():- Received an IMS_RTR \n");
						return Cx_RTA(request);
						break;
					case IMS_PPR:
						LOG(L_INFO,"INFO:"M_NAME":CxRequestHandler(): - Received an IMS_PPR \n");
						return Cx_PPA(request);
						break;
					default :
						LOG(L_ERR,"ERR:"M_NAME":CxRequestHandler(): - Received unknown request for Cx command %d\n",request->commandCode);
						break;	
				}
				break;
			default:
				LOG(L_ERR,"ERR:"M_NAME":CxRequestHandler(): - Received unknown request for app %d command %d\n",
					request->applicationId,
					request->commandCode);
				break;				
		}					
	}
	return 0;		
}
Example #3
0
/**
 * Create and send a Server-Assignment-Request and returns the Answer received for it.
 * This function performs the Server Assignment operation.
 * @param msg - the SIP message to send for
 * @parma public_identity - the public identity of the user
 * @param server_name - local name of the S-CSCF to save on the HSS
 * @param realm - Realm of the user
 * @param assignment_type - type of the assignment
 * @param data_available - if the data is already available
 * @returns the SAA
 */
AAAMessage *Cx_SAR(struct sip_msg *msg, str public_identity, str private_identity,
					str server_name,str realm,int assignment_type, int data_available)
{
	AAAMessage *sar=0,*saa=0;
	AAASession *session=0;
	AAATransaction *trans=0;
//	struct cell* t;
	unsigned int hash=0,label=0;	
	
	session = cdpb.AAACreateSession(0);
	trans=cdpb.AAACreateTransaction(IMS_Cx,IMS_SAR);

	sar = cdpb.AAACreateRequest(IMS_Cx,IMS_SAR,Flag_Proxyable,session);
	if (session) {
		cdpb.AAADropSession(session);
		session=0;
	}
	if (!sar) goto error;

	if (!Cx_add_destination_realm(sar,realm)) goto error;
		
	if (!Cx_add_vendor_specific_appid(sar,IMS_vendor_id_3GPP,IMS_Cx,0 /*IMS_Cx*/)) goto error;
	if (!Cx_add_auth_session_state(sar,1)) goto error;		
		
	if (!Cx_add_public_identity(sar,public_identity)) goto error;
	if (!Cx_add_server_name(sar,server_name)) goto error;
	if (private_identity.len)
		if (!Cx_add_user_name(sar,private_identity)) goto error;
	if (!Cx_add_server_assignment_type(sar,assignment_type)) goto error;
	if (!Cx_add_userdata_available(sar,data_available)) goto error;
	
	if (msg&&tmb.t_get_trans_ident(msg,&hash,&label)<0){	
		// it's ok cause we can call this async with a message
		//LOG(L_ERR,"INF:"M_NAME":Cx_MAR: SIP message without transaction... very strange\n");
		//return 0;
	}

	trans->hash=hash;
	trans->label=label;
	trans->application_id=sar->applicationId;
	trans->command_code=sar->commandCode;
	
	#ifdef WITH_IMS_PM
		ims_pm_diameter_request(sar);
	#endif				
	if (scscf_forced_hss_peer_str.len)
		saa = cdpb.AAASendRecvMessageToPeer(sar,&scscf_forced_hss_peer_str);
	else 
		saa = cdpb.AAASendRecvMessage(sar);
	#ifdef WITH_IMS_PM
		ims_pm_diameter_answer(saa);
	#endif				
	
	cdpb.AAADropTransaction(trans);
	
	return saa;
	
error:
	//free stuff
	if (trans) cdpb.AAADropTransaction(trans);
	if (session) cdpb.AAADropSession(session);
	if (sar) cdpb.AAAFreeMessage(&sar);
	return 0;	
}
Example #4
0
/**
 * Create and send a Multimedia-Authentication-Request and returns the Answer received for it.
 * This function retrieves authentication vectors from the HSS.
 * @param msg - the SIP message to send for
 * @parma public_identity - the public identity of the user
 * @param private_identity - the private identity of the user
 * @param count - how many authentication vectors to ask for
 * @param algorithm - for which algorithm
 * @param authorization - the authorization value
 * @param server_name - local name of the S-CSCF to save on the HSS
 * @param realm - Realm of the user
 * @returns the MAA
 */ 
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)
{
	AAAMessage *mar=0,*maa=0;
	AAASession *session=0;
	AAATransaction *trans=0;
	unsigned int hash=0,label=0;	
	
	session = cdpb.AAACreateSession(0);
	trans=cdpb.AAACreateTransaction(IMS_Cx,IMS_MAR);

	mar = cdpb.AAACreateRequest(IMS_Cx,IMS_MAR,Flag_Proxyable,session);
	if (session) {
		cdpb.AAADropSession(session);
		session=0;
	}	
	if (!mar) goto error;

	if (!Cx_add_destination_realm(mar,realm)) goto error;
		
	if (!Cx_add_vendor_specific_appid(mar,IMS_vendor_id_3GPP,IMS_Cx,0 /*IMS_Cx*/)) goto error;
	if (!Cx_add_auth_session_state(mar,1)) goto error;		
		
	if (!Cx_add_public_identity(mar,public_identity)) goto error;
	if (!Cx_add_user_name(mar,private_identity)) goto error;
	if (!Cx_add_sip_number_auth_items(mar, count)) goto error;
	if (algorithm.len==auth_scheme_types[AUTH_HTTP_DIGEST_MD5].len &&
		strncasecmp(algorithm.s,auth_scheme_types[AUTH_HTTP_DIGEST_MD5].s,algorithm.len)==0) {
		if (!Cx_add_sip_auth_data_item_request(mar, algorithm, authorization, private_identity, realm, 
			msg->first_line.u.request.method, server_name)) goto error;
	}else{
		if (!Cx_add_sip_auth_data_item_request(mar, algorithm, authorization, private_identity, realm, 
			msg->first_line.u.request.method, s_empty)) goto error;		
	}
	if (!Cx_add_server_name(mar,server_name)) goto error;
	//TODO - add the realm also - and don't add when sending if added here 
		
	if (tmb.t_get_trans_ident(msg,&hash,&label)<0){	
		LOG(L_ERR,"INF:"M_NAME":Cx_MAR: SIP message without transaction... very strange\n");
		return 0;
	}

	trans->hash=hash;
	trans->label=label;
	trans->application_id=mar->applicationId;
	trans->command_code=mar->commandCode;
	
	#ifdef WITH_IMS_PM
		ims_pm_diameter_request(mar);
	#endif				
	if (scscf_forced_hss_peer_str.len)
		maa = cdpb.AAASendRecvMessageToPeer(mar,&scscf_forced_hss_peer_str);
	else 
		maa = cdpb.AAASendRecvMessage(mar);
	#ifdef WITH_IMS_PM
		ims_pm_diameter_answer(maa);
	#endif			
	
	cdpb.AAADropTransaction(trans);
	
	return maa;
	
error:
	//free stuff
	if (trans) cdpb.AAADropTransaction(trans);
	if (session) cdpb.AAADropSession(session);
	if (mar) cdpb.AAAFreeMessage(&mar);
	return 0;	
}