mark.h File Reference


Detailed Description

IMS Service Control - ISC Marking Procedures.

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

Definition in file mark.h.

#include "../../parser/msg_parser.h"
#include "../../lump_struct.h"
#include "../../data_lump.h"
#include "checker.h"

Go to the source code of this file.

Data Structures

struct  _isc_mark
 ISC marking structure. More...

Defines

#define ISC_MARK_USERNAME   "sip:iscmark"
 username to be used in the Route
#define ISC_MARK_USERNAME_LEN   11
 length of ISC_MARK_USERNAME
#define ISC_MARK_NOMARK   0
 no mark
#define ISC_MARK_ORIG_LEG   1
 mark for originating
#define ISC_MARK_TERM_LEG   2
 mark for terminating
#define ISC_MARK_TERM_UNREG_LEG   3
 mark for terminating to unregistered users
#define ISC_MARK_STATUS_MAX   99

Typedefs

typedef _isc_mark isc_mark
 ISC marking structure.

Functions

int isc_mark_set (struct sip_msg *msg, isc_match *match, isc_mark *mark)
 Mark the message with the given mark.
int isc_mark_get_from_msg (struct sip_msg *msg, isc_mark *mark)
 Retrieves the mark from message.
int isc_mark_get_from_lump (struct sip_msg *msg, isc_mark *mark)
 Retrieves the mark from lump.
int isc_mark_write_route (struct sip_msg *msg, str *as, str *iscmark)
 Inserts the Route header for marking, before first header.
int isc_mark_drop_route (struct sip_msg *msg)
 Deletes the previous marking attempts (lumps).


Define Documentation

#define ISC_MARK_USERNAME   "sip:iscmark"

username to be used in the Route

Definition at line 64 of file mark.h.

Referenced by isc_appserver_forward(), isc_mark_drop_route(), isc_mark_get_from_lump(), isc_mark_get_from_msg(), and isc_mark_set().

#define ISC_MARK_USERNAME_LEN   11

length of ISC_MARK_USERNAME

Definition at line 66 of file mark.h.

Referenced by isc_appserver_forward(), and isc_mark_get_from_msg().

#define ISC_MARK_NOMARK   0

no mark

Definition at line 69 of file mark.h.

#define ISC_MARK_ORIG_LEG   1

mark for originating

Definition at line 71 of file mark.h.

#define ISC_MARK_TERM_LEG   2

mark for terminating

Definition at line 73 of file mark.h.

#define ISC_MARK_TERM_UNREG_LEG   3

mark for terminating to unregistered users

Definition at line 75 of file mark.h.

#define ISC_MARK_STATUS_MAX   99

Definition at line 76 of file mark.h.


Typedef Documentation

typedef struct _isc_mark isc_mark

ISC marking structure.


Function Documentation

int isc_mark_set ( struct sip_msg *  msg,
isc_match match,
isc_mark mark 
)

Mark the message with the given mark.

Definition at line 130 of file mark.c.

References _isc_mark::aor, bin_to_base16(), _isc_mark::direction, _isc_mark::handling, isc_mark_drop_route(), ISC_MARK_USERNAME, isc_mark_write_route(), isc_my_uri, M_NAME, isc_match::server_name, and _isc_mark::skip.

Referenced by isc_forward().

00131 {
00132     str route={0,0};
00133     str as={0,0};
00134     char chr_mark[256];
00135     char aor_hex[256];
00136     int len;
00137 
00138     /* Drop all the old Header Lump "Route: <as>, <my>" */
00139     isc_mark_drop_route(msg);
00140     
00141     len = bin_to_base16(mark->aor.s,mark->aor.len,aor_hex);
00142     /* Create the Marking */        
00143     sprintf(chr_mark,"%s@%.*s;lr;s=%d;h=%d;d=%d;a=%.*s",
00144         ISC_MARK_USERNAME,
00145         isc_my_uri.len,isc_my_uri.s,
00146         mark->skip,
00147         mark->handling,
00148         mark->direction,
00149         len,aor_hex
00150         );
00151     /* Add it in a lump */
00152     route.s = chr_mark;
00153     route.len = strlen(chr_mark);
00154     if (match) as = match->server_name;
00155     isc_mark_write_route(msg,&as,&route);
00156     LOG(L_INFO,"INFO:"M_NAME":isc_mark_set: NEW mark <%s>\n",chr_mark); 
00157     
00158     return 1;
00159 }

int isc_mark_get_from_msg ( struct sip_msg *  msg,
isc_mark mark 
)

Retrieves the mark from message.

Definition at line 222 of file mark.c.

References isc_mark_get(), ISC_MARK_USERNAME, ISC_MARK_USERNAME_LEN, isc_my_uri, and M_NAME.

Referenced by ISC_from_AS(), and ISC_match_filter().

00223 {
00224     struct hdr_field *hdr;
00225     rr_t *rr;
00226     str x;
00227     LOG(L_INFO,"INFO:"M_NAME":isc_mark_get_from_msg: Trying to get the mark from the message \n");
00228     
00229     memset(mark,0,sizeof(isc_mark));
00230     
00231     parse_headers(msg,HDR_EOH_F,0);
00232     hdr = msg->headers;
00233     while(hdr){
00234         if (hdr->type == HDR_ROUTE_T){
00235             if (!hdr->parsed){
00236                 if (parse_rr(hdr) < 0) {
00237                     LOG(L_ERR, "ERROR:"M_NAME":isc_mark_get_from_msg: Error while parsing Route HF\n");
00238                     hdr = hdr->next;
00239                     continue;
00240                 }
00241             }
00242             rr = (rr_t*)hdr->parsed;
00243             while(rr){
00244                 x = rr->nameaddr.uri;
00245                 if (x.len >= ISC_MARK_USERNAME_LEN + 1 + isc_my_uri.len &&
00246                     strncasecmp(x.s,ISC_MARK_USERNAME,ISC_MARK_USERNAME_LEN)==0 &&
00247                     strncasecmp(x.s+ISC_MARK_USERNAME_LEN+1,isc_my_uri.s,isc_my_uri.len)==0)
00248                 {
00249                     LOG(L_INFO,"INFO:"M_NAME":isc_mark_get_from_msg: Found <%.*s>\n",x.len,x.s);                        
00250                     isc_mark_get(x,mark);
00251                     return 1;
00252                 }                   
00253                 rr = rr->next;
00254             }
00255         }       
00256         hdr = hdr->next;
00257     }       
00258     return 0;
00259 }

int isc_mark_get_from_lump ( struct sip_msg *  msg,
isc_mark mark 
)

Retrieves the mark from lump.

Definition at line 270 of file mark.c.

References isc_mark_get(), ISC_MARK_USERNAME, and M_NAME.

Referenced by ISC_is_session_continued().

00271 {
00272     struct lump* lmp,*tmp;;
00273     struct lump* anchor;
00274     str x;
00275 
00276     anchor = anchor_lump(msg, msg->headers->name.s - msg->buf, 0 , 0);
00277 
00278     memset(mark,0,sizeof(isc_mark));
00279         
00280     LOG(L_DBG,"DEBUG:"M_NAME":isc_mark_get_from_lump: Start --------- \n");
00281     lmp = msg->add_rm;
00282     while(lmp){     
00283         tmp= lmp->before;
00284         if (tmp &&
00285             tmp->op==LUMP_ADD &&
00286             tmp->u.value &&
00287             strstr(tmp->u.value,ISC_MARK_USERNAME))
00288         {           
00289             LOG(L_DBG,"DEBUG:"M_NAME":isc_mark_get_from_lump: Found lump %s ... dropping\n",tmp->u.value);                                      
00290             x.s = lmp->u.value;
00291             x.len = lmp->len;
00292             isc_mark_get(x,mark);
00293             return 1;
00294         }
00295         lmp = lmp->next;        
00296     }
00297     LOG(L_DBG,"DEBUG:"M_NAME":isc_mark_get_from_lump: ---------- End \n");
00298     
00299     return 0;
00300 }

int isc_mark_write_route ( struct sip_msg *  msg,
str *  as,
str *  iscmark 
) [inline]

Inserts the Route header for marking, before first header.

Parameters:
msg - SIP mesage to mark
as - SIP addres of the application server to forward to
iscmark - the mark to write
Returns:
1 on success, else 0

Definition at line 314 of file mark.c.

References M_NAME, and NULL.

Referenced by isc_mark_set().

00315 {
00316     struct hdr_field *first;
00317     struct lump* anchor;
00318     str route;
00319     
00320     parse_headers(msg,HDR_EOH_F,0);         
00321     first = msg->headers;   
00322     if (as && as->len) {
00323         route.s = pkg_malloc(21+as->len+iscmark->len);
00324         sprintf(route.s,"Route: <%.*s;lr>, <%.*s>\r\n",as->len,as->s,iscmark->len,iscmark->s);
00325     }else{
00326         route.s = pkg_malloc(18+iscmark->len);
00327         sprintf(route.s,"Route: <%.*s>\r\n",iscmark->len,iscmark->s);
00328     }
00329     
00330     route.len =strlen(route.s);
00331     LOG(L_DBG,"DEBUG:"M_NAME":isc_mark_write_route: <%.*s>\n",route.len,route.s);
00332     
00333     anchor = anchor_lump(msg, first->name.s - msg->buf, 0 , HDR_ROUTE_T);
00334     if (anchor == NULL) {
00335         LOG(L_ERR, "ERROR:"M_NAME":isc_mark_write_route: anchor_lump failed\n");
00336         return 0;
00337     }
00338 
00339     if (!insert_new_lump_before(anchor, route.s,route.len,HDR_ROUTE_T)){
00340             LOG( L_ERR, "ERROR:"M_NAME":isc_mark_write_route: error creting lump for header_mark\n" );
00341     }   
00342     return 1;
00343 }

int isc_mark_drop_route ( struct sip_msg *  msg  )  [inline]

Deletes the previous marking attempts (lumps).

Parameters:
msg - SIP mesage to mark
Returns:
1 on success

Definition at line 352 of file mark.c.

References ISC_MARK_USERNAME, and M_NAME.

Referenced by isc_mark_set(), and ISC_match_filter().

00353 {
00354     struct lump* lmp,*tmp;
00355     struct lump* anchor;
00356 
00357     parse_headers(msg,HDR_EOH_F,0);         
00358 
00359     anchor = anchor_lump(msg, msg->headers->name.s - msg->buf, 0 , 0);
00360         
00361     LOG(L_DBG,"DEBUG:"M_NAME":ifc_mark_drop_route: Start --------- \n");
00362     lmp = msg->add_rm;
00363     while(lmp){     
00364         tmp= lmp->before;
00365         if (tmp &&
00366             tmp->op==LUMP_ADD &&
00367             tmp->u.value &&
00368             strstr(tmp->u.value,ISC_MARK_USERNAME))
00369         {           
00370             LOG(L_DBG,"DEBUG:"M_NAME":ifc_mark_drop_route: Found lump %s ... dropping\n",tmp->u.value);                                     
00371             //tmp->op=LUMP_NOP;         
00372             tmp->len = 0;
00373             /*lmp->before = tmp->before;
00374             free_lump(tmp); */
00375         }
00376         lmp = lmp->next;        
00377     }
00378     LOG(L_DBG,"DEBUG:"M_NAME":ifc_mark_drop_route: ---------- End \n");
00379     
00380     return 1;
00381 }


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