diff --git a/modules/dialog/README b/modules/dialog/README
index 6ec16b0a71..0431990c53 100644
--- a/modules/dialog/README
+++ b/modules/dialog/README
@@ -139,6 +139,8 @@ dialog Module
1.9.11. list_all_profiles
1.9.12. dlg_push_var
1.9.13. dlg_send_sequential
+ 1.9.14. set_dlg_profile
+ 1.9.15. unset_dlg_profile
1.10. Exported Pseudo-Variables
@@ -288,14 +290,14 @@ Chapter 1. Admin Guide
must call the create_dialog() function, with or without
parameter.
- The dialog is automatically terminated when a “BYE” is
- received. In case of no “BYE”, the dialog lifetime is
- controlled via the default timeout (see “default_timeout” -
- default_timeout) and custom timeout (see “$DLG_timeout” -
+ The dialog is automatically terminated when a "BYE" is
+ received. In case of no "BYE", the dialog lifetime is
+ controlled via the default timeout (see "default_timeout" -
+ default_timeout) and custom timeout (see "$DLG_timeout" -
$DLG_timeout).
Once terminated, the in-memory dialog may be destroyed right
- away or, depending on the “delete_delay” - delete_delay)
+ away or, depending on the "delete_delay" - delete_delay)
setting, it may be kept for a while in memory, in a read-only
state (no action, no changes, nothing). This delaying may be
used to help with the routing of late in-dialog request that
@@ -427,7 +429,7 @@ Chapter 1. Admin Guide
dialog processing. Set it to zero to disable or to non-zero to
enable it.
- Default value is “1 (enabled)”.
+ Default value is "1 (enabled)".
Example 1.1. Set enable_stats parameter
...
@@ -446,7 +448,7 @@ modparam("dialog", "enable_stats", 0)
modify the hash_size you must delete all table's rows before
restarting OpenSIPS.
- Default value is “4096”.
+ Default value is "4096".
Example 1.2. Set hash_size parameter
...
@@ -461,7 +463,7 @@ modparam("dialog", "hash_size", 1024)
provided as the base 2 logarithm(e.g. log_profile_hash_size =4
means the table has 2^4 entries).
- Default value is “4”.
+ Default value is "4".
Example 1.3. Set hash_size parameter
...
@@ -474,7 +476,7 @@ modparam("dialog", "log_profile_hash_size", 5) #set a table size of 32
cookie. It is used for fast dialog matching of the sequential
requests.
- Default value is “did”.
+ Default value is "did".
Example 1.4. Set rr_param parameter
...
@@ -486,7 +488,7 @@ modparam("dialog", "rr_param", "xyz")
The default dialog timeout (in seconds) if no custom one is
set.
- Default value is “43200 (12 hours)”.
+ Default value is "43200 (12 hours)".
Example 1.5. Set default_timeout parameter
...
@@ -499,7 +501,7 @@ modparam("dialog", "default_timeout", 21600)
to be added in the requests generated by the module (like
BYEs).
- Default value is “NULL”.
+ Default value is "NULL".
Example 1.6. Set dlf_extra_hdrs parameter
...
@@ -520,7 +522,7 @@ modparam("dialog", "dlg_extra_hdrs", "Hint: credit expired\r\n")
* 2 - DID_NONE - the match is done exclusively based on SIP
elements; no DID information is added in RR.
- Default value is “1 (DID_FALLBACK)”.
+ Default value is "1 (DID_FALLBACK)".
NOTE that if you have call looping on your OpenSIPS server
(passing more than once through the same OpenSIPS instance), it
@@ -543,9 +545,9 @@ modparam("dialog", "dlg_match_mode", 0)
requests.
This global value may be per-call changed via the DLG_del_delay
- “$DLG_del_delay” ($DLG_del_delay) script variable.
+ "$DLG_del_delay" ($DLG_del_delay) script variable.
- Default value is “0” (disabled).
+ Default value is "0" (disabled).
Example 1.8. Set delete_delay parameter
...
@@ -558,7 +560,7 @@ modparam("dialog", "delete_delay", 10)
database a database url must be specified.
Default value is
- “mysql://opensips:opensipsrw@localhost/opensips”.
+ "mysql://opensips:opensipsrw@localhost/opensips".
Example 1.9. Set db_url parameter
...
@@ -580,7 +582,7 @@ modparam("dialog", "db_url", "dbdriver://username:password@dbhost/dbname
* 3 - SHUTDOWN - the dialog information will be flushed into
DB only at shutdown - no runtime updates.
- Default value is “0”.
+ Default value is "0".
Example 1.10. Set db_mode parameter
...
@@ -594,7 +596,7 @@ modparam("dialog", "db_mode", 1)
too short interval will generate intensive database operations,
a too large one will not notice short dialogs.
- Default value is “60”.
+ Default value is "60".
Example 1.11. Set db_update_period parameter
...
@@ -607,7 +609,7 @@ modparam("dialog", "db_update_period", 120)
in-dialog OPTIONS pings for one or both of the involved
parties.
- Default value is “30”.
+ Default value is "30".
Example 1.12. Set options_ping_interval parameter
...
@@ -630,7 +632,7 @@ modparam("dialog", "options_ping_interval", 20)
ending a disconnected dialog due to pings getting retried
before getting a chance to properly time out.
- Default value is “300”.
+ Default value is "300".
Example 1.13. Set reinvite_ping_interval parameter
...
@@ -642,7 +644,7 @@ modparam("dialog", "reinvite_ping_interval", 600)
If you want to store the information about the dialogs in a
database a table name must be specified.
- Default value is “dialog”.
+ Default value is "dialog".
Example 1.14. Set table_name parameter
...
@@ -653,7 +655,7 @@ modparam("dialog", "table_name", "my_dialog")
The column's name in the database to store the dialogs' callid.
- Default value is “callid”.
+ Default value is "callid".
Example 1.15. Set call_id_column parameter
...
@@ -665,7 +667,7 @@ modparam("dialog", "call_id_column", "callid_c_name")
The column's name in the database to store the caller's sip
address.
- Default value is “from_uri”.
+ Default value is "from_uri".
Example 1.16. Set from_uri_column parameter
...
@@ -677,7 +679,7 @@ modparam("dialog", "from_uri_column", "from_uri_c_name")
The column's name in the database to store the From tag from
the Invite request.
- Default value is “from_tag”.
+ Default value is "from_tag".
Example 1.17. Set from_tag_column parameter
...
@@ -689,7 +691,7 @@ modparam("dialog", "from_tag_column", "from_tag_c_name")
The column's name in the database to store the calee's sip
address.
- Default value is “to_uri”.
+ Default value is "to_uri".
Example 1.18. Set to_uri_column parameter
...
@@ -701,7 +703,7 @@ modparam("dialog", "to_uri_column", "to_uri_c_name")
The column's name in the database to store the To tag from the
200 OK response to the Invite request, if present.
- Default value is “to_tag”.
+ Default value is "to_tag".
Example 1.19. Set to_tag_column parameter
...
@@ -713,7 +715,7 @@ modparam("dialog", "to_tag_column", "to_tag_c_name")
The column's name in the database to store the cseq from caller
side.
- Default value is “caller_cseq”.
+ Default value is "caller_cseq".
Example 1.20. Set from_cseq_column parameter
...
@@ -725,7 +727,7 @@ modparam("dialog", "from_cseq_column", "from_cseq_c_name")
The column's name in the database to store the cseq from callee
side.
- Default value is “callee_cseq”.
+ Default value is "callee_cseq".
Example 1.21. Set to_cseq_column parameter
...
@@ -737,7 +739,7 @@ modparam("dialog", "to_cseq_column", "to_cseq_c_name")
The column's name in the database to store the route records
from caller side (proxy to caller).
- Default value is “caller_route_set”.
+ Default value is "caller_route_set".
Example 1.22. Set from_route_column parameter
...
@@ -749,7 +751,7 @@ modparam("dialog", "from_route_column", "from_route_c_name")
The column's name in the database to store the route records
from callee side (proxy to callee).
- Default value is “callee_route_set”.
+ Default value is "callee_route_set".
Example 1.23. Set to_route_column parameter
...
@@ -761,7 +763,7 @@ modparam("dialog", "to_route_column", "to_route_c_name")
The column's name in the database to store the caller's contact
uri.
- Default value is “caller_contact”.
+ Default value is "caller_contact".
Example 1.24. Set from_contact_column parameter
...
@@ -773,7 +775,7 @@ modparam("dialog", "from_contact_column", "from_contact_c_name")
The column's name in the database to store the callee's contact
uri.
- Default value is “callee_contact”.
+ Default value is "callee_contact".
Example 1.25. Set to_contact_column parameter
...
@@ -785,7 +787,7 @@ modparam("dialog", "to_contact_column", "to_contact_c_name")
The column's name in the database to store the information
about the local interface receiving the traffic from caller.
- Default value is “caller_sock”.
+ Default value is "caller_sock".
Example 1.26. Set from_sock_column parameter
...
@@ -797,7 +799,7 @@ modparam("dialog", "from_sock_column", "from_sock_c_name")
The column's name in the database to store information about
the local interface receiving the traffic from callee.
- Default value is “callee_sock”.
+ Default value is "callee_sock".
Example 1.27. Set to_sock_column parameter
...
@@ -809,7 +811,7 @@ modparam("dialog", "to_sock_column", "to_sock_c_name")
The column's name in the database to store the dialogs' id
information.
- Default value is “dlg_id”.
+ Default value is "dlg_id".
Example 1.28. Set dlg_id_column parameter
...
@@ -821,7 +823,7 @@ modparam("dialog", "dlg_id_column", "dlg_id_c_name")
The column's name in the database to store the dialogs' state
information.
- Default value is “state”.
+ Default value is "state".
Example 1.29. Set state_column parameter
...
@@ -833,7 +835,7 @@ modparam("dialog", "state_column", "state_c_name")
The column's name in the database to store the dialogs' start
time information.
- Default value is “start_time”.
+ Default value is "start_time".
Example 1.30. Set start_time_column parameter
...
@@ -845,7 +847,7 @@ modparam("dialog", "start_time_column", "start_time_c_name")
The column's name in the database to store the dialogs'
timeout.
- Default value is “timeout”.
+ Default value is "timeout".
Example 1.31. Set timeout_column parameter
...
@@ -857,7 +859,7 @@ modparam("dialog", "timeout_column", "timeout_c_name")
The column's name in the database to store the dialogs'
profiles.
- Default value is “profiles”.
+ Default value is "profiles".
Example 1.32. Set profiles_column parameter
...
@@ -868,7 +870,7 @@ modparam("dialog", "profiles_column", "profiles_c_name")
The column's name in the database to store the dialogs' vars.
- Default value is “vars”.
+ Default value is "vars".
Example 1.33. Set vars_column parameter
...
@@ -880,7 +882,7 @@ modparam("dialog", "vars_column", "vars_c_name")
The column's name in the database to store the dialogs' script
flags.
- Default value is “script_flags”.
+ Default value is "script_flags".
Example 1.34. Set sflags_column parameter
...
@@ -892,7 +894,7 @@ modparam("dialog", "sflags_column", "sflags_c_name")
The column's name in the database to store the dialogs' module
flags.
- Default value is “module_flags”.
+ Default value is "module_flags".
Example 1.35. Set mflags_column parameter
...
@@ -903,7 +905,7 @@ modparam("dialog", "mflags_column", "mflags_c_name")
The column's name in the database to store the dialogs' flags.
- Default value is “flags”.
+ Default value is "flags".
Example 1.36. Set flags_column parameter
...
@@ -917,7 +919,7 @@ modparam("dialog", "flags_column", "flags_c_name")
instances using the clusterer module or a CacheDB backend,
respectively.
- Default value is “empty”.
+ Default value is "empty".
Example 1.37. Set profiles_with_value parameter
...
@@ -932,7 +934,7 @@ annels/s; codecUsed/b;")
instances using the clusterer module or a CacheDB backend,
respectively.
- Default value is “empty”.
+ Default value is "empty".
Example 1.38. Set profiles_no_value parameter
...
@@ -946,7 +948,7 @@ repl/b;")
along with other dialog state information (see db_mode 1 and
2).
- Default value is “empty”.
+ Default value is "empty".
Example 1.39. Set db_flush_vals_profiles parameter
...
@@ -958,7 +960,7 @@ modparam("dialog", "db_flush_vals_profiles", 1)
The number of dialogs that should be attempted to be deleted at
the same time ( a single query ) from the DB back-end.
- Default value is “1”.
+ Default value is "1".
Example 1.40. Set timer_bulk_del_no parameter
...
@@ -972,7 +974,7 @@ modparam("dialog", "timer_bulk_del_no", 10)
'race_condition_timeout' seconds. Currently, the only supported
race conditions are (200OK vs CANCEL) and (early BYE vs 200OK)
- Default value is “5” seconds.
+ Default value is "5" seconds.
Example 1.41. Set race_condition_timeout parameter
...
@@ -984,7 +986,7 @@ modparam("dialog", "race_condition_timeout", 1)
Enables distributed dialog profiles and specifies the backend
that should be used by the CacheDB interface.
- Default value is “empty”.
+ Default value is "empty".
Example 1.42. Set cachedb_url parameter
...
@@ -997,7 +999,7 @@ modparam("dialog", "cachedb_url", "redis://127.0.0.1:6379")
value when they are inserted into CacheDB backed. This is only
used when distributed profiles are enabled.
- Default value is “dlg_val_”.
+ Default value is "dlg_val_".
Example 1.43. Set profile_value_prefix parameter
...
@@ -1010,7 +1012,7 @@ modparam("dialog", "profile_value_prefix", "dlgv_")
value when they are inserted into CacheDB backed. This is only
used when distributed profiles are enabled.
- Default value is “dlg_noval_”.
+ Default value is "dlg_noval_".
Example 1.44. Set profile_no_value_prefix parameter
...
@@ -1023,7 +1025,7 @@ modparam("dialog", "profile_no_value_prefix", "dlgnv_")
the profiles with value size in CacheDB backed. This is only
used when distributed profiles are enabled.
- Default value is “dlg_size_”.
+ Default value is "dlg_size_".
Example 1.45. Set profile_size_prefix parameter
...
@@ -1036,7 +1038,7 @@ modparam("dialog", "profile_size_prefix", "dlgs_")
CacheDB until it expires. This is only used when distributed
profiles are enabled.
- Default value is “86400”.
+ Default value is "86400".
Example 1.46. Set profile_timeout parameter
...
@@ -1058,7 +1060,7 @@ modparam("dialog", "profile_timeout", "43200")
functional. Consult the clusterer - Capabilities chapter for
more details.
- Default value is “0” (no replication).
+ Default value is "0" (no replication).
Example 1.47. Set dialog_replication_cluster parameter
...
@@ -1071,7 +1073,7 @@ modparam("dialog", "dialog_replication_cluster", 1)
clusterer module. This enables sending and receiving the
profile information (value, dialog count) in the cluster.
- Default value is “0” (no replication).
+ Default value is "0" (no replication).
Example 1.48. Set profile_replication_cluster parameter
...
@@ -2047,7 +2049,7 @@ each in-dialog request
1.9.2. dlg_list_ctx
- The same as the “dlg_list” but including in the dialog
+ The same as the "dlg_list" but including in the dialog
description the associated context from modules sitting on top
of the dialog module. This function also prints the dialog's
values. In case of binary values, the non-printable chars are
@@ -2055,7 +2057,7 @@ each in-dialog request
Name: dlg_list_ctx
- Parameters: see “dlg_list”
+ Parameters: see "dlg_list"
MI FIFO Command Format:
opensips-cli -x mi dlg_list_ctx
@@ -2325,6 +2327,44 @@ GIwZjAzNGM1ZDY
headers='Refer-To: sip:user@domain:50060
'
+1.9.14. set_dlg_profile
+
+ Set the dialog identified by dialog ID / Call-ID into the given
+ profile ( with optional value and clearing of the old profile
+ values )
+
+ Name: set_dlg_profile
+
+ Parameters: It takes 2-4 parameters
+ * dlg_id - dialog ID or Call-ID for the respective dialog
+ * profile - profile name to be set
+ * value - optional, the profile value to be set
+ * clear_values - optional, clear previous values in the
+ profile before setting the new one
+
+ MI FIFO Command Format:
+ opensips-cli -x mi set_dlg_profile DID my_profile my_val
+ue 1
+
+1.9.15. unset_dlg_profile
+
+ Unsets the dialog identified by dialog ID / Call-ID from the
+ given profile ( with optional value and clearing of the old
+ profile values )
+
+ Name: set_dlg_profile
+
+ Parameters: It takes 2-3 parameters
+ * dlg_id - dialog ID or Call-ID for the respective dialog
+ * profile - profile name to be unset
+ * value - optional, the profile value to be unset. for
+ profiles with value, by omitting this parameter you can now
+ clear all values of the given profile.
+
+ MI FIFO Command Format:
+ opensips-cli -x mi unset_dlg_profile DID my_profile my_v
+alue
+
1.10. Exported Pseudo-Variables
1.10.1. $DLG_count
@@ -2425,7 +2465,7 @@ GIwZjAzNGM1ZDY
Used to set the dialog deletion delay (in seconds) for the
current dialog (in a per-call manner). When read, the variable
returns the number of seconds that were set for the call or the
- default value ( see the “delete_delay” - delete_delay) module
+ default value ( see the "delete_delay" - delete_delay) module
param) for the delete delaying.
The variable must be used when the context of a dialog is
@@ -2526,26 +2566,26 @@ Chapter 2. Developer Guide
command is invoked - it's a per dialog type.
+ DLGCB_DESTROY
* dialog_cb cb - callback function to be called. Prototype
- is: “void (dialog_cb) (struct dlg_cell* dlg, int type,
- struct dlg_cb_params * params); ”
+ is: "void (dialog_cb) (struct dlg_cell* dlg, int type,
+ struct dlg_cb_params * params); "
* void *param - parameter to be passed to the callback
function.
* param_free callback_param_free - callback function to be
- called to free the param. Prototype is: “void
- (param_free_cb) (void *param);”
+ called to free the param. Prototype is: "void
+ (param_free_cb) (void *param);"
Chapter 3. Frequently Asked Questions
3.1.
- What happened with “topology_hiding()” function?
+ What happened with "topology_hiding()" function?
The respective functionality was moved into the topology_hiding
module. Function prototype has remained the same.
3.2.
- What happened with “use_tight_match” parameter?
+ What happened with "use_tight_match" parameter?
The parameter was removed with version 1.3 as the option of
tight matching became mandatory and not configurable. Now, the
@@ -2553,7 +2593,7 @@ Chapter 3. Frequently Asked Questions
3.3.
- What happened with “bye_on_timeout_flag” parameter?
+ What happened with "bye_on_timeout_flag" parameter?
The parameter was removed in a dialog module parameter
restructuring. To keep the bye on timeout behavior, you need to
@@ -2561,7 +2601,7 @@ Chapter 3. Frequently Asked Questions
3.4.
- What happened with “dlg_flag” parameter?
+ What happened with "dlg_flag" parameter?
The parameter is considered obsolete. The only way to create a
dialog is to call the create_dialog() function
@@ -2624,7 +2664,7 @@ Chapter 4. Contributors
(@l2dy), Michel Bensoussan, Richard Revels, Elena-Ramona
Modroiu, Tavis Paquette, Ryan Bullock, Andrei Datcu
(@andrei-datcu), Jeffrey Magder, Stefan-Cristian Mititelu, Ron
- Winacott, Andy Pyles, Julián Moreno Patiño, Konstantin
+ Winacott, Andy Pyles, Juli�n Moreno Pati�o, Konstantin
Bokarius, sergei lavrov, Alex Massover, Damien Sandras
(@dsandras), Alex Hermann, Dusan Klinec (@ph4r05), Norman
Brandinger (@NormB), UnixDev, Eliot Gable, Ryan Bullock
@@ -2665,7 +2705,7 @@ Chapter 4. Contributors
Doekes (@wdoekes), Liviu Chircu (@liviuchircu), sergei lavrov,
Zero King (@l2dy), Dan Pascu (@danpascu), Ionel Cerghit
(@ionel-cerghit), Jarrod Baumann (@jarrodb), Ionut Ionita
- (@ionutrazvanionita), Julián Moreno Patiño, Dusan Klinec
+ (@ionutrazvanionita), Juli�n Moreno Pati�o, Dusan Klinec
(@ph4r05), Eseanu Marius Cristian (@eseanucristian), Andrei
Datcu (@andrei-datcu), Norman Brandinger (@NormB), Damien
Sandras (@dsandras), Ryan Bullock (@rrb3942), Anca Vamanu, Alex
@@ -2687,8 +2727,8 @@ Chapter 5. Documentation
(@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu),
Stefan-Cristian Mititelu, Ryan Bullock, Vlad Patrascu
(@rvlad-patrascu), Vlad Paiu (@vladpaiu), Zero King (@l2dy),
- Dan Pascu (@danpascu), Peter Lemenkov (@lemenkov), Julián
- Moreno Patiño, Ionut Ionita (@ionutrazvanionita), Ionel Cerghit
+ Dan Pascu (@danpascu), Peter Lemenkov (@lemenkov), Juli�n
+ Moreno Pati�o, Ionut Ionita (@ionutrazvanionita), Ionel Cerghit
(@ionel-cerghit), Walter Doekes (@wdoekes), Eseanu Marius
Cristian (@eseanucristian), Norman Brandinger (@NormB), Anca
Vamanu, Andrei Dragus, Hugues Mitonneau, Klaus Darilion,
@@ -2699,4 +2739,4 @@ Chapter 5. Documentation
Documentation Copyrights:
- Copyright © 2006-2009 Voice Sistem SRL
+ Copyright � 2006-2009 Voice Sistem SRL
diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c
index e0dfd7e42a..fdb6f5c68e 100644
--- a/modules/dialog/dialog.c
+++ b/modules/dialog/dialog.c
@@ -441,6 +441,17 @@ static const mi_export_t mi_cmds[] = {
{mi_send_sequential_dlg, {"callid", "method", "body", "mode", "headers", 0}},
{EMPTY_MI_RECIPE}}
},
+ { "dlg_set_profile", 0, 0, 0, {
+ {mi_set_dlg_profile, {"dlg_id", "profile", 0}},
+ {mi_set_dlg_profile, {"dlg_id", "profile","value", 0}},
+ {mi_set_dlg_profile, {"dlg_id", "profile","value", "clear_values", 0}},
+ {EMPTY_MI_RECIPE}}
+ },
+ { "dlg_unset_profile", 0, 0, 0, {
+ {mi_unset_dlg_profile, {"dlg_id", "profile", 0}},
+ {mi_unset_dlg_profile, {"dlg_id", "profile","value", 0}},
+ {EMPTY_MI_RECIPE}}
+ },
{EMPTY_MI_EXPORT}
};
diff --git a/modules/dialog/dlg_hash.c b/modules/dialog/dlg_hash.c
index 06a8f0d798..79609cbaad 100644
--- a/modules/dialog/dlg_hash.c
+++ b/modules/dialog/dlg_hash.c
@@ -1883,3 +1883,186 @@ mi_response_t *mi_push_dlg_var(const mi_params_t *params,
dlg_error:
return init_mi_error(403, MI_SSTR(MI_DLG_OPERATION_ERR));
}
+
+mi_response_t *mi_set_dlg_profile(const mi_params_t *params,
+ struct mi_handler *async_hdl)
+{
+ str profile_name={0,0},profile_value={0,0},dialog_id={0,0};
+ struct dlg_cell * dlg = NULL;
+ int shtag_state = 1, db_update = 0, clear_values = 0;
+ struct dlg_profile_table *profile;
+
+ if ( d_table == NULL)
+ goto not_found;
+
+ /* params : dialog_id profile_name [profile_value] */
+ if (get_mi_string_param(params, "DID",
+ &dialog_id.s, &dialog_id.len) < 0)
+ return init_mi_param_error();
+
+ if (get_mi_string_param(params, "profile",
+ &profile_name.s, &profile_name.len) < 0)
+ return init_mi_param_error();
+
+ get_mi_string_param(params, "value",
+ &profile_value.s, &profile_value.len);
+
+ get_mi_int_param(params, "clear_values",
+ &clear_values);
+
+ profile = search_dlg_profile(&profile_name);
+ if (!profile) {
+ LM_ERR("profile <%.*s> not defined\n", profile_name.len,profile_name.s);
+ goto bad_param;
+ }
+
+ /* Get the dialog based of the dialog_id. This may be a
+ * numerical DID or a string SIP Call-ID */
+ dlg = get_dlg_by_dialog_id(&dialog_id);
+ if (dlg == NULL) {
+ goto not_found;
+ }
+
+ if (dialog_repl_cluster) {
+ shtag_state = get_shtag_state(dlg);
+ if (shtag_state < 0) {
+ goto dlg_error;
+ } else if (shtag_state == 0) {
+ /* editing dlg profiles on backup servers - no no */
+ unref_dlg(dlg, 1);
+ return init_mi_error(403, MI_SSTR("Editing Backup"));
+ }
+ }
+
+ if (profile->has_value && profile_value.s) {
+
+ if (clear_values) {
+ if (unset_dlg_profile_all_values(dlg, profile) < 0) {
+ LM_DBG("dialog not found in profile %.*s\n",
+ profile_name.len, profile_name.s);
+ }
+ }
+
+ if ( set_dlg_profile( dlg, &profile_value, profile, 0) < 0 ) {
+ LM_ERR("failed to set profile\n");
+ goto dlg_error;
+ }
+ } else {
+ if ( set_dlg_profile( dlg, NULL, profile, 0) < 0 ) {
+ LM_ERR("failed to set profile\n");
+ goto dlg_error;
+ }
+ }
+
+ if (dlg->state >= DLG_STATE_CONFIRMED && dlg_db_mode == DB_MODE_REALTIME) {
+ db_update = 1;
+ } else {
+ dlg->flags |= DLG_FLAG_CHANGED;
+ db_update = 0;
+ }
+
+ if (db_update)
+ update_dialog_timeout_info(dlg);
+ if (dialog_repl_cluster && shtag_state != SHTAG_STATE_BACKUP)
+ replicate_dialog_updated(dlg);
+
+ unref_dlg(dlg, 1);
+ return init_mi_result_ok();
+
+not_found:
+ return init_mi_error(404, MI_SSTR("Dialog Not Found"));
+bad_param:
+ return init_mi_error( 400, MI_SSTR("Bad param"));
+dlg_error:
+ unref_dlg(dlg, 1);
+ return init_mi_error(403, MI_SSTR("Dialog Error"));
+}
+
+mi_response_t *mi_unset_dlg_profile(const mi_params_t *params,
+ struct mi_handler *async_hdl)
+{
+ str profile_name={0,0},profile_value={0,0},dialog_id={0,0};
+ struct dlg_cell * dlg = NULL;
+ int shtag_state = 1, db_update = 0;
+ struct dlg_profile_table *profile;
+
+ if ( d_table == NULL)
+ goto not_found;
+
+ /* params : dialog_id profile_name [profile_value] */
+ if (get_mi_string_param(params, "DID",
+ &dialog_id.s, &dialog_id.len) < 0)
+ return init_mi_param_error();
+
+ if (get_mi_string_param(params, "profile",
+ &profile_name.s, &profile_name.len) < 0)
+ return init_mi_param_error();
+
+ get_mi_string_param(params, "value",
+ &profile_value.s, &profile_value.len);
+
+ profile = search_dlg_profile(&profile_name);
+ if (!profile) {
+ LM_ERR("profile <%.*s> not defined\n", profile_name.len,profile_name.s);
+ goto bad_param;
+ }
+
+ /* Get the dialog based of the dialog_id. This may be a
+ * numerical DID or a string SIP Call-ID */
+ dlg = get_dlg_by_dialog_id(&dialog_id);
+ if (dlg == NULL) {
+ goto not_found;
+ }
+
+ if (dialog_repl_cluster) {
+ shtag_state = get_shtag_state(dlg);
+ if (shtag_state < 0) {
+ goto dlg_error;
+ } else if (shtag_state == 0) {
+ /* editing dlg profiles on backup servers - no no */
+ unref_dlg(dlg, 1);
+ return init_mi_error(403, MI_SSTR("Editing Backup"));
+ }
+ }
+
+ if (profile->has_value) {
+
+ if (profile_value.s == NULL) {
+ if (unset_dlg_profile_all_values(dlg, profile) < 0) {
+ LM_DBG("dialog not found in profile %.*s\n",
+ profile_name.len, profile_name.s);
+ }
+ } else if ( unset_dlg_profile( dlg, &profile_value, profile) < 0 ) {
+ LM_ERR("failed to unset profile\n");
+ goto dlg_error;
+ }
+ } else {
+ if ( unset_dlg_profile( dlg, NULL, profile) < 0 ) {
+ LM_ERR("failed to set profile\n");
+ goto dlg_error;
+ }
+ }
+
+ if (dlg->state >= DLG_STATE_CONFIRMED && dlg_db_mode == DB_MODE_REALTIME) {
+ db_update = 1;
+ } else {
+ dlg->flags |= DLG_FLAG_CHANGED;
+ db_update = 0;
+ }
+
+ if (db_update)
+ update_dialog_timeout_info(dlg);
+ if (dialog_repl_cluster && shtag_state != SHTAG_STATE_BACKUP)
+ replicate_dialog_updated(dlg);
+
+ unref_dlg(dlg, 1);
+ return init_mi_result_ok();
+
+not_found:
+ return init_mi_error(404, MI_SSTR("Dialog Not Found"));
+bad_param:
+ return init_mi_error( 400, MI_SSTR("Bad param"));
+dlg_error:
+ unref_dlg(dlg, 1);
+ return init_mi_error(403, MI_SSTR("Dialog Error"));
+}
diff --git a/modules/dialog/dlg_hash.h b/modules/dialog/dlg_hash.h
index c22021d264..9525ff45ed 100644
--- a/modules/dialog/dlg_hash.h
+++ b/modules/dialog/dlg_hash.h
@@ -494,6 +494,10 @@ mi_response_t *mi_print_dlgs_cnt_ctx(const mi_params_t *params,
mi_response_t *mi_push_dlg_var(const mi_params_t *params,
struct mi_handler *async_hdl);
+mi_response_t *mi_set_dlg_profile(const mi_params_t *params,
+ struct mi_handler *async_hdl);
+mi_response_t *mi_unset_dlg_profile(const mi_params_t *params,
+ struct mi_handler *async_hdl);
static inline void unref_dlg_destroy_safe(struct dlg_cell *dlg, unsigned int cnt)
{
diff --git a/modules/dialog/doc/dialog_admin.xml b/modules/dialog/doc/dialog_admin.xml
index caa9f6127c..00f1a44149 100644
--- a/modules/dialog/doc/dialog_admin.xml
+++ b/modules/dialog/doc/dialog_admin.xml
@@ -3225,6 +3225,67 @@ route {
+
+
+ set_dlg_profile
+
+ Set the dialog identified by dialog ID / Call-ID into the given profile ( with optional value and clearing of the old profile values )
+
+
+ Name: set_dlg_profile
+
+ Parameters: It takes 2-4 parameters
+
+
+
+ dlg_id - dialog ID or Call-ID for the respective dialog
+
+
+ profile - profile name to be set
+
+
+ value - optional, the profile value to be set
+
+
+ clear_values - optional, clear previous values in the profile before setting the new one
+
+
+
+ MI FIFO Command Format:
+
+
+ opensips-cli -x mi set_dlg_profile DID my_profile my_value 1
+
+
+
+
+ unset_dlg_profile
+
+ Unsets the dialog identified by dialog ID / Call-ID from the given profile ( with optional value and clearing of the old profile values )
+
+
+ Name: set_dlg_profile
+
+ Parameters: It takes 2-3 parameters
+
+
+
+ dlg_id - dialog ID or Call-ID for the respective dialog
+
+
+ profile - profile name to be unset
+
+
+ value - optional, the profile value to be unset. for profiles with value, by omitting this parameter you can now clear all values of the given profile.
+
+
+
+ MI FIFO Command Format:
+
+
+ opensips-cli -x mi unset_dlg_profile DID my_profile my_value
+
+