Browse code

core/parser: Add parser for 'flags' param in Contact header

Alex Hermann authored on 31/01/2019 16:28:33 • Henning Westerholt committed on 11/02/2019 20:42:26
Showing 4 changed files
... ...
@@ -244,6 +244,7 @@ int parse_contacts(str* _s, contact_t** _c)
244 244
 			c->methods = hooks.contact.methods;
245 245
 			c->instance = hooks.contact.instance;
246 246
 			c->reg_id = hooks.contact.reg_id;
247
+			c->flags = hooks.contact.flags;
247 248
 
248 249
 			if (_s->len == 0) goto ok;
249 250
 		}
... ...
@@ -314,6 +315,7 @@ void print_contacts(FILE* _o, contact_t* _c)
314 315
 		fprintf(_o, "methods : %p\n", ptr->methods);
315 316
 		fprintf(_o, "instance: %p\n", ptr->instance);
316 317
 		fprintf(_o, "reg-id  : %p\n", ptr->reg_id);
318
+		fprintf(_o, "flags   : %p\n", ptr->flags);
317 319
 		fprintf(_o, "len     : %d\n", ptr->len);
318 320
 		if (ptr->params) {
319 321
 			print_params(_o, ptr->params);
... ...
@@ -50,6 +50,7 @@ typedef struct contact {
50 50
 	param_t* received;      /* received parameter hook */
51 51
 	param_t* instance;      /* sip.instance parameter hook */
52 52
 	param_t* reg_id;        /* reg-id parameter hook */
53
+	param_t* flags;         /* flags parameter hook */
53 54
 	param_t* params;        /* List of all parameters */
54 55
 	int len;                /* Total length of the element */
55 56
         struct contact* next; /* Next contact in the list */
... ...
@@ -173,6 +173,14 @@ static inline void parse_contact_class(param_hooks_t *_h, param_t *_p)
173 173
 				_h->contact.ob = _p;
174 174
 			}
175 175
 			break;
176
+		case 'f':
177
+		case 'F':
178
+			if ((_p->name.len == 5) &&
179
+				(!strncasecmp(_p->name.s + 1, "lags", 4))) {
180
+				_p->type = P_FLAGS;
181
+				_h->contact.flags = _p;
182
+			}
183
+			break;
176 184
 	}
177 185
 }
178 186
 
... ...
@@ -673,6 +681,9 @@ static inline void print_param(FILE *_o, param_t *_p)
673 681
 		case P_METHODS:
674 682
 			type = "P_METHODS";
675 683
 			break;
684
+		case P_FLAGS:
685
+			type = "P_FLAGS";
686
+			break;
676 687
 		case P_TRANSPORT:
677 688
 			type = "P_TRANSPORT";
678 689
 			break;
... ...
@@ -44,6 +44,7 @@ typedef enum ptype {
44 44
 	P_EXPIRES,   /*!< Contact: expires parameter */
45 45
 	P_METHODS,   /*!< Contact: methods parameter */
46 46
 	P_RECEIVED,  /*!< Contact: received parameter */
47
+	P_FLAGS,     /*!< Contact: flags parameter */
47 48
 	P_TRANSPORT, /*!< URI: transport parameter */
48 49
 	P_LR,        /*!< URI: lr parameter */
49 50
 	P_R2,        /*!< URI: r2 parameter (ser specific) */
... ...
@@ -98,6 +99,7 @@ struct contact_hooks {
98 99
 	struct param* instance; /*!< sip.instance parameter */
99 100
 	struct param* reg_id;   /*!< reg-id parameter */
100 101
 	struct param* ob;       /*!< ob parameter */
102
+	struct param* flags;    /*!< flags parameter */
101 103
 };
102 104
 
103 105