예제 #1
0
/**
 * Parse the Public Identity.
 * @param doc - the XML document
 * @param root - the current node
 * @param pi - structure to fill
 * @returns 1 on success, 0 on failure
 */
static int parse_public_identity(xmlDocPtr doc, xmlNodePtr root, ims_public_identity *pi)
{
	xmlNodePtr child;
	xmlChar *x;
	
	for(child=root->children;child;child=child->next)
		if (child->type==XML_ELEMENT_NODE)
			switch (child->name[0]){
				case 'I': case 'i':
					if (!pi->public_identity.len){
						x = xmlNodeListGetString(doc,child->xmlChildrenNode,1);
						space_trim_dup(&(pi->public_identity),x);
						xmlFree(x);
					}					
					break;
				case 'B': case 'b':
					x = xmlNodeListGetString(doc,child->xmlChildrenNode,1);
					pi->barring = ifc_tBool2char(x);
					xmlFree(x);
					break;				
			}
	return 1;
}
예제 #2
0
/**
 * Parse the Public Identity.
 * @param doc - the XML document
 * @param root - the current node
 * @param pi - structure to fill
 * @returns 1 on success, 0 on failure , 2 if its a wildcardpsi
 */
static int parse_public_identity(xmlDocPtr doc, xmlNodePtr root, ims_public_identity *pi)
{
	xmlNodePtr child;
	xmlNodePtr grandson;
	xmlChar *x;
	int return_code=1;
	
	for(child=root->children;child;child=child->next)
		if (child->type==XML_ELEMENT_NODE)
			switch (child->name[0]){
				case 'I': case 'i':
					if (!pi->public_identity.len){
						x = xmlNodeListGetString(doc,child->xmlChildrenNode,1);
						space_trim_dup(&(pi->public_identity),(char*)x);
						xmlFree(x);
					}					
					break;
				case 'B': case 'b':
					x = xmlNodeListGetString(doc,child->xmlChildrenNode,1);
					pi->barring = ifc_tBool2char(x);
					xmlFree(x);
					break;
				//lets add something 
				case 'E' : case 'e':
					// that would be Extension
					// here i need to parse Identity Type 
					// if its two then  wildcardedpsi
					// and then extension!!!
					// I have to check how you parse this shit

					for(grandson=child->children;grandson;grandson=grandson->next)
					{
												
						if (grandson->type==XML_ELEMENT_NODE)
						{
							switch (grandson->name[0]) {
								case 'I' : case 'i':
									//identity type 0 public identity 1 distinct psi 2 wildcard psi
									//x = xmlNodeListGetString(doc,grandson->xmlChildrenNode,1);
									// i need to compare x with 2, but i have to trim leading 
									// space characters or tabs			
									//xmlFree(x);
									break;
								case 'W' : case 'w':
									//wildcardpsi
									if(!scscf_support_wildcardPSI) {
										LOG(L_ERR,"Configured without support for Wildcard PSI and got one from HSS\n");
										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");
									}
									
									x = xmlNodeListGetString(doc,grandson->xmlChildrenNode,1);
									space_trim_dup(&(pi->wildcarded_psi),(char*)x);
									
									xmlFree(x);
									return_code=2;
									break;
								default :
									break;
							}
						}
					}
										
					break;				
			}

	return return_code;
}
예제 #3
0
/**
 *	Parse a Trigger Point.
 * @param doc - the XML document
 * @param node - the current node
 * @param tp - structure to fill
 * @returns 1 on success, 0 on failure
 * \todo An effective sort for the priority
 */
static int parse_trigger_point(xmlDocPtr doc,xmlNodePtr node,ims_trigger_point *tp)
{
	xmlNodePtr child,child2;
	xmlChar *x;
	unsigned short spt_cnt=0;
	int i,j;
	ims_spt spttemp;
	tp->condition_type_cnf=IFC_DNF;//0
	tp->spt=NULL;
	tp->spt_cnt=0;

	for(child=node->children ; child ; child=child->next)
		if (child->type==XML_ELEMENT_NODE)
			switch (child->name[0]) {
				case 'C':case 'c': //ConditionTypeCNF
					x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
					tp->condition_type_cnf=ifc_tBool2char(x);
					xmlFree(x);
					break;
				case 'S':case 's': //SPT - Service Point Trigger
					// COUNT all in another groups
					for(child2=child->children ; child2 ; child2=child2->next)
						if (child2->type==XML_ELEMENT_NODE)
							switch (child2->name[0]) {
								case 'G':case 'g':
									spt_cnt++;
							}
					break;
			}
	tp->spt = (ims_spt*) shm_malloc(sizeof(ims_spt)*spt_cnt);
	if (!tp->spt){
		LM_ERR("Out of memory allocating %lx bytes\n",sizeof(ims_spt)*spt_cnt);
		return 0;
	}
	for(child=node->children ; child ; child=child->next)
		if (child->type==XML_ELEMENT_NODE)
			switch (child->name[0]) {
				case 'S':case 's': //SPT - Service Point Trigger
					parse_spt(doc,child,tp->spt,&(tp->spt_cnt));
					/*i=0;
					while(i<tp->spt_cnt&&tp->spt[i].group<spttemp.group)
						i++;
					for(j=tp->spt_cnt-1;j>=i;j--)
						tp->spt[j+1]=tp->spt[j];
					tp->spt[i]=spttemp;
					tp->spt_cnt++;*/
			
					break;
			}
	
	j=1;
	while(j){
		j=0;
		for(i=0;i<tp->spt_cnt-1;i++)
			if (tp->spt[i].group > tp->spt[i+1].group){
				j=1;
				spttemp = tp->spt[i];
				tp->spt[i]=tp->spt[i+1];
				tp->spt[i+1]=spttemp;
			}			
	}
	return 1;
}
예제 #4
0
/**
 *	Parse a Service Point Trigger.
 * @param doc - the XML document
 * @param node - the current node
 * @param spt_to - structure to fill
 * @param spt_cnt - structure to fill with the spt count
 * @returns 1 on success, 0 on failure
 */
static int parse_spt(xmlDocPtr doc,xmlNodePtr node,ims_spt *spt_to,unsigned short *spt_cnt)
{
	xmlNodePtr child,saved=0;
	xmlChar *x;

	ims_spt *spt,*spt2;
	int group;
	
	spt = spt_to + *spt_cnt;
	
	spt->condition_negated=0;
	spt->group=0;
	spt->type=IFC_UNKNOWN;
	spt->registration_type=0;

	for(child=node->children ; child ; child=child->next)
		if (child->type==XML_ELEMENT_NODE)
			switch (child->name[0]) {
				case 'C':case 'c': //ConditionNegated
					x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
					spt->condition_negated=ifc_tBool2char(x);
					xmlFree(x);
					break;
				case 'G':case 'g': //Group
					x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
					spt->group=atoi((char*)x);
					xmlFree(x);
					break;
				case 'R':case 'r': //RequestUri
					spt->type=IFC_REQUEST_URI;
					x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
					space_trim_dup(&(spt->request_uri),(char*)x);
					xmlFree(x);
					break;
				case 'E':case 'e': //Extension
				    parse_spt_extension(doc,child,spt);
					break;
				case 'M':case 'm': //method
					spt->type=IFC_METHOD;
					x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
					space_trim_dup(&(spt->method),(char*)x);
					xmlFree(x);
					break;
				case 'S':case 's': {//SIPHeader/SessionCase/SessionDescription
					switch(child->name[7]) {
						case 'E':case 'e'://SIP_HEADER
							spt->type=IFC_SIP_HEADER;
							parse_sip_header(doc,child,&(spt->sip_header));
							saved = child;
							break;
						case 'C':case 'c'://Session Case
							spt->type=IFC_SESSION_CASE;
							x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
							spt->session_case=ifc_tDirectionOfRequest2char(x);
							xmlFree(x);
							break;
						case 'D':case 'd'://Session Description
							spt->type=IFC_SESSION_DESC;
							parse_session_desc(doc,child,&(spt->session_desc));
							saved = child;
							break;
					}

				}
					break;
			}
	*spt_cnt=*spt_cnt+1;

	/* adding the other nodes for multiple groups */			
	for(child=node->children ; child ; child=child->next)
		if (child->type==XML_ELEMENT_NODE)
			switch (child->name[0]) {
				case 'G':case 'g': //Group
					x = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
					group=atoi((char*)x);
					xmlFree(x);
					if (group != spt->group){
						spt2 = spt_to + *spt_cnt;
						spt2->condition_negated = spt->condition_negated;
						spt2->group = group;
						spt2->type = spt->type;
						switch(spt2->type){
							case IFC_REQUEST_URI:
								spt2->request_uri.len = spt->request_uri.len;
								spt2->request_uri.s = shm_malloc(spt2->request_uri.len);
								if (!spt2->request_uri.s){
									LM_ERR("Out of memory allocating %d bytes\n",spt->request_uri.len);
									break;
								}
								memcpy(spt2->request_uri.s,spt->request_uri.s,spt->request_uri.len);
								break;
							case IFC_METHOD:
								spt2->method.len = spt->method.len;
								spt2->method.s = shm_malloc(spt2->method.len);
								if (!spt2->method.s){
									LM_ERR("Out of memory allocating %d bytes\n",spt->method.len);
									break;
								}
								memcpy(spt2->method.s,spt->method.s,spt->method.len);
								break;
							case IFC_SIP_HEADER:
								parse_sip_header(doc,saved,&(spt2->sip_header));
								break;
							case IFC_SESSION_CASE:
								spt2->session_case = spt->session_case;
								break;
							case IFC_SESSION_DESC:
								parse_session_desc(doc,saved,&(spt2->session_desc));
								break;								
						}
						spt2->registration_type = spt->registration_type;
						*spt_cnt = *spt_cnt+1;						
					}
					break;
			}
	return 1;			
}