Browse code

core: PAI and PPI parsing support fixed

- use a new function to identify hdr type instead of 'case' construct
- reported by Juha Heinanen
(cherry picked from commit 78f069c3726085902101a55d3bb98f0be7549b60)

Daniel-Constantin Mierla authored on 01/11/2009 13:06:04 • Juha Heinanen committed on 01/11/2009 12:50:42
Showing 3 changed files
... ...
@@ -216,6 +216,15 @@ void clean_hdr_field(struct hdr_field* hf)
216 216
 		case HDR_PATH_T:
217 217
 		case HDR_PRIVACY_T:
218 218
 			break;
219
+
220
+		case HDR_PPI_T:
221
+			free_to(hf->parsed);
222
+			break;
223
+
224
+		case HDR_PAI_T:
225
+			free_to(hf->parsed);
226
+			break;
227
+
219 228
 		default:
220 229
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
221 230
 			    hf->type);
... ...
@@ -243,6 +243,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
243 243
 		case HDR_PROXY_AUTHENTICATE_T:
244 244
 	    case HDR_PATH_T:
245 245
 	    case HDR_PRIVACY_T:
246
+	    case HDR_PAI_T:
247
+	    case HDR_PPI_T:
246 248
 		case HDR_OTHER_T:
247 249
 			/* just skip over it */
248 250
 			hdr->body.s=tmp;
... ...
@@ -528,6 +530,14 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
528 530
 				if (msg->privacy==0) msg->privacy=hf;
529 531
 				msg->parsed_flag|=HDR_PRIVACY_F;
530 532
 				break;
533
+		    case HDR_PAI_T:
534
+				if (msg->pai==0) msg->pai=hf;
535
+				msg->parsed_flag|=HDR_PAI_F;
536
+				break;
537
+		    case HDR_PPI_T:
538
+				if (msg->ppi==0) msg->ppi=hf;
539
+				msg->parsed_flag|=HDR_PPI_F;
540
+				break;
531 541
 			default:
532 542
 				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
533 543
 							hf->type);
... ...
@@ -163,6 +163,24 @@ static inline char* skip_ws(char* p, unsigned int size)
163 163
         }
164 164
 
165 165
 
166
+int hdr_update_type(struct hdr_field* hdr)
167
+{
168
+	if(hdr==0 || hdr->name.s==0)
169
+		return -1;
170
+	switch(hdr->name.len) {
171
+		case 19:
172
+			if(strncasecmp(hdr->name.s, "P-Asserted-Identity", 19)==0)
173
+				hdr->type = HDR_PAI_T;
174
+		break;
175
+		case 20:
176
+			if(strncasecmp(hdr->name.s, "P-Preferred-Identity", 20)==0)
177
+				hdr->type = HDR_PPI_T;
178
+		break;
179
+	}
180
+
181
+	return 0;
182
+}
183
+
166 184
 char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
167 185
 {
168 186
 	register char* p;
... ...
@@ -242,6 +260,8 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
242 260
 	} else {
243 261
 		hdr->type = HDR_OTHER_T;
244 262
 		hdr->name.len = p - hdr->name.s;
263
+		hdr_update_type(hdr);
245 264
 		return (p + 1);
246 265
 	}
247 266
 }
267
+