Browse code

Extend the parser parameter with support for dialog event parameters.

This patch extends the generic parameter parser in the sip-router core
with support for the following dialog event package parameters: call-id,
from-tag, to-tag, include-session-description, and sla.

The patch introduces a new parameter class called CLASS_EVENT_DIALOG
which can be used to instruct the parser to look for the well-known
parameters above.

It also adds a new parameter hook structure called event_dialog_hooks
which will be filled with pointers to the well known parameters if
the are found in the parsed string.

Jan Janak authored on 17/03/2009 16:17:44
Showing 2 changed files
... ...
@@ -43,6 +43,66 @@
43 43
 #include "parse_param.h"
44 44
 
45 45
 
46
+static inline void parse_event_dialog_class(param_hooks_t* h, param_t* p)
47
+{
48
+
49
+	if (!p->name.s) {
50
+		LOG(L_ERR, "ERROR: parse_event_dialog_class: empty value\n");
51
+		return;
52
+	}
53
+	if (!h) {
54
+		LOG(L_CRIT, "BUG: parse_event_dialog_class: NULL param hook pointer\n");
55
+		return;
56
+	}
57
+	switch(p->name.s[0]) {
58
+	case 'c':
59
+	case 'C':
60
+		if ((p->name.len == 7) &&
61
+		    (!strncasecmp(p->name.s + 1, "all-id", 6))) {
62
+			p->type = P_CALL_ID;
63
+			h->event_dialog.call_id = p;
64
+		}
65
+		break;
66
+
67
+	case 'f':
68
+	case 'F':
69
+		if ((p->name.len == 8) &&
70
+		    (!strncasecmp(p->name.s + 1, "rom-tag", 7))) {
71
+			p->type = P_FROM_TAG;
72
+			h->event_dialog.from_tag = p;
73
+		}
74
+		break;
75
+
76
+	case 't':
77
+	case 'T':
78
+		if ((p->name.len == 6) &&
79
+		    (!strncasecmp(p->name.s + 1, "o-tag", 5))) {
80
+			p->type = P_TO_TAG;
81
+			h->event_dialog.to_tag = p;
82
+		}
83
+		break;
84
+
85
+	case 'i':
86
+	case 'I':
87
+		if ((p->name.len == 27) &&
88
+		    (!strncasecmp(p->name.s + 1, "nclude-session-description", 26))) {
89
+			p->type = P_ISD;
90
+			h->event_dialog.include_session_description = p;
91
+		}
92
+		break;
93
+
94
+	case 's':
95
+	case 'S':
96
+		if ((p->name.len == 3) &&
97
+		    (!strncasecmp(p->name.s + 1, "la", 2))) {
98
+			p->type = P_SLA;
99
+			h->event_dialog.sla = p;
100
+		}
101
+		break;
102
+	}
103
+}
104
+
105
+
46 106
 /*
47 107
  * Try to find out parameter name, recognized parameters
48 108
  * are q, expires and method
... ...
@@ -328,6 +388,7 @@ static inline void parse_param_name(str* _s, pclass_t _c, param_hooks_t* _h, par
328 388
 	switch(_c) {
329 389
 	case CLASS_CONTACT: parse_contact_class(_h, _p); break;
330 390
 	case CLASS_URI:     parse_uri_class(_h, _p);     break;
391
+	case CLASS_EVENT_DIALOG: parse_event_dialog_class(_h, _p); break;
331 392
 	default: break;
332 393
 	}
333 394
 }
... ...
@@ -545,6 +606,11 @@ static inline void print_param(FILE* _o, param_t* _p)
545 606
 	case P_DSTPORT:   type = "P_DSTPORT";   break;
546 607
 	case P_INSTANCE:  type = "P_INSTANCE";  break;
547 608
 	case P_FTAG:      type = "P_FTAG";      break;
609
+	case P_CALL_ID:   type = "P_CALL_ID";   break;
610
+	case P_FROM_TAG:  type = "P_FROM_TAG";  break;
611
+	case P_TO_TAG:    type = "P_TO_TAG";    break;
612
+	case P_ISD:       type = "P_ISD";       break;
613
+	case P_SLA:       type = "P_SLA";       break;
548 614
 	default:          type = "UNKNOWN";     break;
549 615
 	}
550 616
 	
... ...
@@ -56,7 +56,12 @@ typedef enum ptype {
56 56
 	P_DSTIP,     /* URI: dstip parameter */
57 57
 	P_DSTPORT,   /* URi: dstport parameter */
58 58
 	P_INSTANCE,  /* Contact: sip.instance parameter */
59
-	P_FTAG       /* URI: ftag parameter */
59
+	P_FTAG,      /* URI: ftag parameter */
60
+	P_CALL_ID,   /* Dialog event package: call-id */
61
+	P_FROM_TAG,  /* Dialog event package: from-tag */
62
+	P_TO_TAG,    /* Dialog event package: to-tag */
63
+	P_ISD,       /* Dialog event package: include-session-description */
64
+	P_SLA        /* Dialog event package: sla */
60 65
 } ptype_t;
61 66
 
62 67
 
... ...
@@ -64,9 +69,10 @@ typedef enum ptype {
64 69
  * Class of parameters
65 70
  */
66 71
 typedef enum pclass {
67
-	CLASS_ANY = 0,  /* Any parameters, well-known hooks will be not used */
68
-	CLASS_CONTACT,  /* Contact parameters */
69
-	CLASS_URI       /* URI parameters */
72
+	CLASS_ANY = 0,      /* Any parameters, well-known hooks will be not used */
73
+	CLASS_CONTACT,      /* Contact parameters */
74
+	CLASS_URI,          /* URI parameters */
75
+	CLASS_EVENT_DIALOG  /* Event dialog parameters */
70 76
 } pclass_t;
71 77
 
72 78
 
... ...
@@ -109,12 +115,21 @@ struct uri_hooks {
109 115
 };
110 116
 
111 117
 
118
+struct event_dialog_hooks {
119
+	struct param* call_id;
120
+	struct param* from_tag;
121
+	struct param* to_tag;
122
+	struct param* include_session_description;
123
+	struct param* sla;
124
+};
125
+
112 126
 /*
113 127
  * Union of hooks structures for all classes
114 128
  */
115 129
 typedef union param_hooks {
116 130
 	struct contact_hooks contact; /* Contact hooks */
117 131
 	struct uri_hooks uri;         /* URI hooks */
132
+	struct event_dialog_hooks event_dialog;
118 133
 } param_hooks_t;
119 134
 
120 135
 /**