This XML is received in the Server-Assignment-Answer
Definition in file registrar_parser.c.
#include <libxml/xmlschemas.h>
#include <libxml/xmlschemastypes.h>
#include <libxml/parser.h>
#include "registrar_parser.h"
#include "mod.h"
#include "../../mem/shm_mem.h"
#include "../../parser/parse_hname2.h"
Go to the source code of this file.
Functions | |
| int | parser_init (char *dtd_filename, char *xsd_filename) |
| Initializes the libxml2 parser. | |
| void | parser_destroy () |
| Destroys the parser. | |
| void | space_quotes_trim_dup (str *dest, char *src) |
| Duplicate a string into shm and trim leading&trailing spaces and surrounding quotes. | |
| static void | space_trim_dup (str *dest, char *src) |
| Duplicate a string into shm and trim leading&trailing spaces. | |
| static char | ifc_tBool2char (xmlChar *x) |
| Converts strings to integer values. | |
| static char | ifc_tDefaultHandling2char (xmlChar *x) |
| Converts strings to integer values. | |
| static char | ifc_tDirectionOfRequest2char (xmlChar *x) |
| Converts strings to integer values. | |
| static char | ifc_tProfilePartIndicator2char (xmlChar *x) |
| Converts strings to integer values. | |
| static int | parse_public_identity (xmlDocPtr doc, xmlNodePtr root, ims_public_identity *pi) |
| Parse the Public Identity. | |
| static int | parse_sip_header (xmlDocPtr doc, xmlNodePtr node, ims_sip_header *sh) |
| Parse SPT for SIP Header. | |
| static int | parse_session_desc (xmlDocPtr doc, xmlNodePtr node, ims_session_desc *sd) |
| Parse SPT for Session Description. | |
| static int | parse_spt_extension (xmlDocPtr doc, xmlNodePtr node, ims_spt *spt) |
| Parse a Service Point Trigger Extension (RegistrationType). | |
| static int | parse_spt (xmlDocPtr doc, xmlNodePtr node, ims_spt *spt_to, unsigned short *spt_cnt) |
| Parse a Service Point Trigger. | |
| static int | parse_trigger_point (xmlDocPtr doc, xmlNodePtr node, ims_trigger_point *tp) |
| Parse a Trigger Point. | |
| static int | parse_application_server (xmlDocPtr doc, xmlNodePtr node, ims_application_server *as) |
| Parse a Application Server. | |
| static int | parse_filter_criteria (xmlDocPtr doc, xmlNodePtr node, ims_filter_criteria *fc) |
| Parse a Filter Criteria. | |
| static int | parse_cn_service_auth (xmlDocPtr doc, xmlNodePtr node, ims_cn_service_auth *cn) |
| Parse a Core Network Service Authorization. | |
| static int | parse_service_profile (xmlDocPtr doc, xmlNodePtr root, ims_service_profile *sp) |
| Parse a Core Network Service Profile. | |
| static ims_subscription * | parse_ims_subscription (xmlDocPtr doc, xmlNodePtr root) |
| Parse a IMS Subscription. | |
| ims_subscription * | parse_user_data (str xml) |
| Parses the user data XML and copies data into a new ims_subscription structure. | |
| void | print_user_data (int log_level, ims_subscription *s) |
| Print the contents of an ims_subscription structure. | |
| void | free_user_data (ims_subscription *s) |
| Deallocates memory used by a subscription. | |
Variables | |
| char * | scscf_user_data_dtd |
| char * | scscf_user_data_xsd |
| int | scscf_support_wildcardPSI |
| int | ctxtInit = 0 |
| the XML context | |
| static xmlDtdPtr | dtd = 0 |
| DTD file. | |
| static xmlValidCtxtPtr | dtdCtxt = 0 |
| Validating context. | |
| static xmlSchemaPtr | xsd = 0 |
| XSD file. | |
| static xmlSchemaValidCtxtPtr | xsdCtxt = 0 |
| Schema Validating context. | |
| int parser_init | ( | char * | dtd_filename, | |
| char * | xsd_filename | |||
| ) |
Initializes the libxml2 parser.
| dtd_filename | - path to the DTD or NULL if none | |
| xsd_filename | - path to the XSD or NULL if none |
Definition at line 89 of file registrar_parser.c.
References ctxtInit, dtd, dtdCtxt, M_NAME, NULL, xsd, and xsdCtxt.
00090 { 00091 if (dtd_filename){ 00092 dtd = xmlParseDTD(NULL,(unsigned char*)dtd_filename); 00093 if (!dtd){ 00094 LOG(L_ERR,"ERR:"M_NAME":parser_init: unsuccesful DTD parsing from file <%s>\n", 00095 dtd_filename); 00096 return 0; 00097 } 00098 dtdCtxt = xmlNewValidCtxt(); 00099 dtdCtxt->userData = (void*)stderr; 00100 dtdCtxt->error = (xmlValidityErrorFunc) fprintf; 00101 dtdCtxt->warning = (xmlValidityWarningFunc) fprintf; 00102 } 00103 if (xsd_filename){ 00104 xmlSchemaParserCtxtPtr ctxt; 00105 ctxt = xmlSchemaNewParserCtxt(xsd_filename); 00106 if (!ctxt) { 00107 LOG(L_ERR,"ERR:"M_NAME":parser_init: unsuccesful XSD parsing from file <%s>\n", 00108 xsd_filename); 00109 return 0; 00110 } 00111 xmlSchemaSetParserErrors(ctxt,(xmlValidityErrorFunc) fprintf,(xmlValidityWarningFunc) fprintf,stderr); 00112 xsd = xmlSchemaParse(ctxt); 00113 xmlSchemaFreeParserCtxt(ctxt); 00114 00115 xsdCtxt = xmlSchemaNewValidCtxt(xsd); 00116 xmlSchemaSetValidErrors(xsdCtxt,(xmlValidityErrorFunc) fprintf,(xmlValidityWarningFunc) fprintf,stderr); 00117 } 00118 ctxtInit=1; 00119 return 1; 00120 }
| void parser_destroy | ( | ) |
Destroys the parser.
Definition at line 125 of file registrar_parser.c.
References dtdCtxt, and xsdCtxt.
00126 { 00127 if (dtdCtxt){ 00128 xmlFreeValidCtxt(dtdCtxt); 00129 } 00130 if (xsdCtxt){ 00131 xmlSchemaFreeValidCtxt(xsdCtxt); 00132 xmlSchemaCleanupTypes(); 00133 } 00134 xmlCleanupParser(); 00135 00136 }
| void space_quotes_trim_dup | ( | str * | dest, | |
| char * | src | |||
| ) |
Duplicate a string into shm and trim leading&trailing spaces and surrounding quotes.
| dest | - destination | |
| src | - source |
Definition at line 143 of file registrar_parser.c.
References NULL.
Referenced by parse_session_desc(), and parse_sip_header().
00143 { 00144 int i = 0; 00145 //right space trim 00146 if (src == NULL) return ; 00147 dest->len = strlen(src); 00148 i = dest->len - 1; 00149 while((src[i] == ' '||src[i]=='\t') && i > 0) { 00150 dest->len--; 00151 i--; 00152 } 00153 //left space trim 00154 i = 0; 00155 while((src[i] == ' '||src[i]=='\t') && i<dest->len) 00156 i++; 00157 00158 while(i<dest->len &&(src[i]=='\"'&&src[dest->len-1]=='\"')){ 00159 i++; 00160 if (i<dest->len) dest->len--; 00161 } 00162 00163 dest->len -= i; 00164 if (dest->len<=0) return; 00165 dest->s = shm_malloc(dest->len); 00166 memcpy(dest->s, src+i , dest->len); 00167 }
| static void space_trim_dup | ( | str * | dest, | |
| char * | src | |||
| ) | [inline, static] |
Duplicate a string into shm and trim leading&trailing spaces.
| dest | - destination | |
| src | - source |
Definition at line 174 of file registrar_parser.c.
References M_NAME.
00175 { 00176 int i; 00177 dest->s=0; 00178 dest->len=0; 00179 if (!src) return; 00180 dest->len = strlen(src); 00181 i = dest->len-1; 00182 while((src[i]==' '||src[i]=='\t') && i>0) 00183 i--; 00184 i=0; 00185 while((src[i]==' '||src[i]=='\t') && i<dest->len) 00186 i++; 00187 dest->len -= i; 00188 dest->s = shm_malloc(dest->len); 00189 if (!dest->s) { 00190 LOG(L_ERR,"ERR:"M_NAME":space_trim_dup: Out of memory allocating %d bytes\n",dest->len); 00191 dest->len=0; 00192 return; 00193 } 00194 memcpy(dest->s,src+i,dest->len); 00195 }
| static char ifc_tBool2char | ( | xmlChar * | x | ) | [inline, static] |
Converts strings to integer values.
| x | - input value |
Definition at line 206 of file registrar_parser.c.
Referenced by parse_public_identity(), parse_spt(), and parse_trigger_point().
00207 { 00208 int r=0; 00209 while(x[r]){ 00210 switch(x[r]){ 00211 case '0': return 0; 00212 case '1': return 1; 00213 case 't': case 'T': return 1; 00214 case 'f': case 'F': return 0; 00215 } 00216 r++; 00217 } 00218 return 0; 00219 }
| static char ifc_tDefaultHandling2char | ( | xmlChar * | x | ) | [inline, static] |
Converts strings to integer values.
| x | - input value |
Definition at line 228 of file registrar_parser.c.
Referenced by parse_application_server().
00229 { 00230 char r; 00231 r = strtol((char*)x, (char **)NULL, 10); 00232 if (errno==EINVAL){ 00233 while(x[0]){ 00234 if (x[0]=='c'||x[0]=='C') return 0;//SESSION_CONTINUED 00235 if (x[0]=='r'||x[0]=='R') return 1;//SESSION_TERMINATED 00236 x++; 00237 } 00238 return 0; 00239 } 00240 else return (char)r; 00241 }
| static char ifc_tDirectionOfRequest2char | ( | xmlChar * | x | ) | [inline, static] |
Converts strings to integer values.
| x | - input value |
Definition at line 251 of file registrar_parser.c.
Referenced by parse_spt().
00252 { 00253 int r; 00254 r = strtol((char*)x, (char **)NULL, 10); 00255 if (errno==EINVAL){ 00256 while(x[0]){ 00257 if (x[0]=='o'||x[0]=='O') return 0;//ORIGINATING_SESSION 00258 if (x[0]=='s'||x[0]=='S') return 1;//TERMINATING_REGISTERED 00259 if (x[0]=='u'||x[0]=='U') return 2;//TERMINATING_UNREGISTERED 00260 x++; 00261 } 00262 return 0; 00263 } 00264 else return (char)r; 00265 }
| static char ifc_tProfilePartIndicator2char | ( | xmlChar * | x | ) | [inline, static] |
Converts strings to integer values.
| x | - input value |
Definition at line 275 of file registrar_parser.c.
Referenced by parse_filter_criteria().
00276 { 00277 int r; 00278 if (x==0||x[0]==0) return -1; 00279 r = strtol((char*)x, (char **)NULL, 10); 00280 if (errno==EINVAL){ 00281 while(x[0]){ 00282 if (x[0]=='r'||x[0]=='R') return 0;//REGISTERED 00283 if (x[0]=='u'||x[0]=='U') return 1;//UNREGISTERED 00284 x++; 00285 } 00286 return 0; 00287 } 00288 else return (char)r; 00289 }
| static int parse_public_identity | ( | xmlDocPtr | doc, | |
| xmlNodePtr | root, | |||
| ims_public_identity * | pi | |||
| ) | [static] |
Parse the Public Identity.
| doc | - the XML document | |
| root | - the current node | |
| pi | - structure to fill |
Definition at line 299 of file registrar_parser.c.
References ims_public_identity::barring, ifc_tBool2char(), ims_public_identity::public_identity, scscf_support_wildcardPSI, space_trim_dup(), and ims_public_identity::wildcarded_psi.
Referenced by parse_service_profile().
00300 { 00301 xmlNodePtr child; 00302 xmlNodePtr grandson; 00303 xmlChar *x; 00304 int return_code=1; 00305 00306 for(child=root->children;child;child=child->next) 00307 if (child->type==XML_ELEMENT_NODE) 00308 switch (child->name[0]){ 00309 case 'I': case 'i': 00310 if (!pi->public_identity.len){ 00311 x = xmlNodeListGetString(doc,child->xmlChildrenNode,1); 00312 space_trim_dup(&(pi->public_identity),(char*)x); 00313 xmlFree(x); 00314 } 00315 break; 00316 case 'B': case 'b': 00317 x = xmlNodeListGetString(doc,child->xmlChildrenNode,1); 00318 pi->barring = ifc_tBool2char(x); 00319 xmlFree(x); 00320 break; 00321 //lets add something 00322 case 'E' : case 'e': 00323 // that would be Extension 00324 // here i need to parse Identity Type 00325 // if its two then wildcardedpsi 00326 // and then extension!!! 00327 // I have to check how you parse this shit 00328 00329 for(grandson=child->children;grandson;grandson=grandson->next) 00330 { 00331 00332 if (grandson->type==XML_ELEMENT_NODE) 00333 { 00334 switch (grandson->name[0]) { 00335 case 'I' : case 'i': 00336 //identity type 0 public identity 1 distinct psi 2 wildcard psi 00337 //x = xmlNodeListGetString(doc,grandson->xmlChildrenNode,1); 00338 // i need to compare x with 2, but i have to trim leading 00339 // space characters or tabs 00340 //xmlFree(x); 00341 break; 00342 case 'W' : case 'w': 00343 //wildcardpsi 00344 if(!scscf_support_wildcardPSI) { 00345 LOG(L_ERR,"Configured without support for Wildcard PSI and got one from HSS\n"); 00346 LOG(L_ERR,"the identity will be stored but never be matched, please include the parameter to support wildcard PSI in the config file\n"); 00347 } 00348 00349 x = xmlNodeListGetString(doc,grandson->xmlChildrenNode,1); 00350 00351 space_trim_dup(&(pi->wildcarded_psi),(char*)x); 00352 00353 xmlFree(x); 00354 return_code=2; 00355 break; 00356 default : 00357 break; 00358 } 00359 } 00360 } 00361 00362 break; 00363 } 00364 00365 return return_code; 00366 }
| static int parse_sip_header | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_sip_header * | sh | |||
| ) | [static] |
Parse SPT for SIP Header.
| doc | - the XML document | |
| node | - the current node | |
| sh | - structure to fill |
Definition at line 375 of file registrar_parser.c.
References _ims_sip_header::content, _ims_sip_header::header, NULL, space_quotes_trim_dup(), space_trim_dup(), and _ims_sip_header::type.
Referenced by parse_spt().
00376 { 00377 xmlNodePtr child; 00378 xmlChar *x; 00379 char c[256]; 00380 int len; 00381 struct hdr_field hf; 00382 sh->header.s=NULL;sh->header.len=0; 00383 sh->content.s=NULL;sh->content.len=0; 00384 00385 for(child=node->children ; child ; child=child->next) 00386 if (child->type==XML_ELEMENT_NODE) 00387 switch (child->name[0]) { 00388 case 'H':case 'h': //Header 00389 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00390 len = strlen((char*)x); 00391 memcpy(c,x,len); 00392 c[len++]=':'; 00393 c[len]=0; 00394 space_trim_dup(&(sh->header),(char*)x); 00395 parse_hname2(c,c+(len<4?4:len),&hf); 00396 sh->type=(short)hf.type; 00397 //LOG(L_CRIT,"[%.*s(%d)]\n",sh->header.len,sh->header.s,sh->type); 00398 xmlFree(x); 00399 break; 00400 case 'C':case 'c': //Content 00401 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00402 space_quotes_trim_dup(&(sh->content),(char*)x); 00403 xmlFree(x); 00404 break; 00405 } 00406 return 1; 00407 }
| static int parse_session_desc | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_session_desc * | sd | |||
| ) | [static] |
Parse SPT for Session Description.
| doc | - the XML document | |
| node | - the current node | |
| sd | - structure to fill |
Definition at line 416 of file registrar_parser.c.
References _ims_session_desc::content, _ims_session_desc::line, NULL, space_quotes_trim_dup(), and space_trim_dup().
Referenced by parse_spt().
00417 { 00418 xmlNodePtr child; 00419 xmlChar *x; 00420 sd->line.s=NULL;sd->line.len=0; 00421 sd->content.s=NULL;sd->content.len=0; 00422 00423 for(child=node->children ; child ; child=child->next) 00424 if (child->type==XML_ELEMENT_NODE) 00425 switch (child->name[0]) { 00426 case 'L':case 'l': //Line 00427 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00428 space_trim_dup(&(sd->line),(char*)x); 00429 xmlFree(x); 00430 break; 00431 case 'C':case 'c': //Content 00432 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00433 space_quotes_trim_dup(&(sd->content),(char*)x); 00434 xmlFree(x); 00435 break; 00436 } 00437 return 1; 00438 }
| static int parse_spt_extension | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_spt * | spt | |||
| ) | [static] |
Parse a Service Point Trigger Extension (RegistrationType).
| doc | - the XML document | |
| node | - the current node | |
| spt | - structure to fill |
Definition at line 447 of file registrar_parser.c.
References IFC_DE_REGISTRATION, IFC_INITIAL_REGISTRATION, IFC_RE_REGISTRATION, and _ims_spt::registration_type.
Referenced by parse_spt().
00448 { 00449 xmlNodePtr child; 00450 xmlChar *x; 00451 00452 for(child=node->children ; child ; child=child->next) { 00453 if (child->type==XML_ELEMENT_NODE && (child->name[0]=='R' || child->name[0]=='r')) { 00454 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00455 switch(atoi((char*)x)) { 00456 case 0: 00457 spt->registration_type |= IFC_INITIAL_REGISTRATION; 00458 break; 00459 case 1: 00460 spt->registration_type |= IFC_RE_REGISTRATION; 00461 break; 00462 case 2: 00463 spt->registration_type |= IFC_DE_REGISTRATION; 00464 break; 00465 } 00466 xmlFree(x); 00467 } 00468 } 00469 // LOG(L_CRIT,"INFO:"M_NAME":parse_spt_extension: spt->registration_type=%d\n",spt->registration_type); 00470 return 1; 00471 }
| static int parse_spt | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_spt * | spt_to, | |||
| unsigned short * | spt_cnt | |||
| ) | [static] |
Parse a Service Point Trigger.
| doc | - the XML document | |
| node | - the current node | |
| spt_to | - structure to fill | |
| spt_cnt | - structure to fill with the spt count |
Definition at line 481 of file registrar_parser.c.
References _ims_spt::condition_negated, _ims_spt::group, IFC_METHOD, IFC_REQUEST_URI, IFC_SESSION_CASE, IFC_SESSION_DESC, IFC_SIP_HEADER, ifc_tBool2char(), ifc_tDirectionOfRequest2char(), IFC_UNKNOWN, M_NAME, _ims_spt::method, parse_session_desc(), parse_sip_header(), parse_spt_extension(), _ims_spt::registration_type, _ims_spt::request_uri, _ims_spt::session_case, _ims_spt::session_desc, _ims_spt::sip_header, space_trim_dup(), and _ims_spt::type.
Referenced by parse_trigger_point().
00482 { 00483 xmlNodePtr child,saved=0; 00484 xmlChar *x; 00485 00486 ims_spt *spt,*spt2; 00487 int group; 00488 00489 spt = spt_to + *spt_cnt; 00490 00491 spt->condition_negated=0; 00492 spt->group=0; 00493 spt->type=IFC_UNKNOWN; 00494 spt->registration_type=0; 00495 00496 for(child=node->children ; child ; child=child->next) 00497 if (child->type==XML_ELEMENT_NODE) 00498 switch (child->name[0]) { 00499 case 'C':case 'c': //ConditionNegated 00500 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00501 spt->condition_negated=ifc_tBool2char(x); 00502 xmlFree(x); 00503 break; 00504 case 'G':case 'g': //Group 00505 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00506 spt->group=atoi((char*)x); 00507 xmlFree(x); 00508 break; 00509 case 'R':case 'r': //RequestUri 00510 spt->type=IFC_REQUEST_URI; 00511 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00512 space_trim_dup(&(spt->request_uri),(char*)x); 00513 xmlFree(x); 00514 break; 00515 case 'E':case 'e': //Extension 00516 parse_spt_extension(doc,child,spt); 00517 break; 00518 case 'M':case 'm': //method 00519 spt->type=IFC_METHOD; 00520 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00521 space_trim_dup(&(spt->method),(char*)x); 00522 xmlFree(x); 00523 break; 00524 case 'S':case 's': {//SIPHeader/SessionCase/SessionDescription 00525 switch(child->name[7]) { 00526 case 'E':case 'e'://SIP_HEADER 00527 spt->type=IFC_SIP_HEADER; 00528 parse_sip_header(doc,child,&(spt->sip_header)); 00529 saved = child; 00530 break; 00531 case 'C':case 'c'://Session Case 00532 spt->type=IFC_SESSION_CASE; 00533 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00534 spt->session_case=ifc_tDirectionOfRequest2char(x); 00535 xmlFree(x); 00536 break; 00537 case 'D':case 'd'://Session Description 00538 spt->type=IFC_SESSION_DESC; 00539 parse_session_desc(doc,child,&(spt->session_desc)); 00540 saved = child; 00541 break; 00542 } 00543 00544 } 00545 break; 00546 } 00547 *spt_cnt=*spt_cnt+1; 00548 00549 /* adding the other nodes for multiple groups */ 00550 for(child=node->children ; child ; child=child->next) 00551 if (child->type==XML_ELEMENT_NODE) 00552 switch (child->name[0]) { 00553 case 'G':case 'g': //Group 00554 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00555 group=atoi((char*)x); 00556 xmlFree(x); 00557 if (group != spt->group){ 00558 spt2 = spt_to + *spt_cnt; 00559 spt2->condition_negated = spt->condition_negated; 00560 spt2->group = group; 00561 spt2->type = spt->type; 00562 switch(spt2->type){ 00563 case IFC_REQUEST_URI: 00564 spt2->request_uri.len = spt->request_uri.len; 00565 spt2->request_uri.s = shm_malloc(spt2->request_uri.len); 00566 if (!spt2->request_uri.s){ 00567 LOG(L_ERR,"ERR:"M_NAME":parse_spt: Out of memory allocating %d bytes\n",spt->request_uri.len); 00568 break; 00569 } 00570 memcpy(spt2->request_uri.s,spt->request_uri.s,spt->request_uri.len); 00571 break; 00572 case IFC_METHOD: 00573 spt2->method.len = spt->method.len; 00574 spt2->method.s = shm_malloc(spt2->method.len); 00575 if (!spt2->method.s){ 00576 LOG(L_ERR,"ERR:"M_NAME":parse_spt: Out of memory allocating %d bytes\n",spt->method.len); 00577 break; 00578 } 00579 memcpy(spt2->method.s,spt->method.s,spt->method.len); 00580 break; 00581 case IFC_SIP_HEADER: 00582 parse_sip_header(doc,saved,&(spt2->sip_header)); 00583 break; 00584 case IFC_SESSION_CASE: 00585 spt2->session_case = spt->session_case; 00586 break; 00587 case IFC_SESSION_DESC: 00588 parse_session_desc(doc,saved,&(spt2->session_desc)); 00589 break; 00590 } 00591 spt2->registration_type = spt->registration_type; 00592 *spt_cnt = *spt_cnt+1; 00593 } 00594 break; 00595 } 00596 return 1; 00597 }
| static int parse_trigger_point | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_trigger_point * | tp | |||
| ) | [static] |
Parse a Trigger Point.
| doc | - the XML document | |
| node | - the current node | |
| tp | - structure to fill |
Definition at line 607 of file registrar_parser.c.
References _ims_trigger_point::condition_type_cnf, _ims_spt::group, IFC_DNF, ifc_tBool2char(), M_NAME, NULL, parse_spt(), _ims_trigger_point::spt, and _ims_trigger_point::spt_cnt.
Referenced by parse_filter_criteria().
00608 { 00609 xmlNodePtr child,child2; 00610 xmlChar *x; 00611 unsigned short spt_cnt=0; 00612 int i,j; 00613 ims_spt spttemp; 00614 tp->condition_type_cnf=IFC_DNF;//0 00615 tp->spt=NULL; 00616 tp->spt_cnt=0; 00617 00618 for(child=node->children ; child ; child=child->next) 00619 if (child->type==XML_ELEMENT_NODE) 00620 switch (child->name[0]) { 00621 case 'C':case 'c': //ConditionTypeCNF 00622 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00623 tp->condition_type_cnf=ifc_tBool2char(x); 00624 xmlFree(x); 00625 break; 00626 case 'S':case 's': //SPT - Service Point Trigger 00627 // COUNT all in another groups 00628 for(child2=child->children ; child2 ; child2=child2->next) 00629 if (child2->type==XML_ELEMENT_NODE) 00630 switch (child2->name[0]) { 00631 case 'G':case 'g': 00632 spt_cnt++; 00633 } 00634 break; 00635 } 00636 tp->spt = (ims_spt*) shm_malloc(sizeof(ims_spt)*spt_cnt); 00637 if (!tp->spt){ 00638 LOG(L_ERR,"ERR:"M_NAME":parse_trigger_point: Out of memory allocating %d bytes\n",sizeof(ims_spt)*spt_cnt); 00639 return 0; 00640 } 00641 for(child=node->children ; child ; child=child->next) 00642 if (child->type==XML_ELEMENT_NODE) 00643 switch (child->name[0]) { 00644 case 'S':case 's': //SPT - Service Point Trigger 00645 parse_spt(doc,child,tp->spt,&(tp->spt_cnt)); 00646 /*i=0; 00647 while(i<tp->spt_cnt&&tp->spt[i].group<spttemp.group) 00648 i++; 00649 for(j=tp->spt_cnt-1;j>=i;j--) 00650 tp->spt[j+1]=tp->spt[j]; 00651 tp->spt[i]=spttemp; 00652 tp->spt_cnt++;*/ 00653 00654 break; 00655 } 00656 00657 j=1; 00658 while(j){ 00659 j=0; 00660 for(i=0;i<tp->spt_cnt-1;i++) 00661 if (tp->spt[i].group > tp->spt[i+1].group){ 00662 j=1; 00663 spttemp = tp->spt[i]; 00664 tp->spt[i]=tp->spt[i+1]; 00665 tp->spt[i+1]=spttemp; 00666 } 00667 } 00668 return 1; 00669 }
| static int parse_application_server | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_application_server * | as | |||
| ) | [static] |
Parse a Application Server.
| doc | - the XML document | |
| node | - the current node | |
| as | - structure to fill |
Definition at line 677 of file registrar_parser.c.
References _ims_application_server::default_handling, IFC_NO_DEFAULT_HANDLING, ifc_tDefaultHandling2char(), NULL, _ims_application_server::server_name, _ims_application_server::service_info, and space_trim_dup().
Referenced by parse_filter_criteria().
00678 { 00679 xmlNodePtr child; 00680 xmlChar *x; 00681 as->server_name.s=NULL;as->server_name.len=0; 00682 as->default_handling=IFC_NO_DEFAULT_HANDLING; 00683 as->service_info.s=NULL;as->service_info.len=0; 00684 00685 for(child=node->children ; child ; child=child->next) 00686 if (child->type==XML_ELEMENT_NODE) 00687 switch (child->name[0]) { 00688 case 'S':case 's': {//ServerName / ServiceInfo 00689 switch (child->name[4]) { 00690 case 'E':case 'e': //ServerName 00691 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00692 space_trim_dup(&(as->server_name),(char*)x); 00693 xmlFree((char*)x); 00694 break; 00695 case 'I':case 'i': //ServiceInfo 00696 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00697 space_trim_dup(&(as->service_info),(char*)x); 00698 xmlFree(x); 00699 break; 00700 } 00701 break; 00702 } 00703 case 'D':case 'd': //DefaultHandling 00704 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00705 as->default_handling=ifc_tDefaultHandling2char(x); 00706 xmlFree(x); 00707 break; 00708 } 00709 return 1; 00710 }
| static int parse_filter_criteria | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_filter_criteria * | fc | |||
| ) | [static] |
Parse a Filter Criteria.
| doc | - the XML document | |
| node | - the current node | |
| fc | - structure to fill |
Definition at line 721 of file registrar_parser.c.
References _ims_filter_criteria::application_server, ifc_tProfilePartIndicator2char(), M_NAME, NULL, parse_application_server(), parse_trigger_point(), _ims_filter_criteria::priority, _ims_filter_criteria::profile_part_indicator, and _ims_filter_criteria::trigger_point.
Referenced by parse_service_profile().
00722 { 00723 xmlNodePtr child; 00724 xmlChar *x; 00725 char k; 00726 fc->priority=0; 00727 fc->trigger_point=NULL; 00728 fc->profile_part_indicator=NULL; 00729 //fc->apllication_server init mai tarziu 00730 for(child=node->children ; child ; child=child->next) 00731 if (child->type==XML_ELEMENT_NODE) 00732 switch (child->name[3]) { 00733 case 'O':case 'o': //Priority 00734 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00735 fc->priority=atoi((char*)x); 00736 xmlFree(x); 00737 break; 00738 case 'G':case 'g': //TriggerPoint 00739 fc->trigger_point=(ims_trigger_point*) shm_malloc(sizeof(ims_trigger_point)); 00740 if (!fc->trigger_point){ 00741 LOG(L_ERR,"ERR:"M_NAME":parse_filter_criteria: Out of memory allocating %d bytes\n",sizeof(ims_trigger_point)); 00742 break; 00743 } 00744 if (!parse_trigger_point(doc,child,fc->trigger_point)){ 00745 shm_free(fc->trigger_point); 00746 fc->trigger_point=0; 00747 return 0; 00748 } 00749 break; 00750 case 'L':case 'l': //ApplicationServer 00751 parse_application_server(doc,child,&(fc->application_server)); 00752 break; 00753 case 'F':case 'f': //ProfilePartIndicator 00754 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00755 k = ifc_tProfilePartIndicator2char(x); 00756 if (k<0) break; 00757 fc->profile_part_indicator=(char*)shm_malloc(sizeof(char)); 00758 if (!fc->profile_part_indicator){ 00759 LOG(L_ERR,"ERR:"M_NAME":parse_filter_criteria: Out of memory allocating %d bytes\n",sizeof(ims_trigger_point)); 00760 break; 00761 } 00762 *fc->profile_part_indicator=k; 00763 xmlFree(x); 00764 break; 00765 } 00766 return 1; 00767 }
| static int parse_cn_service_auth | ( | xmlDocPtr | doc, | |
| xmlNodePtr | node, | |||
| ims_cn_service_auth * | cn | |||
| ) | [static] |
Parse a Core Network Service Authorization.
| doc | - the XML document | |
| node | - the current node | |
| cn | - structure to fill |
Definition at line 777 of file registrar_parser.c.
References _ims_cn_service_auth::subscribed_media_profile_id.
Referenced by parse_service_profile().
00778 { 00779 xmlNodePtr child; 00780 xmlChar *x; 00781 cn->subscribed_media_profile_id=-1; 00782 for(child=node->children ; child ; child=child->next) 00783 if (child->type==XML_ELEMENT_NODE) 00784 switch (child->name[0]) { 00785 case 'S':case 's': //BarringIndication 00786 x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); 00787 cn->subscribed_media_profile_id=atoi((char*)x); 00788 xmlFree(x); 00789 return 1; 00790 break; 00791 00792 } 00793 return 0; 00794 }
| static int parse_service_profile | ( | xmlDocPtr | doc, | |
| xmlNodePtr | root, | |||
| ims_service_profile * | sp | |||
| ) | [static] |
Parse a Core Network Service Profile.