Browse code

Contact header field parser extended to parse "received" parameter.

Jan Janak authored on 01/09/2004 11:56:58
Showing 4 changed files
... ...
@@ -245,6 +245,7 @@ int parse_contacts(str* _s, contact_t** _c)
245 245
 
246 246
 			c->q = hooks.contact.q;
247 247
 			c->expires = hooks.contact.expires;
248
+			c->received = hooks.contact.received;
248 249
 			c->method = hooks.contact.method;
249 250
 
250 251
 			if (_s->len == 0) goto ok;
... ...
@@ -306,11 +307,12 @@ void print_contacts(FILE* _o, contact_t* _c)
306 307
 
307 308
 	while(ptr) {
308 309
 		fprintf(_o, "---Contact---\n");
309
-		fprintf(_o, "name   : '%.*s'\n", ptr->name.len, ptr->name.s);
310
-		fprintf(_o, "URI    : '%.*s'\n", ptr->uri.len, ptr->uri.s);
311
-		fprintf(_o, "q      : %p\n", ptr->q);
312
-		fprintf(_o, "expires: %p\n", ptr->expires);
313
-		fprintf(_o, "method : %p\n", ptr->method);
310
+		fprintf(_o, "name    : '%.*s'\n", ptr->name.len, ptr->name.s);
311
+		fprintf(_o, "URI     : '%.*s'\n", ptr->uri.len, ptr->uri.s);
312
+		fprintf(_o, "q       : %p\n", ptr->q);
313
+		fprintf(_o, "expires : %p\n", ptr->expires);
314
+		fprintf(_o, "received: %p\n", ptr->received);
315
+		fprintf(_o, "method  : %p\n", ptr->method);
314 316
 		if (ptr->params) {
315 317
 			print_params(_o, ptr->params);
316 318
 		}
... ...
@@ -49,6 +49,7 @@ typedef struct contact {
49 49
 	param_t* q;             /* q parameter hook */
50 50
 	param_t* expires;       /* expires parameter hook */
51 51
 	param_t* method;        /* method parameter hook */
52
+	param_t* received;      /* received parameter hook */
52 53
 	param_t* params;        /* List of all parameters */
53 54
         struct contact* next; /* Next contact in the list */
54 55
 } contact_t;
... ...
@@ -80,6 +80,15 @@ static inline void parse_contact_class(param_hooks_t* _h, param_t* _p)
80 80
 			_h->contact.method = _p;
81 81
 		}
82 82
 		break;
83
+		
84
+	case 'r':
85
+	case 'R':
86
+		if ((_p->name.len == 8) &&
87
+		    (!strncasecmp(_p->name.s + 1, "eceived", 7))) {
88
+			_p->type = P_RECEIVED;
89
+			_h->contact.method = _p;
90
+		}
91
+		break;
83 92
 	}
84 93
 }
85 94
 
... ...
@@ -465,6 +474,7 @@ static inline void print_param(FILE* _o, param_t* _p)
465 474
 	case P_R2:        type = "P_R2";        break;
466 475
 	case P_MADDR:     type = "P_MADDR";     break;
467 476
 	case P_TTL:       type = "P_TTL";       break;
477
+	case P_RECEIVED:  type = "P_RECEIVED";  break;
468 478
 	default:          type = "UNKNOWN";     break;
469 479
 	}
470 480
 	
... ...
@@ -47,6 +47,7 @@ typedef enum ptype {
47 47
 	P_Q,         /* Contact: q parameter */
48 48
 	P_EXPIRES,   /* Contact: expires parameter */
49 49
 	P_METHOD,    /* Contact: method parameter */
50
+	P_RECEIVED,  /* Contact: received parameter */
50 51
 	P_TRANSPORT, /* URI: transport parameter */
51 52
 	P_LR,        /* URI: lr parameter */
52 53
 	P_R2,        /* URI: r2 parameter (ser specific) */
... ...
@@ -81,9 +82,10 @@ typedef struct param {
81 82
  * Hooks to well known parameters for contact class of parameters
82 83
  */
83 84
 struct contact_hooks {
84
-	struct param* expires; /* expires parameter */
85
-	struct param* q;       /* q parameter */
86
-	struct param* method;  /* method parameter */
85
+	struct param* expires;  /* expires parameter */
86
+	struct param* q;        /* q parameter */
87
+	struct param* method;   /* method parameter */
88
+	struct param* received; /* received parameter */
87 89
 };
88 90
 
89 91