Bläddra i källkod

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

Alex Hermann 6 år sedan
förälder
incheckning
5af1a114d8

+ 2 - 0
src/core/parser/contact/contact.c

@@ -244,6 +244,7 @@ int parse_contacts(str* _s, contact_t** _c)
 			c->methods = hooks.contact.methods;
 			c->instance = hooks.contact.instance;
 			c->reg_id = hooks.contact.reg_id;
+			c->flags = hooks.contact.flags;
 
 			if (_s->len == 0) goto ok;
 		}
@@ -314,6 +315,7 @@ void print_contacts(FILE* _o, contact_t* _c)
 		fprintf(_o, "methods : %p\n", ptr->methods);
 		fprintf(_o, "instance: %p\n", ptr->instance);
 		fprintf(_o, "reg-id  : %p\n", ptr->reg_id);
+		fprintf(_o, "flags   : %p\n", ptr->flags);
 		fprintf(_o, "len     : %d\n", ptr->len);
 		if (ptr->params) {
 			print_params(_o, ptr->params);

+ 1 - 0
src/core/parser/contact/contact.h

@@ -50,6 +50,7 @@ typedef struct contact {
 	param_t* received;      /* received parameter hook */
 	param_t* instance;      /* sip.instance parameter hook */
 	param_t* reg_id;        /* reg-id parameter hook */
+	param_t* flags;         /* flags parameter hook */
 	param_t* params;        /* List of all parameters */
 	int len;                /* Total length of the element */
         struct contact* next; /* Next contact in the list */

+ 11 - 0
src/core/parser/parse_param.c

@@ -173,6 +173,14 @@ static inline void parse_contact_class(param_hooks_t *_h, param_t *_p)
 				_h->contact.ob = _p;
 			}
 			break;
+		case 'f':
+		case 'F':
+			if ((_p->name.len == 5) &&
+				(!strncasecmp(_p->name.s + 1, "lags", 4))) {
+				_p->type = P_FLAGS;
+				_h->contact.flags = _p;
+			}
+			break;
 	}
 }
 
@@ -673,6 +681,9 @@ static inline void print_param(FILE *_o, param_t *_p)
 		case P_METHODS:
 			type = "P_METHODS";
 			break;
+		case P_FLAGS:
+			type = "P_FLAGS";
+			break;
 		case P_TRANSPORT:
 			type = "P_TRANSPORT";
 			break;

+ 2 - 0
src/core/parser/parse_param.h

@@ -44,6 +44,7 @@ typedef enum ptype {
 	P_EXPIRES,   /*!< Contact: expires parameter */
 	P_METHODS,   /*!< Contact: methods parameter */
 	P_RECEIVED,  /*!< Contact: received parameter */
+	P_FLAGS,     /*!< Contact: flags parameter */
 	P_TRANSPORT, /*!< URI: transport parameter */
 	P_LR,        /*!< URI: lr parameter */
 	P_R2,        /*!< URI: r2 parameter (ser specific) */
@@ -98,6 +99,7 @@ struct contact_hooks {
 	struct param* instance; /*!< sip.instance parameter */
 	struct param* reg_id;   /*!< reg-id parameter */
 	struct param* ob;       /*!< ob parameter */
+	struct param* flags;    /*!< flags parameter */
 };