checker.h File Reference


Detailed Description

IMS Service Control - Initial Filter Criteria Checker.

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

Definition in file checker.h.

#include "../scscf/ifc_datastruct.h"
#include "../../sr_module.h"

Go to the source code of this file.

Data Structures

struct  isc_match
 ISC match structure. More...

Defines

#define MOBILE_ORIGINATED   0
 Originating case.
#define MOBILE_TERMINATED   1
 Terminating case.
#define MOBILE_TERMINATED_UNREGISTERED   2
 Terminating to unregistered case.

Functions

void isc_free_match (isc_match *m)
 Free up all memory taken by a isc_match.
isc_matchisc_checker_find (str uri, char direction, int skip, struct sip_msg *msg, int registered)
 Find the next match and fill up the ifc_match structure with the position of the match.


Define Documentation

#define MOBILE_ORIGINATED   0

Originating case.

Definition at line 62 of file checker.h.

#define MOBILE_TERMINATED   1

Terminating case.

Definition at line 64 of file checker.h.

#define MOBILE_TERMINATED_UNREGISTERED   2

Terminating to unregistered case.

Definition at line 66 of file checker.h.


Function Documentation

void isc_free_match ( isc_match m  ) 

Free up all memory taken by a isc_match.

Parameters:
m - match to deallocate

Definition at line 375 of file checker.c.

References M_NAME, isc_match::server_name, and isc_match::service_info.

Referenced by ISC_match_filter(), and ISC_match_filter_reg().

00376 {
00377     if (m) {
00378         if (m->server_name.s) pkg_free(m->server_name.s);
00379         if (m->service_info.s) pkg_free(m->service_info.s);         
00380         pkg_free(m);
00381     }
00382     DBG("DEBUG:"M_NAME":isc_match_free: match position freed\n");
00383 }

isc_match* isc_checker_find ( str  uri,
char  direction,
int  skip,
struct sip_msg *  msg,
int  registered 
)

Find the next match and fill up the ifc_match structure with the position of the match.

Parameters:
uri - URI of the user for which to apply the IFC
direction - direction of the session
skip - how many IFCs to skip because already matched
msg - the SIP initial request to check on
Returns:
- TRUE if found, FALSE if none found, end of search space

Definition at line 395 of file checker.c.

References ims_service_profile::filter_criteria_cnt, scscf_binds::get_r_public, _r_public::hash, IFC_DE_REGISTRATION, IFC_INITIAL_REGISTRATION, IFC_RE_REGISTRATION, isc_get_expires(), isc_scscfb, M_NAME, ims_service_profile::public_identities, ims_service_profile::public_identities_cnt, ims_public_identity::public_identity, scscf_binds::r_unlock, _r_public::s, ims_subscription::service_profiles, and ims_subscription::wpsi.

Referenced by ISC_match_filter(), and ISC_match_filter_reg().

00396 {
00397     int expires;
00398     char registration_type;
00399     str domain={0,0};
00400     int i,j,k,cnt,si,sj,next;
00401     r_public *p;
00402     ims_service_profile *sp;
00403     ims_filter_criteria *fc;
00404     isc_match *r;
00405     
00406     
00407     if (skip==0) LOG(L_INFO,"INFO:"M_NAME":isc_checker_find: starting search\n");
00408     else LOG(L_INFO,"INFO:"M_NAME":isc_checker_find: resuming search from %d\n",skip);
00409 
00410     expires = isc_get_expires(msg);
00411     if (!registered) registration_type = IFC_INITIAL_REGISTRATION;
00412     else if (expires>0) registration_type = IFC_RE_REGISTRATION;
00413          else registration_type = IFC_DE_REGISTRATION;
00414     
00415     /* get the user profile from the scscf module */    
00416     i=0;
00417 
00418     while(i<uri.len && uri.s[i]!='@') 
00419         i++;
00420     domain.s = uri.s+i+1;
00421     domain.len = uri.len - i - 1;
00422 
00423     p = isc_scscfb.get_r_public(uri);
00424 
00425     if (!p) return 0;
00426     LOG(L_DBG,"isc_checker_find(): got a r_public for the user %.*s\n",uri.len,uri.s);
00427     if (!p->s) {
00428         LOG(L_DBG,"isc_checker_find() : got an user without a subscription\n");
00429         isc_scscfb.r_unlock(p->hash);
00430         return 0;
00431     }
00432     
00433     /* find the starting fc as the skip-th one*/            
00434     cnt=0;
00435     si=0;sj=0;
00436     while(si<p->s->service_profiles_cnt){
00437         next = cnt + p->s->service_profiles[si].filter_criteria_cnt;
00438         if (cnt<=skip && skip<next){
00439             sj = skip-cnt;
00440             cnt += sj;
00441             break;
00442         }
00443         cnt = next;
00444         si++;
00445     }
00446     
00447     /* iterate through the rest and check for matches */
00448     i = si;
00449     while(i<p->s->service_profiles_cnt){
00450         sp = p->s->service_profiles +i;
00451         k=0;
00452         for(j=0;j<sp->public_identities_cnt;j++)
00453         {
00454             
00455             if (p->s->wpsi)
00456             {
00457                     // here i should regexec again!
00458                     // to check this , but anyway if i already got p
00459                     // from the get_r_public , that is already checked...
00460                     // or not if there is no wildcardPSI but ... then ...
00461                     //isc_check_wpsi_match();
00462                     k = 1;
00463                     break;  
00464                             
00465             } else {
00466             if (sp->public_identities[j].public_identity.len == uri.len &&
00467                 strncasecmp(sp->public_identities[j].public_identity.s,uri.s,uri.len)==0){
00468                     k = 1;
00469                     break;
00470                 }
00471             }
00472         }
00473 
00474         if (!k){/* this sp is not for this id */
00475             
00476             cnt += sp->filter_criteria_cnt;
00477         }else{
00478             
00479             for(j=sj;j<sp->filter_criteria_cnt;j++){
00480                 fc = sp->filter_criteria+j;
00481                 if (fc->profile_part_indicator){                
00482                     if (( (registered==IMS_USER_REGISTERED) && (*fc->profile_part_indicator))||
00483                         ( (registered==IMS_USER_UNREGISTERED) && !(*fc->profile_part_indicator))) {
00484                         DBG("DEBUG:"M_NAME":isc_checker_find: this one is not good... ppindicator wrong \n");                                           
00485                         cnt++;
00486                         continue;
00487                     }
00488                 }
00489                 
00490                 if (isc_check_filter_criteria(fc,msg,direction,registration_type)){
00491                     LOG(L_INFO,"INFO:"M_NAME":isc_checker_find: MATCH -> %.*s (%.*s) handling %d \n",
00492                         fc->application_server.server_name.len,
00493                         fc->application_server.server_name.s,
00494                         fc->application_server.service_info.len,
00495                         fc->application_server.service_info.s,
00496                         fc->application_server.default_handling );      
00497                     r = isc_new_match(fc,cnt);  
00498                     isc_scscfb.r_unlock(p->hash);
00499 
00500                     return r;   
00501                 }else{
00502                     cnt++;
00503                     continue;
00504                 }
00505             }   
00506         }   
00507         i++;
00508         sj = 0;
00509     }
00510     isc_scscfb.r_unlock(p->hash);
00511 
00512     return 0;
00513 }


Generated on Thu Oct 23 04:14:41 2008 for Open IMS Core CSCFs by  doxygen 1.5.2