registration.c File Reference


Detailed Description

Interrogating-CSCF - User-Authorization Operations.

Author:
Dragos Vingarzan vingarzan -at- fokus dot fraunhofer dot de

Definition in file registration.c.

#include <stdlib.h>
#include "registration.h"
#include "../../mem/shm_mem.h"
#include "../../dset.h"
#include "mod.h"
#include "sip.h"
#include "cx.h"
#include "cx_avp.h"

Go to the source code of this file.

Functions

int I_UAR (struct sip_msg *msg, char *str1, char *str2)
 Perform User Authorization Request.
int I_UAA (struct sip_msg *msg, AAAMessage *uaa)
 Process a UAA.

Variables

tm_binds tmb
 Structure with pointers to tm funcs.
cdp_binds cdpb
 < link to the stateless reply function in sl module Structure with pointers to cdp funcs


Function Documentation

int I_UAR ( struct sip_msg *  msg,
char *  str1,
char *  str2 
)

Perform User Authorization Request.

creates and send the user authorization query

Parameters:
msg - the SIP message
str1 - the realm
str2 - if to do capabilities
Returns:
true if OK, false if not

Definition at line 80 of file registration.c.

References cdp_binds::AAAFreeMessage, AVP_IMS_UAR_DE_REGISTRATION, AVP_IMS_UAR_REGISTRATION, AVP_IMS_UAR_REGISTRATION_AND_CAPABILITIES, cdpb, cscf_get_max_expires(), cscf_get_private_identity(), cscf_get_public_identity(), cscf_get_realm_from_ruri(), cscf_get_visited_network_id(), cscf_reply_transactional(), CSCF_RETURN_BREAK, CSCF_RETURN_FALSE, Cx_UAR(), I_UAA(), M_NAME, MSG_400_NO_PRIVATE, MSG_400_NO_PUBLIC, MSG_400_NO_VISITED, and MSG_480_DIAMETER_ERROR.

00081 {
00082     int result=CSCF_RETURN_FALSE;
00083     str private_identity,public_identity,visited_network_id;
00084     int authorization_type=AVP_IMS_UAR_REGISTRATION;    
00085     int expires=3600;
00086     struct hdr_field *hdr ;
00087     str realm;
00088     AAAMessage* uaa;
00089     
00090     realm = cscf_get_realm_from_ruri(msg);
00091     
00092     LOG(L_DBG,"DBG:"M_NAME":I_UAR: Starting ... <%.*s>\n",realm.len,realm.s);
00093     /* check if we received what we should */
00094     if (msg->first_line.type!=SIP_REQUEST) {
00095         LOG(L_ERR,"ERR:"M_NAME":I_UAR: The message is not a request\n");
00096         goto done;
00097     }
00098     if (msg->first_line.u.request.method.len!=8||
00099         memcmp(msg->first_line.u.request.method.s,"REGISTER",8)!=0)
00100     {
00101         LOG(L_ERR,"ERR:"M_NAME":I_UAR: The method is not a REGISTER\n");
00102         goto done;      
00103     }
00104     
00105     /* extract data from message */
00106     private_identity=cscf_get_private_identity(msg,realm);
00107     if (!private_identity.len) {
00108         LOG(L_ERR,"ERR:"M_NAME":I_UAR: Private Identity not found, responding with 400\n");
00109         cscf_reply_transactional(msg,400,MSG_400_NO_PRIVATE);
00110         result=CSCF_RETURN_BREAK;
00111         goto done;      
00112     }
00113     
00114     public_identity=cscf_get_public_identity(msg);
00115     if (!public_identity.len) {
00116         LOG(L_ERR,"ERR:"M_NAME":I_UAR: Public Identity not found, responding with 400\n");
00117         cscf_reply_transactional(msg,400,MSG_400_NO_PUBLIC);
00118         result=CSCF_RETURN_BREAK;
00119         goto done;      
00120     }
00121     
00122     visited_network_id=cscf_get_visited_network_id(msg , &hdr);
00123     if (!visited_network_id.len) {
00124         LOG(L_ERR,"ERR:"M_NAME":I_UAR: Visited Network Identity not found, responding with 400\n");
00125         cscf_reply_transactional(msg,400,MSG_400_NO_VISITED);
00126         result=CSCF_RETURN_BREAK;
00127         goto done;      
00128     }
00129     
00130     
00131     if (atoi(str1)) authorization_type=AVP_IMS_UAR_REGISTRATION_AND_CAPABILITIES;
00132     else {
00133         expires = cscf_get_max_expires(msg);
00134         if (expires == 0) authorization_type=AVP_IMS_UAR_DE_REGISTRATION;
00135     }
00136     
00137     uaa = Cx_UAR(msg,private_identity,public_identity,visited_network_id, 
00138                 authorization_type,realm);
00139     if (!uaa){
00140         LOG(L_ERR,"ERR:"M_NAME":I_UAR: Error creating/sending UAR or UAR time-out\n");
00141         cscf_reply_transactional(msg,480,MSG_480_DIAMETER_ERROR);
00142         result=CSCF_RETURN_BREAK;
00143         goto done;      
00144     }
00145 
00146     result = I_UAA(msg,uaa);    
00147     if (uaa) cdpb.AAAFreeMessage(&uaa);
00148     return result;
00149 done:   
00150     LOG(L_DBG,"DBG:"M_NAME":I_UAR: ... Done\n");
00151     return result;  
00152 }

int I_UAA ( struct sip_msg *  msg,
AAAMessage uaa 
)

Process a UAA.

Called from the Cx_UAA handler when the UAA is received

Parameters:
msg - the original SIP message retrieved from the transaction
uaa - the UAA diameter answer received from the HSS

Definition at line 160 of file registration.c.

References AAA_AUTHORIZATION_REJECTED, AAA_SUCCESS, AAA_UNABLE_TO_COMPLY, add_scscf_list(), cscf_get_call_id(), cscf_reply_transactional(), CSCF_RETURN_BREAK, CSCF_RETURN_TRUE, Cx_get_capabilities(), Cx_get_experimental_result_code(), Cx_get_result_code(), Cx_get_server_name(), I_get_capab_ordered(), MSG_403_AUTHORIZATION_REJECTED, MSG_403_IDENTITIES_DONT_MATCH, MSG_403_IDENTITY_NOT_REGISTERED, MSG_403_ROAMING_NOT_ALLOWED, MSG_403_UNABLE_TO_COMPLY, MSG_403_UNKOWN_EXPERIMENTAL_RC, MSG_403_UNKOWN_RC, MSG_403_USER_UNKNOWN, MSG_480_DIAMETER_MISSING_AVP, MSG_480_DIAMETER_TIMEOUT, MSG_500_ERROR_SAVING_LIST, MSG_600_EMPTY_LIST, RC_IMS_DIAMETER_ERROR_IDENTITIES_DONT_MATCH, RC_IMS_DIAMETER_ERROR_IDENTITY_NOT_REGISTERED, RC_IMS_DIAMETER_ERROR_ROAMING_NOT_ALLOWED, RC_IMS_DIAMETER_ERROR_USER_UNKNOWN, RC_IMS_DIAMETER_FIRST_REGISTRATION, RC_IMS_DIAMETER_SERVER_SELECTION, and RC_IMS_DIAMETER_SUBSEQUENT_REGISTRATION.

Referenced by I_UAR().

00161 {
00162     int rc=-1,experimental_rc=-1;
00163     str server_name;
00164     int *m_capab=0,m_capab_cnt=0;
00165     int *o_capab=0,o_capab_cnt=0;
00166     str *p_server_names=0;
00167     int p_server_names_cnt=0;
00168     scscf_entry *list=0;
00169     str call_id;
00170     
00171     if (!uaa){
00172         //TODO - add the warning code 99 in the reply   
00173         cscf_reply_transactional(msg,480,MSG_480_DIAMETER_TIMEOUT);     
00174         return CSCF_RETURN_BREAK;
00175     }
00176     
00177     if (!Cx_get_result_code(uaa,&rc)&&
00178         !Cx_get_experimental_result_code(uaa,&experimental_rc))
00179     {
00180         cscf_reply_transactional(msg,480,MSG_480_DIAMETER_MISSING_AVP);     
00181         return CSCF_RETURN_BREAK;           
00182     }
00183     
00184     switch(rc){
00185         case -1:
00186             switch(experimental_rc){
00187                 case RC_IMS_DIAMETER_ERROR_USER_UNKNOWN:
00188                     cscf_reply_transactional(msg,403,MSG_403_USER_UNKNOWN);     
00189                     return CSCF_RETURN_BREAK;           
00190                     break;
00191                 case RC_IMS_DIAMETER_ERROR_IDENTITIES_DONT_MATCH:
00192                     cscf_reply_transactional(msg,403,MSG_403_IDENTITIES_DONT_MATCH);        
00193                     return CSCF_RETURN_BREAK;           
00194                     break;
00195                 case RC_IMS_DIAMETER_ERROR_ROAMING_NOT_ALLOWED:
00196                     cscf_reply_transactional(msg,403,MSG_403_ROAMING_NOT_ALLOWED);      
00197                     return CSCF_RETURN_BREAK;           
00198                     break;
00199                 case RC_IMS_DIAMETER_ERROR_IDENTITY_NOT_REGISTERED:
00200                     cscf_reply_transactional(msg,403,MSG_403_IDENTITY_NOT_REGISTERED);      
00201                     return CSCF_RETURN_BREAK;           
00202                     break;
00203                  
00204                 case RC_IMS_DIAMETER_FIRST_REGISTRATION:
00205                     goto success;
00206                 case RC_IMS_DIAMETER_SUBSEQUENT_REGISTRATION:
00207                     goto success;
00208                     break;
00209                 case RC_IMS_DIAMETER_SERVER_SELECTION:
00210                     goto success;
00211                     break;
00212                 
00213                 default:
00214                     cscf_reply_transactional(msg,403,MSG_403_UNKOWN_EXPERIMENTAL_RC);       
00215                     return CSCF_RETURN_BREAK;           
00216             }
00217             break;
00218         
00219         case AAA_AUTHORIZATION_REJECTED:
00220             cscf_reply_transactional(msg,403,MSG_403_AUTHORIZATION_REJECTED);       
00221             return CSCF_RETURN_BREAK;           
00222             break;
00223         case AAA_UNABLE_TO_COMPLY:
00224             cscf_reply_transactional(msg,403,MSG_403_UNABLE_TO_COMPLY);     
00225             return CSCF_RETURN_BREAK;           
00226             break;
00227                 
00228         case AAA_SUCCESS:
00229             goto success;           
00230             break;
00231                         
00232         default:
00233             cscf_reply_transactional(msg,403,MSG_403_UNKOWN_RC);        
00234             return CSCF_RETURN_BREAK;           
00235     }
00236     
00237 success:
00238     server_name = Cx_get_server_name(uaa);
00239     Cx_get_capabilities(uaa,&m_capab,&m_capab_cnt,&o_capab,&o_capab_cnt,&p_server_names,&p_server_names_cnt);
00240 
00241     list = I_get_capab_ordered(server_name,m_capab,m_capab_cnt,o_capab,o_capab_cnt,p_server_names,p_server_names_cnt,0);
00242     if (m_capab) shm_free(m_capab);
00243     if (o_capab) shm_free(o_capab);
00244     if (p_server_names) shm_free(p_server_names);
00245 
00246     if (!list) {
00247         cscf_reply_transactional(msg,600,MSG_600_EMPTY_LIST);   
00248         return CSCF_RETURN_BREAK;
00249     }
00250     call_id = cscf_get_call_id(msg,0);
00251     if (!call_id.len||!add_scscf_list(call_id,list)){
00252         cscf_reply_transactional(msg,500,MSG_500_ERROR_SAVING_LIST);    
00253         return CSCF_RETURN_BREAK;
00254     }
00255     //print_s_list(L_ERR);
00256     return CSCF_RETURN_TRUE;;
00257 }


Variable Documentation

struct tm_binds tmb

Structure with pointers to tm funcs.

Definition at line 257 of file mod.c.

struct cdp_binds cdpb

< link to the stateless reply function in sl module Structure with pointers to cdp funcs

Definition at line 258 of file mod.c.


Generated on Sat Sep 6 04:17:51 2008 for Open IMS Core CSCFs by  doxygen 1.5.2