Browse code

Merge pull request #2336 from kamailio/ds_add_attrs

dispatcher: add attrs param to rpc 'add' call

Federico Cabiddu authored on 28/05/2020 05:14:56 • GitHub committed on 28/05/2020 05:14:56
Showing 4 changed files
... ...
@@ -2419,15 +2419,16 @@ void ds_add_dest_cb(ds_set_t *node, int i, void *arg)
2419 2419
 }
2420 2420
 
2421 2421
 /* add dispatcher entry to in-memory dispatcher list */
2422
-int ds_add_dst(int group, str *address, int flags)
2422
+int ds_add_dst(int group, str *address, int flags, str *attrs)
2423 2423
 {
2424 2424
 	int setn, priority;
2425
-	str attrs;
2426 2425
 
2427 2426
 	setn = _ds_list_nr;
2428 2427
 	priority = 0;
2429
-	attrs.s = 0;
2430
-	attrs.len = 0;
2428
+
2429
+	if (attrs->len == 0) {
2430
+		attrs->s = 0;
2431
+	}
2431 2432
 
2432 2433
 	*next_idx = (*crt_idx + 1) % 2;
2433 2434
 	ds_avl_destroy(&ds_lists[*next_idx]);
... ...
@@ -2436,7 +2437,7 @@ int ds_add_dst(int group, str *address, int flags)
2436 2437
 	ds_iter_set(_ds_list, &ds_add_dest_cb, NULL);
2437 2438
 
2438 2439
 	// add new destination
2439
-	if(add_dest2list(group, *address, flags, priority, &attrs,
2440
+	if(add_dest2list(group, *address, flags, priority, attrs,
2440 2441
 			*next_idx, &setn) != 0) {
2441 2442
 		LM_WARN("unable to add destination %.*s to set %d", address->len, address->s, group);
2442 2443
 		if(ds_load_mode==1) {
... ...
@@ -140,7 +140,7 @@ int ds_select_dst_limit(sip_msg_t *msg, int set, int alg, uint32_t limit,
140 140
 		int mode);
141 141
 int ds_select_dst(struct sip_msg *msg, int set, int alg, int mode);
142 142
 int ds_update_dst(struct sip_msg *msg, int upos, int mode);
143
-int ds_add_dst(int group, str *address, int flags);
143
+int ds_add_dst(int group, str *address, int flags, str *attrs);
144 144
 int ds_remove_dst(int group, str *address);
145 145
 int ds_update_state(sip_msg_t *msg, int group, str *address, int state,
146 146
 		ds_rctx_t *rctx);
... ...
@@ -1800,15 +1800,16 @@ static void dispatcher_rpc_add(rpc_t *rpc, void *ctx)
1800 1800
 {
1801 1801
 	int group, flags;
1802 1802
 	str dest;
1803
+  str attrs;
1803 1804
 
1804 1805
 	flags = 0;
1805 1806
 
1806
-	if(rpc->scan(ctx, "dS*d", &group, &dest, &flags) < 2) {
1807
+	if(rpc->scan(ctx, "dS*d", &group, &dest, &flags, &attrs) < 3) {
1807 1808
 		rpc->fault(ctx, 500, "Invalid Parameters");
1808 1809
 		return;
1809 1810
 	}
1810 1811
 
1811
-	if(ds_add_dst(group, &dest, flags) != 0) {
1812
+	if(ds_add_dst(group, &dest, flags, &attrs) != 0) {
1812 1813
 		rpc->fault(ctx, 500, "Adding dispatcher dst failed");
1813 1814
 		return;
1814 1815
 	}
... ...
@@ -1938,15 +1938,19 @@ DEST: {
1938 1938
 			<listitem><para>_flags_ (optional): as described in the list file format,
1939 1939
 			default 0</para></listitem>
1940 1940
 
1941
+			<listitem><para>_attrs_ (optional): as described in the list file format,
1942
+			default ""</para></listitem>
1943
+
1941 1944
 		</itemizedlist>
1942 1945
 		<para>
1943 1946
 		Example:
1944 1947
 		</para>
1945 1948
 <programlisting  format="linespecific">
1946 1949
 ...
1947
-# prototype: &sercmd; dispatcher.add _group_ _address_ _flags_
1950
+# prototype: &sercmd; dispatcher.add _group_ _address_ _flags_ _attrs_
1948 1951
 &sercmd; dispatcher.add 2 sip:127.0.0.1:5080
1949 1952
 &sercmd; dispatcher.add 3 sip:127.0.0.1:5075 8
1953
+&sercmd; dispatcher.add 3 sip:127.0.0.1:5075 0 duid=abc;socket=udp:127.0.0.1:5060
1950 1954
 ...
1951 1955
 </programlisting>
1952 1956
     </section>