[sr-dev] git:master: dispatcher: expand attrs while running rpc command dispatcher. list

Ovidiu Sas osas at voipembedded.com
Wed May 14 23:01:18 CEST 2014


Module: sip-router
Branch: master
Commit: 661bcef49ba3be944ba215b8a379256e3fe94a60
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=661bcef49ba3be944ba215b8a379256e3fe94a60

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Wed May 14 17:00:30 2014 -0400

dispatcher: expand attrs while running rpc command dispatcher.list

---

 modules/dispatcher/dispatcher.c |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/modules/dispatcher/dispatcher.c b/modules/dispatcher/dispatcher.c
index c7dca2e..b07cc24 100644
--- a/modules/dispatcher/dispatcher.c
+++ b/modules/dispatcher/dispatcher.c
@@ -974,6 +974,7 @@ static void dispatcher_rpc_list(rpc_t* rpc, void* ctx)
 	void* rh;
 	void* sh;
 	void* vh;
+	void* wh;
 	int j;
 	char c[3];
 	str data = {"", 0};
@@ -1005,7 +1006,6 @@ static void dispatcher_rpc_list(rpc_t* rpc, void* ctx)
 		return;
 	}
 
-
 	for(list = ds_list; list!= NULL; list= list->next)
 	{
 		if (rpc->struct_add(ih, "{", "SET", &sh) < 0)
@@ -1045,15 +1045,36 @@ static void dispatcher_rpc_list(rpc_t* rpc, void* ctx)
 			else
 				c[1] = 'X';
 
-			if(rpc->struct_add(vh, "SsdS",
+			if (list->dlist[j].attrs.body.s)
+			{
+				if(rpc->struct_add(vh, "Ssd{",
 						"URI", &list->dlist[j].uri,
 						"FLAGS", c,
 						"PRIORITY", list->dlist[j].priority,
-						"ATTRS", (list->dlist[j].attrs.body.s)?
-						&(list->dlist[j].attrs.body):&data)<0)
-			{
-				rpc->fault(ctx, 500, "Internal error creating dest struct");
-				return;
+						"ATTRS", &wh)<0)
+				{
+					rpc->fault(ctx, 500, "Internal error creating dest struct");
+					return;
+				}
+				if(rpc->struct_add(wh, "SSdd",
+						"BODY", &(list->dlist[j].attrs.body),
+						"DUID", (list->dlist[j].attrs.duid.s)?
+						&(list->dlist[j].attrs.duid):&data,
+						"MAXLOAD", list->dlist[j].attrs.maxload,
+						"WEIGHT", list->dlist[j].attrs.weight)<0)
+				{
+					rpc->fault(ctx, 500, "Internal error creating attrs struct");
+					return;
+				}
+			} else {
+				if(rpc->struct_add(vh, "Ssd",
+						"URI", &list->dlist[j].uri,
+						"FLAGS", c,
+						"PRIORITY", list->dlist[j].priority)<0)
+				{
+					rpc->fault(ctx, 500, "Internal error creating dest struct");
+					return;
+				}
 			}
 		}
 	}




More information about the sr-dev mailing list