625a626,634
> struct isup_data
> {
> 	int found;
> 	char called_party_no[25];
>     char calling_party_no[25];
>     char jurisdiction[7];
> 	char hop_counter[3];
>     char originating_line[3]; 
> };
15268c15277
< 	default:
---
> 	default: 
15279a15289,15412
> static struct isup_data find_sipt_isup(struct sip_request *req)
> {
> 	int isup_start = 0;
> 	int isup_end = 0;
> 	struct isup_data isup={0};
>     int isup_byte = 0;
>     int optional_parameter;
> 	char multipart_message_boundary[30];
> 	char content_type_isup[35] = "Content-Type: application/isup\0";
> 	int bo = 0, k = 0, i = 0;
> 
> 	multipart_message_boundary[0]='\0';
> 	for(i=0; i<strlen(req->data)-8; i++)
> 		if((req->data[i]=='b')&&(req->data[i+1]=='o')&&(req->data[i+2]=='u')&&(req->data[i+3]=='n')&&(req->data[i+4]=='d')&&(req->data[i+5]=='a')&&(req->data[i+6]=='r')&&(req->data[i+7]=='y')) {
> 		k=0;
> 		while(req->data[k+i+9]!='\r')
> 		{
> 			multipart_message_boundary[k]=req->data[k+i+9];
> 			k++;
> 		}
> 		multipart_message_boundary[k]='\0';
> 		break;
> 		}
> 	
>     bo = 0; k = 0; i = 0;
> 	do{
> 		if ((unsigned char)(req->data[i]) == content_type_isup[k]) {    
> 				if (k == 0) isup_start = i;
> 				i++;
> 				k++;
> 		}
> 		else {
> 	       i++;
> 	       k = 0;  
> 		   isup_start = 0;
> 	    }
> 	 }while((i < req->len) && (k < strlen(content_type_isup)));
> 	 if(isup_start!=0) {
> 	   do{
> 	       if(((unsigned char)(req->data[i]) == '\r') && ((unsigned char)(req->data[i+1]) == '\n') && ((unsigned char)(req->data[i+2]) == '\r') && ((unsigned char)(req->data[i+3]) == '\n')) {
> 					bo = 1;
> 					i+=4;
> 				}
> 	       else i++;
> 	   }while((!bo) && (i < req->len-3));
> 	   isup_start = i;
> 	 }
> 	
> 	 if (isup_start!=0) {
> 		  k = 0;
> 		  i = isup_start+1; 
> 		  do{
> 			if ((unsigned char)(req->data[i]) == multipart_message_boundary[k]){
> 					if (k == 0) isup_end = i-4;
> 					i++;
> 					k++;
> 			}
> 			else {
> 					i++;
> 					k = 0;  
> 					isup_end = 0;
> 			}
> 		  }while((i < req->len) && (k < strlen(multipart_message_boundary)));
> 
>     if((int)((unsigned char)(req->data[isup_start])) == 1){
> 		isup.found = 1;
> 		isup_byte = 13;
> 		k = 0;
> 		for(i = isup_start+isup_byte+1; i < isup_start+isup_byte+(int)((unsigned char)(req->data[isup_start+isup_byte-1])); i++) { 
>           isup.called_party_no[k] = 48+(int)((unsigned char)(req->data[i]))%16;
>           isup.called_party_no[k+1] = 48+(int)((unsigned char)(req->data[i]))/16;
>           k+=2;
> 		}
> 		isup.called_party_no[k] = '\0';
> 		isup_byte = isup_byte+(int)((unsigned char)(req->data[isup_start+isup_byte-1]));
> 		optional_parameter = (int)((unsigned char)(req->data[isup_start+isup_byte]));
>   
> 	while(optional_parameter!=0) {  
> 			switch(optional_parameter) {
> 					case 10:
> 						k=0;
> 						for(i=isup_start+isup_byte+3; i < isup_start+isup_byte + ((int) ((unsigned char)(req->data[isup_start+isup_byte+1])))+2; i++) {
> 								isup.calling_party_no[k] = 48+(int)((unsigned char)(req->data[i]))%16;
> 								isup.calling_party_no[k+1] = 48+(int)((unsigned char)(req->data[i]))/16;
> 								k+=2;
> 						}  
> 						isup.calling_party_no[k] = '\0';
> 						isup_byte = isup_byte+(int)((unsigned char)(req->data[isup_start+isup_byte+1]))+3;
> 						break;
> 					case 61:
> 						k = 0;
> 						isup.hop_counter[k] = 48+(int)((unsigned char)(req->data[isup_start+isup_byte+1]))/10;
> 						isup.hop_counter[k+1] = 48+(int)((unsigned char)(req->data[isup_start+isup_byte+1]))%10;
> 						isup.hop_counter[k+2] = '\0';
> 						isup_byte+=3;
> 						break;
> 					case 196:
> 						k = 0;
> 						for(i=isup_start+isup_byte+1; i < isup_start+isup_byte + 4; i++) {
> 								isup.jurisdiction[k] = 48+(int)((unsigned char)(req->data[i]))%16;
> 								isup.jurisdiction[k+1] = 48+(int)((unsigned char)(req->data[i]))/16;
> 								k+=2;
> 						}
> 						isup.jurisdiction[k] = '\0';
> 						isup_byte+=5;
> 						break;
> 					case 234:
> 						k = 0;
> 						isup.originating_line[k] = 48+(int)((unsigned char)(req->data[isup_start+isup_byte+1]))/10;
> 						isup.originating_line[k+1] = 48+(int)((unsigned char)(req->data[isup_start+isup_byte+1]))%10;
>      					isup.originating_line[k+2] = '\0';
> 						isup_byte=isup_byte+3; 
> 						break;
> 					default:
> 			  	        isup_byte = isup_byte+(int)((unsigned char)(req->data[isup_start+isup_byte]))+2;
> 						break;
> 				}   
> 				optional_parameter = (int)((unsigned char)(req->data[isup_start+isup_byte-1]));
> 			}
> 		}
> 	}
> 	return isup;
> }
> 
15289a15423
> 	struct isup_data isup;
15320c15454,15455
< 
---
> 	
> 	isup = find_sipt_isup(&req); 
15381c15516,15522
< 
---
> 	if(isup.found == 1) {
> 		pbx_builtin_setvar_helper(p->owner, "CALLED_PARTY_NO", isup.called_party_no);
> 		pbx_builtin_setvar_helper(p->owner, "CALLING_PARTY_NO", isup.calling_party_no);
> 		pbx_builtin_setvar_helper(p->owner, "JURISDICTION", isup.jurisdiction);
> 		pbx_builtin_setvar_helper(p->owner, "HOP_COUNTER", isup.hop_counter);
> 	    pbx_builtin_setvar_helper(p->owner, "ORIGINATING_LINE", isup.originating_line);
> 	}
