Module: sip-router Branch: master Commit: 2eb780d71326e03dff0cc676c16085c18bce914b URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2eb780d7...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Tue Mar 17 17:17:44 2009 +0100
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.
---
parser/parse_param.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ parser/parse_param.h | 23 ++++++++++++++--- 2 files changed, 85 insertions(+), 4 deletions(-)
diff --git a/parser/parse_param.c b/parser/parse_param.c index f52811d..c5ed012 100644 --- a/parser/parse_param.c +++ b/parser/parse_param.c @@ -43,6 +43,66 @@ #include "parse_param.h"
+static inline void parse_event_dialog_class(param_hooks_t* h, param_t* p) +{ + + if (!p->name.s) { + LOG(L_ERR, "ERROR: parse_event_dialog_class: empty value\n"); + return; + } + if (!h) { + LOG(L_CRIT, "BUG: parse_event_dialog_class: NULL param hook pointer\n"); + return; + } + switch(p->name.s[0]) { + case 'c': + case 'C': + if ((p->name.len == 7) && + (!strncasecmp(p->name.s + 1, "all-id", 6))) { + p->type = P_CALL_ID; + h->event_dialog.call_id = p; + } + break; + + case 'f': + case 'F': + if ((p->name.len == 8) && + (!strncasecmp(p->name.s + 1, "rom-tag", 7))) { + p->type = P_FROM_TAG; + h->event_dialog.from_tag = p; + } + break; + + case 't': + case 'T': + if ((p->name.len == 6) && + (!strncasecmp(p->name.s + 1, "o-tag", 5))) { + p->type = P_TO_TAG; + h->event_dialog.to_tag = p; + } + break; + + case 'i': + case 'I': + if ((p->name.len == 27) && + (!strncasecmp(p->name.s + 1, "nclude-session-description", 26))) { + p->type = P_ISD; + h->event_dialog.include_session_description = p; + } + break; + + case 's': + case 'S': + if ((p->name.len == 3) && + (!strncasecmp(p->name.s + 1, "la", 2))) { + p->type = P_SLA; + h->event_dialog.sla = p; + } + break; + } +} + + /* * Try to find out parameter name, recognized parameters * 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 switch(_c) { case CLASS_CONTACT: parse_contact_class(_h, _p); break; case CLASS_URI: parse_uri_class(_h, _p); break; + case CLASS_EVENT_DIALOG: parse_event_dialog_class(_h, _p); break; default: break; } } @@ -545,6 +606,11 @@ static inline void print_param(FILE* _o, param_t* _p) case P_DSTPORT: type = "P_DSTPORT"; break; case P_INSTANCE: type = "P_INSTANCE"; break; case P_FTAG: type = "P_FTAG"; break; + case P_CALL_ID: type = "P_CALL_ID"; break; + case P_FROM_TAG: type = "P_FROM_TAG"; break; + case P_TO_TAG: type = "P_TO_TAG"; break; + case P_ISD: type = "P_ISD"; break; + case P_SLA: type = "P_SLA"; break; default: type = "UNKNOWN"; break; } diff --git a/parser/parse_param.h b/parser/parse_param.h index 297518c..40a529f 100644 --- a/parser/parse_param.h +++ b/parser/parse_param.h @@ -56,7 +56,12 @@ typedef enum ptype { P_DSTIP, /* URI: dstip parameter */ P_DSTPORT, /* URi: dstport parameter */ P_INSTANCE, /* Contact: sip.instance parameter */ - P_FTAG /* URI: ftag parameter */ + P_FTAG, /* URI: ftag parameter */ + P_CALL_ID, /* Dialog event package: call-id */ + P_FROM_TAG, /* Dialog event package: from-tag */ + P_TO_TAG, /* Dialog event package: to-tag */ + P_ISD, /* Dialog event package: include-session-description */ + P_SLA /* Dialog event package: sla */ } ptype_t;
@@ -64,9 +69,10 @@ typedef enum ptype { * Class of parameters */ typedef enum pclass { - CLASS_ANY = 0, /* Any parameters, well-known hooks will be not used */ - CLASS_CONTACT, /* Contact parameters */ - CLASS_URI /* URI parameters */ + CLASS_ANY = 0, /* Any parameters, well-known hooks will be not used */ + CLASS_CONTACT, /* Contact parameters */ + CLASS_URI, /* URI parameters */ + CLASS_EVENT_DIALOG /* Event dialog parameters */ } pclass_t;
@@ -109,12 +115,21 @@ struct uri_hooks { };
+struct event_dialog_hooks { + struct param* call_id; + struct param* from_tag; + struct param* to_tag; + struct param* include_session_description; + struct param* sla; +}; + /* * Union of hooks structures for all classes */ typedef union param_hooks { struct contact_hooks contact; /* Contact hooks */ struct uri_hooks uri; /* URI hooks */ + struct event_dialog_hooks event_dialog; } param_hooks_t;
/**