Module: sip-router
Branch: master
Commit: 1cc0144e434fdcf76013e9424d31928c260d4377
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1cc0144…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Oct 30 22:11:04 2013 +0100
kamctl: updated dispatcher command to current db table fields
- parameters flags, priority, attrs and description are optional
---
utils/kamctl/kamctl | 41 ++++++++++++++++++++++++++++-------------
utils/kamctl/kamctl.base | 12 +++++++-----
2 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index b63b51e..2e25d2e 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -1564,27 +1564,44 @@ dispatcher() {
QUERY="select * FROM $DISPATCHER_TABLE ORDER BY $DISPATCHER_SETID_COLUMN; "
$DBROCMD "$QUERY"
;;
- addgw)
+ addgw|add)
shift
- if [ $# -lt 3 ] ; then
+ if [ $# -lt 2 ] ; then
merr "too few parameters"
usage_dispatcher
exit 1
fi
+ DISPATCHER_SETID=$1
+ DISPATCHER_DESTINATION=$2
+
+ if [ $# -gt 2 ] ; then
+ DISPATCHER_FLAGS=$3
+ else
+ DISPATCHER_FLAGS=0
+ fi
+
if [ $# -gt 3 ] ; then
- DISPATCHER_DESCRIPTION=$4
+ DISPATCHER_PRIORITY=$4
else
- DISPATCHER_DESCRIPTION=""
- fi
+ DISPATCHER_PRIORITY=0
+ fi
- DISPATCHER_SETID=$1
- DISPATCHER_DESTINATION=$2
- DISPATCHER_FLAGS=$3
+ if [ $# -gt 4 ] ; then
+ DISPATCHER_ATTRS=$5
+ else
+ DISPATCHER_ATTRS=""
+ fi
+
+ if [ $# -gt 5 ] ; then
+ DISPATCHER_DESCRIPTION=$6
+ else
+ DISPATCHER_DESCRIPTION=""
+ fi
QUERY="insert into $DISPATCHER_TABLE \
- ( $DISPATCHER_SETID_COLUMN, $DISPATCHER_DESTINATION_COLUMN, $DISPATCHER_FLAGS_COLUMN,
$DISPATCHER_DESCRIPTION_COLUMN ) \
- VALUES
($DISPATCHER_SETID,'$DISPATCHER_DESTINATION',$DISPATCHER_FLAGS,'$DISPATCHER_DESCRIPTION');"
+ ( $DISPATCHER_SETID_COLUMN, $DISPATCHER_DESTINATION_COLUMN, $DISPATCHER_FLAGS_COLUMN,
$DISPATCHER_PRIORITY_COLUMN, $DISPATCHER_ATTRS_COLUMN, $DISPATCHER_DESCRIPTION_COLUMN ) \
+ VALUES
($DISPATCHER_SETID,'$DISPATCHER_DESTINATION',$DISPATCHER_FLAGS,$DISPATCHER_PRIORITY,'$DISPATCHER_ATTRS','$DISPATCHER_DESCRIPTION');"
$DBCMD "$QUERY"
if [ $? -ne 0 ] ; then
@@ -1592,9 +1609,8 @@ dispatcher() {
exit 1
fi
- $CTLCMD ds_reload
;;
- rmgw)
+ rmgw|rm)
shift
if [ $# -ne 1 ] ; then
merr "missing gateway id to be removed"
@@ -1609,7 +1625,6 @@ dispatcher() {
exit 1
fi
- $CTLCMD ds_reload
;;
reload)
$CTLCMD ds_reload
diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base
index 94db676..a5e6211 100644
--- a/utils/kamctl/kamctl.base
+++ b/utils/kamctl/kamctl.base
@@ -310,6 +310,8 @@ DISPATCHER_ID_COLUMN=id
DISPATCHER_SETID_COLUMN=setid
DISPATCHER_DESTINATION_COLUMN=destination
DISPATCHER_FLAGS_COLUMN=flags
+DISPATCHER_PRIORITY_COLUMN=priority
+DISPATCHER_ATTRS_COLUMN=attrs
DISPATCHER_DESCRIPTION_COLUMN=description
# dialplan tables
@@ -468,15 +470,15 @@ usage_dispatcher() {
mecho " -- command 'dispatcher' - manage dispatcher"
echo
cat <<EOF
- * Examples: dispatcher addgw 1 sip:1.2.3.1:5050 1 'outbound gateway'
- * dispatcher addgw 2 sip:1.2.3.4:5050 3 ''
- * dispatcher rmgw 4
+ * Examples: dispatcher add 1 sip:1.2.3.1:5050 1 5 'prefix=123' 'gw
one'
+ * dispatcher add 2 sip:1.2.3.4:5050 3 0
+ * dispatcher rm 4
dispatcher show ..................... show dispatcher gateways
dispatcher reload ................... reload dispatcher gateways
dispatcher dump ..................... show in memory dispatcher gateways
- dispatcher addgw <setid> <destination> <flags> <description>
+ dispatcher add <setid> <destination> [flags] [priority] [attrs]
[description]
.......................... add gateway
- dispatcher rmgw <id> ................ delete gateway
+ dispatcher rm <id> .................. delete gateway
EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_dispatcher"