third_party_reg.c File Reference


Detailed Description

Serving-CSCF - Third party register towards AS.

Author:
Erling Klaeboe klaboe -at- colibria dot com

Definition in file third_party_reg.c.

#include "third_party_reg.h"
#include "mod.h"
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "../../parser/parse_uri.h"
#include "../../locking.h"
#include "../tm/tm_load.h"
#include "../scscf/scscf_load.h"
#include "sip.h"
#include "ims_pm.h"

Go to the source code of this file.

Functions

int isc_third_party_reg (struct sip_msg *msg, isc_match *m, isc_mark *mark)
 Handle third party registration.
int r_send_third_party_reg (r_third_party_registration *r, int expires)
 Send a third party registration.
void r_third_party_reg_response (struct cell *t, int type, struct tmcb_params *ps)
 Response callback for third party register.

Variables

tm_binds isc_tmb
 Structure with pointers to tm funcs.
str isc_my_uri
 Uri of myself to loop the message in str.
str isc_my_uri_sip
 Uri of myself to loop the message in str with leading "sip:".
int isc_expires_grace
 expires value to add to the expires in the 3rd party register to prevent expiration in AS
scscf_binds isc_scscfb
 Structure with pointers to S-CSCF funcs.
static str method = {"REGISTER",8}
static str event_hdr = {"Event: registration\r\n",21}
static str max_fwds_hdr = {"Max-Forwards: 10\r\n",18}
static str expires_s = {"Expires: ",9}
static str expires_e = {"\r\n",2}
static str contact_s = {"Contact: <",10}
static str contact_e = {">\r\n",3}
static str p_visited_network_id_s = {"P-Visited-Network-ID: ",22}
static str p_visited_network_id_e = {"\r\n",2}
static str p_access_network_info_s = {"P-Access-Network-Info: ",23}
static str p_access_network_info_e = {"\r\n",2}
static str p_charging_vector_s = {"P-Charging-Vector: ",19}
static str p_charging_vector_e = {"\r\n",2}
static str body_s = {"<ims-3gpp version=\"1\"><service-info>",36}
static str body_e = {"</service-info></ims-3gpp>",26}


Function Documentation

int isc_third_party_reg ( struct sip_msg *  msg,
isc_match m,
isc_mark mark 
)

Handle third party registration.

Parameters:
msg - the SIP REGISTER message
m - the isc_match that matched with info about where to forward it
mark - the isc_mark that should be used to mark the message
Returns:
ISC_RETURN_TRUE if allowed, ISC_RETURN_FALSE if not

Definition at line 85 of file third_party_reg.c.

References cscf_get_access_network_info(), cscf_get_charging_vector(), cscf_get_max_expires(), cscf_get_public_identity(), cscf_get_visited_network_id(), _r_third_party_reg::cv, _r_third_party_reg::from, isc_expires_grace, isc_my_uri_sip, ISC_RETURN_FALSE, ISC_RETURN_TRUE, M_NAME, _r_third_party_reg::pani, _r_third_party_reg::pvni, r_send_third_party_reg(), _r_third_party_reg::req_uri, isc_match::server_name, _r_third_party_reg::service_info, isc_match::service_info, and _r_third_party_reg::to.

Referenced by ISC_match_filter_reg().

00086 {
00087     r_third_party_registration r;
00088     int expires=0;
00089     str req_uri ={0,0};
00090     str to ={0,0};
00091     str pvni ={0,0};
00092     str pani ={0,0};
00093     str cv ={0,0};
00094 
00095     struct hdr_field *hdr;
00096 
00097     LOG(L_INFO,"INFO:"M_NAME":isc_third_party_reg: Enter\n");
00098 
00099     /* Set Request Uri to IFC matching server name */
00100     req_uri.len = m->server_name.len;
00101     req_uri.s = m->server_name.s;
00102 
00103     /* Get To header*/
00104     to = cscf_get_public_identity(msg);
00105 
00106 
00107     /*TODO - check if the min/max expires is in the acceptable limits
00108      * this does not work correctly if the user has multiple contacts
00109      * and register/deregisters them individually!!!
00110      */
00111     expires = cscf_get_max_expires(msg);
00112     
00113     /* Get P-Visited-Network-Id header */
00114     pvni = cscf_get_visited_network_id(msg, &hdr);
00115     /* Get P-Access-Network-Info header */
00116     pani = cscf_get_access_network_info(msg, &hdr);
00117     
00118     /* Get P-Charging-Vector header */
00119     /* Just forward the charging header received from P-CSCF */
00120     /* Todo: implement also according to TS 24.229, chap 5.4.1.7 */
00121     cv =   cscf_get_charging_vector(msg, &hdr);
00122 
00123     if (req_uri.s){
00124         
00125         memset(&r,0,sizeof(r_third_party_registration));
00126 
00127         r.req_uri = req_uri;
00128         r.to = to;
00129         r.from = isc_my_uri_sip;
00130         r.pvni = pvni;
00131         r.pani = pani;
00132         r.cv = cv;
00133         r.service_info = m->service_info;
00134          
00135         if (expires<=0) r_send_third_party_reg(&r,0);
00136         else r_send_third_party_reg(&r,expires+isc_expires_grace);
00137         return ISC_RETURN_TRUE;
00138     }else{
00139         return ISC_RETURN_FALSE;
00140     }   
00141 }

int r_send_third_party_reg ( r_third_party_registration r,
int  expires 
)

Send a third party registration.

Parameters:
r - the register to send for
expires - expires time
Returns:
true if OK, false if not

Definition at line 176 of file third_party_reg.c.

References body_e, body_s, contact_e, contact_s, _r_third_party_reg::cv, event_hdr, expires_e, expires_s, _r_third_party_reg::from, IMS_PM_LOG, isc_my_uri_sip, isc_tmb, M_NAME, max_fwds_hdr, method, p_access_network_info_e, p_access_network_info_s, p_charging_vector_e, p_charging_vector_s, p_visited_network_id_e, p_visited_network_id_s, _r_third_party_reg::pani, _r_third_party_reg::pvni, r_third_party_reg_response(), _r_third_party_reg::req_uri, _r_third_party_reg::service_info, STR_APPEND, and _r_third_party_reg::to.

Referenced by isc_third_party_reg().

00177 {
00178         str h={0,0};
00179         str b={0,0};
00180 
00181         LOG(L_DBG,"DBG:"M_NAME":r_send_third_party_reg: REGISTER to <%.*s>\n",
00182                 r->req_uri.len,r->req_uri.s);
00183 
00184         h.len = event_hdr.len+max_fwds_hdr.len;
00185         h.len += expires_s.len + 12 + expires_e.len;
00186 
00187         h.len += contact_s.len + isc_my_uri_sip.len + contact_e.len;
00188 
00189         if (r->pvni.len) h.len += p_visited_network_id_s.len +
00190                 p_visited_network_id_e.len + r->pvni.len;
00191 
00192         if (r->pani.len) h.len += p_access_network_info_s.len +
00193                 p_access_network_info_e.len + r->pani.len;
00194 
00195         if (r->cv.len) h.len += p_charging_vector_s.len +
00196                 p_charging_vector_e.len + r->cv.len;
00197 
00198         h.s = pkg_malloc(h.len);
00199         if (!h.s){
00200             LOG(L_ERR,"ERR:"M_NAME":r_send_third_party_reg: Error allocating %d bytes\n",h.len);
00201             h.len = 0;
00202             return 0;
00203         }
00204 
00205         h.len = 0;
00206         STR_APPEND(h,event_hdr);
00207         
00208         STR_APPEND(h,max_fwds_hdr);
00209 
00210         STR_APPEND(h,expires_s);
00211         sprintf(h.s+h.len,"%d",expires);
00212         h.len += strlen(h.s+h.len);
00213         STR_APPEND(h,expires_e);
00214 
00215         STR_APPEND(h,contact_s);
00216         STR_APPEND(h,isc_my_uri_sip);
00217         STR_APPEND(h,contact_e);
00218 
00219         if (r->pvni.len) {
00220                 STR_APPEND(h,p_visited_network_id_s);
00221                 STR_APPEND(h,r->pvni);
00222                 STR_APPEND(h,p_visited_network_id_e);
00223         }
00224 
00225         if (r->pani.len) {
00226                 STR_APPEND(h,p_access_network_info_s);
00227                 STR_APPEND(h,r->pani);
00228                 STR_APPEND(h,p_access_network_info_e);
00229         }
00230 
00231         if (r->cv.len) {
00232                 STR_APPEND(h,p_charging_vector_s);
00233                 STR_APPEND(h,r->cv);
00234                 STR_APPEND(h,p_charging_vector_e);
00235         }
00236         LOG(L_CRIT,"SRV INFO:<%.*s>\n",r->service_info.len, r->service_info.s);
00237         if (r->service_info.len){
00238             b.len = body_s.len+r->service_info.len+body_e.len;
00239             b.s = pkg_malloc(b.len);
00240             if (!b.s){
00241                 LOG(L_ERR,"ERR:"M_NAME":r_send_third_party_reg: Error allocating %d bytes\n",b.len);
00242                 b.len = 0;
00243                 return 0;
00244             }
00245     
00246             b.len = 0;
00247             STR_APPEND(b,body_s);
00248             STR_APPEND(b,r->service_info);          
00249             STR_APPEND(b,body_e);           
00250         }
00251         
00252 
00253         if (isc_tmb.t_request(&method, &(r->req_uri), &(r->to), &(r->from), &h, &b, 0,
00254                  r_third_party_reg_response, &(r->req_uri))<0)
00255         {
00256                 LOG(L_ERR,"ERR:"M_NAME":r_send_third_party_reg: Error sending in transaction\n");
00257                 goto error;
00258         }
00259         #ifdef WITH_IMS_PM
00260             IMS_PM_LOG(UR_Att3rdPartyReg);
00261         #endif
00262         if (h.s) pkg_free(h.s);
00263         return 1;
00264 
00265 error:
00266         if (h.s) pkg_free(h.s);
00267         return 0;
00268 }

void r_third_party_reg_response ( struct cell *  t,
int  type,
struct tmcb_params *  ps 
)

Response callback for third party register.

Definition at line 275 of file third_party_reg.c.

References cscf_get_expires_hdr(), IMS_PM_LOG01, and M_NAME.

Referenced by r_send_third_party_reg().

00276 {
00277         str req_uri;
00278         int expires;
00279         LOG(L_DBG,"DBG:"M_NAME":r_third_party_reg_response: code %d\n",ps->code);
00280         if (!ps->rpl) {
00281                 LOG(L_ERR,"INF:"M_NAME":r_third_party_reg_response: No reply\n");
00282                 return;
00283         }
00284         
00285         #ifdef WITH_IMS_PM
00286             if (ps->code>=200 && ps->code<300) 
00287                 IMS_PM_LOG01(UR_Succ3rdPartyReg,ps->code);
00288             else if (ps->code>=300) IMS_PM_LOG01(UR_Fail3rdPartyReg,ps->code);
00289         #endif
00290              
00291         if (ps->code>=200 && ps->code<300){
00292                 if (ps->rpl)
00293                         expires = cscf_get_expires_hdr(ps->rpl);
00294                 else
00295                         return;
00296                 req_uri = *((str*) *(ps->param));
00297         }else
00298         if (ps->code==404){
00299         }else{
00300                 LOG(L_INFO,"INF:"M_NAME":r_third_party_reg_response: code %d\n",ps->code); 
00301         }
00302 }


Variable Documentation

struct tm_binds isc_tmb

Structure with pointers to tm funcs.

Definition at line 110 of file mod.c.

str isc_my_uri

Uri of myself to loop the message in str.

Definition at line 92 of file mod.c.

str isc_my_uri_sip

Uri of myself to loop the message in str with leading "sip:".

Definition at line 93 of file mod.c.

int isc_expires_grace

expires value to add to the expires in the 3rd party register to prevent expiration in AS

Definition at line 96 of file mod.c.

Referenced by isc_third_party_reg().

struct scscf_binds isc_scscfb

Structure with pointers to S-CSCF funcs.

Definition at line 111 of file mod.c.

str method = {"REGISTER",8} [static]

Definition at line 146 of file third_party_reg.c.

Referenced by cscf_get_cseq_method(), P_SDP_manipulate(), r_send_subscribe(), and r_send_third_party_reg().

str event_hdr = {"Event: registration\r\n",21} [static]

Definition at line 147 of file third_party_reg.c.

Referenced by r_send_subscribe(), and r_send_third_party_reg().

str max_fwds_hdr = {"Max-Forwards: 10\r\n",18} [static]

Definition at line 148 of file third_party_reg.c.

Referenced by r_send_subscribe(), and r_send_third_party_reg().

str expires_s = {"Expires: ",9} [static]

Definition at line 149 of file third_party_reg.c.

Referenced by r_send_subscribe(), and r_send_third_party_reg().

str expires_e = {"\r\n",2} [static]

Definition at line 150 of file third_party_reg.c.

Referenced by r_send_subscribe(), and r_send_third_party_reg().

str contact_s = {"Contact: <",10} [static]

Definition at line 151 of file third_party_reg.c.

Referenced by r_send_subscribe(), and r_send_third_party_reg().

str contact_e = {">\r\n",3} [static]

Definition at line 152 of file third_party_reg.c.

Referenced by r_send_subscribe(), and r_send_third_party_reg().

str p_visited_network_id_s = {"P-Visited-Network-ID: ",22} [static]

Definition at line 154 of file third_party_reg.c.

Referenced by r_send_third_party_reg().

str p_visited_network_id_e = {"\r\n",2} [static]

Definition at line 155 of file third_party_reg.c.

Referenced by r_send_third_party_reg().

str p_access_network_info_s = {"P-Access-Network-Info: ",23} [static]

Definition at line 157 of file third_party_reg.c.

Referenced by r_send_third_party_reg().

str p_access_network_info_e = {"\r\n",2} [static]

Definition at line 158 of file third_party_reg.c.

Referenced by r_send_third_party_reg().

str p_charging_vector_s = {"P-Charging-Vector: ",19} [static]

Definition at line 160 of file third_party_reg.c.

Referenced by r_send_third_party_reg().

str p_charging_vector_e = {"\r\n",2} [static]

Definition at line 161 of file third_party_reg.c.

Referenced by r_send_third_party_reg().

str body_s = {"<ims-3gpp version=\"1\"><service-info>",36} [static]

Definition at line 162 of file third_party_reg.c.

Referenced by r_send_third_party_reg().

str body_e = {"</service-info></ims-3gpp>",26} [static]

Definition at line 163 of file third_party_reg.c.

Referenced by r_send_third_party_reg().


Generated on Tue Jul 29 04:19:17 2008 for Open IMS Core CSCFs by  doxygen 1.5.2