Bladeren bron

mohqueue: switched from MI to RPC commands

Robert Boisvert 8 jaren geleden
bovenliggende
commit
9c14592d45

+ 3 - 2
src/modules/mohqueue/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# msgqueue module makefile
+# mohqueue module makefile
 #
 #
 #
 #
 # WARNING: do not run this directly, it should be run by the master Makefile
 # WARNING: do not run this directly, it should be run by the master Makefile
@@ -13,4 +13,5 @@ DEFS+=-DKAMAILIO_MOD_INTERFACE
 
 
 SERLIBPATH=../../lib
 SERLIBPATH=../../lib
 SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
 SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
-include ../../Makefile.modules
+
+include ../../Makefile.modules

+ 1 - 1
src/modules/mohqueue/README

@@ -2,7 +2,7 @@ mohqueue Module
 
 
 Robert Boisvert
 Robert Boisvert
 
 
-   Copyright © 2013 Robert Boisvert, [email protected]
+   Copyright © 2013-2017 Robert Boisvert, [email protected]
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents

+ 63 - 18
src/modules/mohqueue/doc/mohqueue_admin.xml

@@ -88,7 +88,7 @@ The URL to connect to the database for the mohqueue tables.
         <title>Set <varname>db_url</varname>:</title>
         <title>Set <varname>db_url</varname>:</title>
         <programlisting format="linespecific">
         <programlisting format="linespecific">
 ...
 ...
-modparam("mohqueue", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")
+modparam ("mohqueue", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")
 ...
 ...
         </programlisting>
         </programlisting>
       </example>
       </example>
@@ -109,8 +109,8 @@ maintains the call status.
         <title>Set table names:</title>
         <title>Set table names:</title>
         <programlisting format="linespecific">
         <programlisting format="linespecific">
 ...
 ...
-modparam("mohqueue", "db_qtable", "mqueues")
-modparam("mohqueue", "db_ctable", "mcalls")
+modparam ("mohqueue", "db_qtable", "mqueues")
+modparam ("mohqueue", "db_ctable", "mcalls")
 ...
 ...
         </programlisting>
         </programlisting>
       </example>
       </example>
@@ -131,7 +131,7 @@ queues table.</emphasis>
         <title>Set default directory for audio files:</title>
         <title>Set default directory for audio files:</title>
         <programlisting format="linespecific">
         <programlisting format="linespecific">
 ...
 ...
-modparam("mohqueue", "mohdir", "/var/kamailio/MOH")
+modparam ("mohqueue", "mohdir", "/var/kamailio/MOH")
 ...
 ...
         </programlisting>
         </programlisting>
       </example>
       </example>
@@ -154,7 +154,7 @@ queues table.</emphasis>
         <title>Set default directory for audio files:</title>
         <title>Set default directory for audio files:</title>
         <programlisting format="linespecific">
         <programlisting format="linespecific">
 ...
 ...
-modparam("mohqueue", "mohdir", "/var/kamailio/MOH")
+modparam ("mohqueue", "mohdir", "/var/kamailio/MOH")
 ...
 ...
         </programlisting>
         </programlisting>
       </example>
       </example>
@@ -167,7 +167,7 @@ modparam("mohqueue", "mohdir", "/var/kamailio/MOH")
 
 
     <section id="proc.func">
     <section id="proc.func">
       <title>
       <title>
-        <function moreinfo="none">mohq_process()</function>
+        <function moreinfo="none">mohq_process ()</function>
       </title>
       </title>
       <para>
       <para>
 Checks to see if the current SIP message involves a queue. If it
 Checks to see if the current SIP message involves a queue. If it
@@ -207,8 +207,8 @@ request_route {
   # main route with limited processing
   # main route with limited processing
 ...
 ...
   # MOH queue?
   # MOH queue?
-  if (mohq_process()) {
-    xlog("L_DBG", "Handled by mohqueue");
+  if (mohq_process ()) {
+    xlog ("L_DBG", "Handled by mohqueue");
     exit;
     exit;
   }
   }
   # An error or not a MOH queue message; continue processing
   # An error or not a MOH queue message; continue processing
@@ -221,12 +221,12 @@ request_route {
 
 
     <section id="send.func">
     <section id="send.func">
       <title>
       <title>
-        <function moreinfo="none">mohq_send(queue_name)</function>
+        <function moreinfo="none">mohq_send (queue_name)</function>
       </title>
       </title>
       <para>
       <para>
 Normally calls enter the queue with an initial INVITE message that
 Normally calls enter the queue with an initial INVITE message that
 1) has a RURI that matches a queue URI and 2) is passed through
 1) has a RURI that matches a queue URI and 2) is passed through
-<function>mohq_process()</function>, which is the preferred method.
+<function>mohq_process ()</function>, which is the preferred method.
       </para>
       </para>
       <para>
       <para>
 This function is used when you wish to send a call into a queue that
 This function is used when you wish to send a call into a queue that
@@ -254,8 +254,8 @@ can be passed as a literal or pseudo-variable.
 ...
 ...
   # call is initial INVITE and ready for queue?
   # call is initial INVITE and ready for queue?
   if (some test) {
   if (some test) {
-    if (mohq_send("main")) {
-      xlog("L_DBG", "Sent call to main mohqueue");
+    if (mohq_send ("main")) {
+      xlog ("L_DBG", "Sent call to main mohqueue");
       exit;
       exit;
     }
     }
     # failed to enter queue!
     # failed to enter queue!
@@ -268,7 +268,7 @@ can be passed as a literal or pseudo-variable.
 
 
     <section id="retrieve.func">
     <section id="retrieve.func">
       <title>
       <title>
-        <function moreinfo="none">mohq_retrieve(queue_name, URI)</function>
+        <function moreinfo="none">mohq_retrieve (queue_name, URI)</function>
       </title>
       </title>
       <para>
       <para>
 Retrieves the oldest call in a queue and redirects it to a URI.
 Retrieves the oldest call in a queue and redirects it to a URI.
@@ -299,8 +299,8 @@ be called from any route.
 #!define CGROUP   "sip:[email protected]"
 #!define CGROUP   "sip:[email protected]"
 ...
 ...
   # redirect oldest call to operator call group
   # redirect oldest call to operator call group
-  if (mohq_retrieve(MOHQNAME, CGROUP)) {
-      xlog("L_DBG", "Retrieved call from mohqueue");
+  if (mohq_retrieve (MOHQNAME, CGROUP)) {
+      xlog ("L_DBG", "Retrieved call from mohqueue");
       exit;
       exit;
   }
   }
   # queue is empty or something went wrong
   # queue is empty or something went wrong
@@ -311,7 +311,7 @@ be called from any route.
 
 
     <section id="count.func">
     <section id="count.func">
       <title>
       <title>
-        <function moreinfo="none">mohq_count(queue_name, pvar)</function>
+        <function moreinfo="none">mohq_count (queue_name, pvar)</function>
       </title>
       </title>
       <para>
       <para>
 Finds the number of calls that are in a queue. It will not count
 Finds the number of calls that are in a queue. It will not count
@@ -341,9 +341,9 @@ any route.
 $var(mohq) = "operators";
 $var(mohq) = "operators";
 ...
 ...
   # more than 10 calls?
   # more than 10 calls?
-  mohq_count("$var(mohq)", "$var(mohqcnt)");
+  mohq_count ("$var(mohq)", "$var(mohqcnt)");
   if ($var(mohqcnt) > 10) {
   if ($var(mohqcnt) > 10) {
-    xlog("L_WARN", "$var(mohq) queue has $var(mohqcnt) calls!");
+    xlog ("L_WARN", "$var(mohq) queue has $var(mohqcnt) calls!");
   }
   }
 ...
 ...
         </programlisting>
         </programlisting>
@@ -463,6 +463,7 @@ fails this time is not changed.
     </section>
     </section>
 
 
   </section>
   </section>
+
   <section id="audiofiles">
   <section id="audiofiles">
     <title>Audio Files</title>
     <title>Audio Files</title>
       <para>
       <para>
@@ -506,4 +507,48 @@ payload types.
 
 
   </section>
   </section>
 
 
+  <section id="rpccmds">
+    <title>RPC Commands</title>
+
+    <section id="rpc.debug">
+      <title>
+        <function moreinfo="none">mohqueue.debug</function>
+      </title>
+      <para>
+Turns <ulink url="#mohqueues.dbase">debugging</ulink> on or off for a queue. The first paramater is the queue name and the second is a number indicating whether debugging should be turned off or on (0=off, <>0=on).
+      </para>
+      <example>
+        <title><function>rpc.debug</function> usage:</title>
+        <programlisting format="linespecific">
+...
+# enable debugging on the test queue
+rpc.debug test 1
+# disable debugging on the main queue
+rpc.debug main 0
+...
+        </programlisting>
+      </example>
+    </section>
+
+    <section id="rpc.drop_call">
+      <title>
+        <function moreinfo="none">mohqueue.drop_call</function>
+      </title>
+      <para>
+Drops a call from a queue. The first paramater is the queue name and the second is the <ulink url="#mohqcalls.dbase">call ID</ulink>. Using a call ID of "*" (asterisk) drops all calls from the queue.
+      </para>
+      <example>
+        <title><function>rpc.drop_call</function> usage:</title>
+        <programlisting format="linespecific">
+...
+# drop all calls from the test queue
+rpc.drop_call test *
+# drop a call from the main queue
+rpc.drop_call main [email protected]
+...
+        </programlisting>
+      </example>
+    </section>
+
+  </section>
 </chapter>
 </chapter>

+ 38 - 10
src/modules/mohqueue/mohq_common.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-15 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *
@@ -27,6 +27,32 @@
 
 
 #include "../rr/api.h"
 #include "../rr/api.h"
 
 
+#if SER_VER < 5000000
+#include "../../data_lump.h"
+#include "../../data_lump_rpl.h"
+#include "../../dprint.h"
+#include "../../dset.h"
+#include "../../flags.h"
+#include "../../hashes.h"
+#include "../../locking.h"
+#include "../../lvalue.h"
+#include "../../mod_fix.h"
+#include "../../rpc.h"
+#include "../../rpc_lookup.h"
+#include "../../sr_module.h"
+#include "../../str.h"
+
+#include "../../mem/mem.h"
+#include "../../mem/shm_mem.h"
+
+#include "../../parser/hf.h"
+#include "../../parser/msg_parser.h"
+#include "../../parser/contact/parse_contact.h"
+#include "../../parser/parse_expires.h"
+#include "../../parser/parse_from.h"
+#include "../../parser/parse_rr.h"
+#include "../../parser/sdp/sdp.h"
+#else
 #include "../../core/data_lump.h"
 #include "../../core/data_lump.h"
 #include "../../core/data_lump_rpl.h"
 #include "../../core/data_lump_rpl.h"
 #include "../../core/dprint.h"
 #include "../../core/dprint.h"
@@ -35,16 +61,9 @@
 #include "../../core/hashes.h"
 #include "../../core/hashes.h"
 #include "../../core/locking.h"
 #include "../../core/locking.h"
 #include "../../core/lvalue.h"
 #include "../../core/lvalue.h"
-#include "../../core/mod_fix.h"
-#include "../../core/sr_module.h"
-#include "../../core/str.h"
-
-#include "../../core/strutils.h"
-#include "../../lib/srdb1/db.h"
 #include "../../core/mem/mem.h"
 #include "../../core/mem/mem.h"
 #include "../../core/mem/shm_mem.h"
 #include "../../core/mem/shm_mem.h"
-#include "../../modules/sl/sl.h"
-#include "../../modules/tm/tm_load.h"
+#include "../../core/mod_fix.h"
 #include "../../core/parser/hf.h"
 #include "../../core/parser/hf.h"
 #include "../../core/parser/msg_parser.h"
 #include "../../core/parser/msg_parser.h"
 #include "../../core/parser/contact/parse_contact.h"
 #include "../../core/parser/contact/parse_contact.h"
@@ -52,6 +71,15 @@
 #include "../../core/parser/parse_from.h"
 #include "../../core/parser/parse_from.h"
 #include "../../core/parser/parse_rr.h"
 #include "../../core/parser/parse_rr.h"
 #include "../../core/parser/sdp/sdp.h"
 #include "../../core/parser/sdp/sdp.h"
+#include "../../core/rpc.h"
+#include "../../core/rpc_lookup.h"
+#include "../../core/sr_module.h"
+#include "../../core/str.h"
+#endif
+
+#include "../../lib/srdb1/db.h"
+#include "../../modules/sl/sl.h"
+#include "../../modules/tm/tm_load.h"
 
 
 /* convenience macros */
 /* convenience macros */
 #define MOHQ_STRUCT_PTR_OFFSET( struct1, cast1, offset1 ) \
 #define MOHQ_STRUCT_PTR_OFFSET( struct1, cast1, offset1 ) \
@@ -99,4 +127,4 @@
 #define MOHQ_HEADER_EMPTY( hdr1 ) \
 #define MOHQ_HEADER_EMPTY( hdr1 ) \
 	((hdr1) == NULL || MOHQ_STR_EMPTY( &(hdr1)->body ))
 	((hdr1) == NULL || MOHQ_STR_EMPTY( &(hdr1)->body ))
 
 
-#endif /* MOHQ_COMMON_H */
+#endif /* MOHQ_COMMON_H */

+ 1 - 1
src/modules/mohqueue/mohq_db.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-15 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *

+ 49 - 39
src/modules/mohqueue/mohq_funcs.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-16 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *
@@ -32,7 +32,7 @@
 #define ALLOWHDR "Allow: INVITE, ACK, BYE, CANCEL, NOTIFY, PRACK"
 #define ALLOWHDR "Allow: INVITE, ACK, BYE, CANCEL, NOTIFY, PRACK"
 #define CLENHDR "Content-Length"
 #define CLENHDR "Content-Length"
 #define SIPEOL  "\r\n"
 #define SIPEOL  "\r\n"
-#define USRAGNT "Kamailio MOH Queue v1.3"
+#define USRAGNT "Kamailio MOH Queue v1.4"
 
 
 /**********
 /**********
 * local constants
 * local constants
@@ -43,8 +43,6 @@ str pallq [1] = {STR_STATIC_INIT ("*")};
 str paudio [1] = {STR_STATIC_INIT ("audio")};
 str paudio [1] = {STR_STATIC_INIT ("audio")};
 str pbye [1] = {STR_STATIC_INIT ("BYE")};
 str pbye [1] = {STR_STATIC_INIT ("BYE")};
 str pinvite [1] = {STR_STATIC_INIT ("INVITE")};
 str pinvite [1] = {STR_STATIC_INIT ("INVITE")};
-str pmi_nolock [1] = {STR_STATIC_INIT ("Unable to lock queue")};
-str pmi_noqueue [1] = {STR_STATIC_INIT ("No matching queue name found")};
 str prefer [1] = {STR_STATIC_INIT ("REFER")};
 str prefer [1] = {STR_STATIC_INIT ("REFER")};
 str presp_busy [1] = {STR_STATIC_INIT ("Busy Here")};
 str presp_busy [1] = {STR_STATIC_INIT ("Busy Here")};
 str presp_noaccept [1] = {STR_STATIC_INIT ("Not Acceptable Here")};
 str presp_noaccept [1] = {STR_STATIC_INIT ("Not Acceptable Here")};
@@ -2370,21 +2368,20 @@ pmohfiles [nfound] = 0;
 return pmohfiles;
 return pmohfiles;
 }
 }
 
 
-#ifdef MI_REMOVED
 /**********
 /**********
-* MI Debug
+* RPC Debug
 *
 *
 * PARAMETERS:
 * PARAMETERS:
 * queue name = queue to use
 * queue name = queue to use
 * state = 0=off, <>0=on
 * state = 0=off, <>0=on
 *
 *
 * INPUT:
 * INPUT:
-*   Arg (1) = command tree pointer
-*   Arg (2) = parms pointer
-* OUTPUT: root pointer
+*   Arg (1) = rpc handle
+*   Arg (2) = rpc context pointer
+* OUTPUT: none
 **********/
 **********/
 
 
-struct mi_root *mi_debug (struct mi_root *pcmd_tree, void *parms)
+void mohqueue_rpc_debug (rpc_t *prpc, void *pctx)
 
 
 {
 {
 /**********
 /**********
@@ -2393,20 +2390,25 @@ struct mi_root *mi_debug (struct mi_root *pcmd_tree, void *parms)
 * o lock queue
 * o lock queue
 **********/
 **********/
 
 
-struct mi_node *pnode = pcmd_tree->node.kids;
-if (!pnode || !pnode->next || pnode->next->next)
-  { return init_mi_tree (400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); }
-int nq_idx = find_qname (&pnode->value);
+str pqname [1];
+int bdebug;
+if (prpc->scan (pctx, "Sd", pqname, &bdebug) != 2)
+  {
+  prpc->fault (pctx, 400, "Too few parameters!");
+  return;
+  }
+int nq_idx = find_qname (pqname);
 if (nq_idx == -1)
 if (nq_idx == -1)
-  { return init_mi_tree (400, pmi_noqueue->s, pmi_noqueue->len); }
-char pint [20];
-int nsize = (pnode->next->value.len >= sizeof (pint))
-  ? sizeof (pint) - 1 : pnode->next->value.len;
-strncpy (pint, pnode->next->value.s, nsize);
-pint [nsize] = '\0';
-int bdebug = atoi (pint) ? 1 : 0;
-if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 5000))
-  { return init_mi_tree (400, pmi_nolock->s, pmi_nolock->len); }
+  {
+  prpc->fault (pctx, 401, "No such queue (%.*s)!", STR_FMT (pqname));
+  return;
+  }
+if (!mohq_lock_set (pmod_data->pcall_lock, 0, 5000))
+  {
+  prpc->fault
+    (pctx, 402, "Unable to lock the queue (%.*s)!", STR_FMT (pqname));
+  return;
+  }
 
 
 /**********
 /**********
 * o set flag
 * o set flag
@@ -2421,23 +2423,23 @@ else
   { pqueue->mohq_flags &= ~MOHQF_DBG; }
   { pqueue->mohq_flags &= ~MOHQF_DBG; }
 update_debug (pqueue, bdebug);
 update_debug (pqueue, bdebug);
 mohq_lock_release (pmod_data->pmohq_lock);
 mohq_lock_release (pmod_data->pmohq_lock);
-return init_mi_tree (200, MI_OK_S, MI_OK_LEN);
+return;
 }
 }
 
 
 /**********
 /**********
-* MI Drop Call
+* RPC Drop Call
 *
 *
 * PARAMETERS:
 * PARAMETERS:
 * queue name = queue to use
 * queue name = queue to use
 * callID = *=all, otherwise callID
 * callID = *=all, otherwise callID
 *
 *
 * INPUT:
 * INPUT:
-*   Arg (1) = command tree pointer
-*   Arg (2) = parms pointer
-* OUTPUT: root pointer
+*   Arg (1) = rpc handle
+*   Arg (2) = rpc context pointer
+* OUTPUT: none
 **********/
 **********/
 
 
-struct mi_root *mi_drop_call (struct mi_root *pcmd_tree, void *parms)
+void mohqueue_rpc_drop_call (rpc_t *prpc, void *pctx)
 
 
 {
 {
 /**********
 /**********
@@ -2446,14 +2448,24 @@ struct mi_root *mi_drop_call (struct mi_root *pcmd_tree, void *parms)
 * o lock calls
 * o lock calls
 **********/
 **********/
 
 
-struct mi_node *pnode = pcmd_tree->node.kids;
-if (!pnode || !pnode->next || pnode->next->next)
-  { return init_mi_tree (400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); }
-int nq_idx = find_qname (&pnode->value);
+str pcallid [1], pqname [1];
+if (prpc->scan (pctx, "SS", pqname, pcallid) != 2)
+  {
+  prpc->fault (pctx, 400, "Too few parameters!");
+  return;
+  }
+int nq_idx = find_qname (pqname);
 if (nq_idx == -1)
 if (nq_idx == -1)
-  { return init_mi_tree (400, pmi_noqueue->s, pmi_noqueue->len); }
+  {
+  prpc->fault (pctx, 401, "No such queue (%.*s)!", STR_FMT (pqname));
+  return;
+  }
 if (!mohq_lock_set (pmod_data->pcall_lock, 0, 5000))
 if (!mohq_lock_set (pmod_data->pcall_lock, 0, 5000))
-  { return init_mi_tree (400, pmi_nolock->s, pmi_nolock->len); }
+  {
+  prpc->fault
+    (pctx, 402, "Unable to lock the queue (%.*s)!", STR_FMT (pqname));
+  return;
+  }
 
 
 /**********
 /**********
 * o find matching calls
 * o find matching calls
@@ -2462,7 +2474,6 @@ if (!mohq_lock_set (pmod_data->pcall_lock, 0, 5000))
 
 
 mohq_lst *pqueue = &pmod_data->pmohq_lst [nq_idx];
 mohq_lst *pqueue = &pmod_data->pmohq_lst [nq_idx];
 int nidx;
 int nidx;
-str *pcallid = &pnode->next->value;
 for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
 for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
   {
   {
   /**********
   /**********
@@ -2487,9 +2498,8 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
   close_call (FAKED_REPLY, pcall);
   close_call (FAKED_REPLY, pcall);
   }
   }
 mohq_lock_release (pmod_data->pcall_lock);
 mohq_lock_release (pmod_data->pcall_lock);
-return init_mi_tree (200, MI_OK_S, MI_OK_LEN);
+return;
 }
 }
-#endif
 
 
 /**********
 /**********
 * Count Messages
 * Count Messages
@@ -2927,4 +2937,4 @@ if (pmod_data->ptm->t_relay (pmsg, 0, 0) < 0)
   return -1;
   return -1;
   }
   }
 return 1;
 return 1;
-}
+}

+ 4 - 2
src/modules/mohqueue/mohq_funcs.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-15 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *
@@ -31,6 +31,8 @@ int mohq_count (sip_msg_t *, char *, pv_spec_t *);
 void mohq_debug (mohq_lst *, char *, ...);
 void mohq_debug (mohq_lst *, char *, ...);
 int mohq_process (sip_msg_t *);
 int mohq_process (sip_msg_t *);
 int mohq_retrieve (sip_msg_t *, char *, char *);
 int mohq_retrieve (sip_msg_t *, char *, char *);
+void mohqueue_rpc_debug (rpc_t *, void *);
+void mohqueue_rpc_drop_call (rpc_t *, void *);
 int mohq_send (sip_msg_t *, char *);
 int mohq_send (sip_msg_t *, char *);
 
 
-#endif /* MOHQ_FUNCS_H */
+#endif /* MOHQ_FUNCS_H */

+ 1 - 1
src/modules/mohqueue/mohq_locks.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-15 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *

+ 1 - 3
src/modules/mohqueue/mohq_locks.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-15 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *
@@ -22,8 +22,6 @@
 #ifndef MOHQ_LOCKS_H
 #ifndef MOHQ_LOCKS_H
 #define MOHQ_LOCKS_H
 #define MOHQ_LOCKS_H
 
 
-#include "../../core/locking.h"
-
 /**********
 /**********
 * lock record
 * lock record
 **********/
 **********/

+ 33 - 11
src/modules/mohqueue/mohqueue_mod.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-16 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *
@@ -75,14 +75,26 @@ static param_export_t mod_parms [] = {
   { NULL, 0, NULL },
   { NULL, 0, NULL },
 };
 };
 
 
-#ifdef MI_REMOVED
-/* MI COMMANDS */
-static mi_export_t mi_cmds [] = {
-  { "debug", mi_debug, 0, 0, 0 },
-  { "drop_call", mi_drop_call, 0, 0, 0 },
-  { 0, 0, 0, 0, 0 }
-};
-#endif
+static const char *mohqueue_rpc_debug_doc [] =
+  {
+  "Toggle mohqueue debug mode. Parameters: queue name, state (0=off, <>0=on)",
+  0
+  };
+
+static const char *mohqueue_rpc_drop_call_doc [] =
+  {
+  "Drop a mohqueue call. Parameters: queue name, callID (*=all)",
+  0
+  };
+
+/* RPC COMMANDS */
+rpc_export_t mohqueue_rpc [] =
+  {
+    { "mohqueue.debug", mohqueue_rpc_debug, mohqueue_rpc_debug_doc, 0 },
+    { "mohqueue.drop_call", mohqueue_rpc_drop_call,
+      mohqueue_rpc_drop_call_doc, 0 },
+    { 0, 0, 0, 0 }
+  };
 
 
 /* MODULE EXPORTS */
 /* MODULE EXPORTS */
 struct module_exports exports = {
 struct module_exports exports = {
@@ -91,7 +103,7 @@ struct module_exports exports = {
   mod_cmds,         /* exported functions */
   mod_cmds,         /* exported functions */
   mod_parms,        /* exported parameters */
   mod_parms,        /* exported parameters */
   0,                /* statistics */
   0,                /* statistics */
-  0,                 /* MI functions */
+  0,                /* MI functions */
   0,                /* exported pseudo-variables */
   0,                /* exported pseudo-variables */
   0,                /* extra processes */
   0,                /* extra processes */
   mod_init,         /* module initialization function */
   mod_init,         /* module initialization function */
@@ -441,6 +453,16 @@ if (!pmod_data->fn_rtp_destroy)
   goto initerr;
   goto initerr;
   }
   }
 
 
+/**********
+* register RPC
+**********/
+
+if (rpc_register_array (mohqueue_rpc))
+  {
+  LM_ERR ("Unable to register RPC commands!\n");
+  return -1;
+  }
+
 /**********
 /**********
 * get RTPSTAT pv spec
 * get RTPSTAT pv spec
 **********/
 **********/
@@ -481,4 +503,4 @@ if (pmod_data->pcall_lock->plock)
 shm_free (pmod_data);
 shm_free (pmod_data);
 pmod_data = NULL;
 pmod_data = NULL;
 return -1;
 return -1;
-}
+}

+ 1 - 1
src/modules/mohqueue/mohqueue_mod.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-15 Robert Boisvert
+ * Copyright (C) 2013-17 Robert Boisvert
  *
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
  *