Module: sip-router Branch: master Commit: 9c8020d2ab0b522bd63dc521270e80d0f7bd6212 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9c8020d2...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Aug 22 15:37:53 2014 +0200
dialog: new config function - dlg_remote_profile
- dlg_remote_profile(cmd, profile, value, uid, expires) - manage non-local profiles from configuration file - cmd can be add (insert a remote profile) and rm (remove a remote profile)
---
modules/dialog/dialog.c | 55 ++++++++++++++++++++++++++++++++++++++++++ modules/dialog/dlg_profile.c | 2 +- modules/dialog/dlg_profile.h | 6 ++++ 3 files changed, 62 insertions(+), 1 deletions(-)
diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c index 86bafbf..2f5acc7 100644 --- a/modules/dialog/dialog.c +++ b/modules/dialog/dialog.c @@ -181,6 +181,10 @@ static int fixup_dlg_bridge(void** param, int param_no); static int w_dlg_get(struct sip_msg*, char*, char*, char*); static int w_is_known_dlg(struct sip_msg *);
+static int w_dlg_remote_profile(sip_msg_t *msg, char *cmd, char *pname, + char *pval, char *puid, char *expires); +static int fixup_dlg_remote_profile(void** param, int param_no); + static cmd_export_t cmds[]={ {"dlg_manage", (cmd_function)w_dlg_manage, 0,0, 0, REQUEST_ROUTE }, @@ -228,6 +232,8 @@ static cmd_export_t cmds[]={ 0, ANY_ROUTE }, {"dlg_set_property", (cmd_function)w_dlg_set_property,1,fixup_spve_null, 0, ANY_ROUTE }, + {"dlg_remote_profile", (cmd_function)w_dlg_remote_profile, 5, fixup_dlg_remote_profile, + 0, ANY_ROUTE }, {"load_dlg", (cmd_function)load_dlg, 0, 0, 0, 0}, {0,0,0,0,0,0} }; @@ -1357,6 +1363,55 @@ static int w_dlg_get(struct sip_msg *msg, char *ci, char *ft, char *tt) return 1; }
+/** + * + */ +static int w_dlg_remote_profile(sip_msg_t *msg, char *cmd, char *pname, + char *pval, char *puid, char *expires) +{ + str scmd; + str sname; + str sval; + str suid; + int ival; + int ret; + + if(fixup_get_svalue(msg, (gparam_t*)cmd, &scmd)!=0) { + LM_ERR("unable to get command\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)pname, &sname)!=0) { + LM_ERR("unable to get profile name\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)pval, &sval)!=0) { + LM_ERR("unable to get profile value\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)puid, &suid)!=0) { + LM_ERR("unable to get profile uid\n"); + return -1; + } + if(fixup_get_ivalue(msg, (gparam_t*)expires, &ival)!=0) { + LM_ERR("no hash entry value value\n"); + return -1; + } + + ret = dlg_cmd_remote_profile(&scmd, &sname, &sval, &suid, (time_t)ival, 0); + if(ret==0) + return 1; + return ret; +} + +static int fixup_dlg_remote_profile(void** param, int param_no) +{ + if(param_no>=1 && param_no<=4) + return fixup_spve_null(param, 1); + if(param_no==5) + return fixup_igp_null(param, 1); + return 0; +} + struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param) { str from = {0,0}; diff --git a/modules/dialog/dlg_profile.c b/modules/dialog/dlg_profile.c index 3600728..c363fd6 100644 --- a/modules/dialog/dlg_profile.c +++ b/modules/dialog/dlg_profile.c @@ -1297,7 +1297,7 @@ int dlg_json_to_profiles(dlg_cell_t *dlg, srjson_doc_t *jdoc) return 0; }
-/** +/*! * */ int dlg_cmd_remote_profile(str *cmd, str *pname, str *value, str *puid, diff --git a/modules/dialog/dlg_profile.h b/modules/dialog/dlg_profile.h index 17ae242..29625e4 100644 --- a/modules/dialog/dlg_profile.h +++ b/modules/dialog/dlg_profile.h @@ -235,4 +235,10 @@ int dlg_json_to_profiles(dlg_cell_t *dlg, srjson_doc_t *jdoc); */ void remove_expired_remote_profiles(time_t te);
+/*! + * + */ +int dlg_cmd_remote_profile(str *cmd, str *pname, str *value, str *puid, + time_t expires, int flags); + #endif