[svn-commits] oej: branch oej/moremanager r63244 - in
/team/oej/moremanager: ./ channels/ i...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon May 7 12:46:47 MST 2007
Author: oej
Date: Mon May 7 14:46:47 2007
New Revision: 63244
URL: http://svn.digium.com/view/asterisk?view=rev&rev=63244
Log:
- Two new Module commands for loading/reloading/unloading modules and checking if they're loaded
- Change the "Unhold" event to "Hold" with a Status: header to signal hold/unhold
Modified:
team/oej/moremanager/CHANGES.moremanager
team/oej/moremanager/channels/chan_iax2.c
team/oej/moremanager/channels/chan_sip.c
team/oej/moremanager/include/asterisk.h
team/oej/moremanager/include/asterisk/module.h
team/oej/moremanager/main/asterisk.c
team/oej/moremanager/main/loader.c
Modified: team/oej/moremanager/CHANGES.moremanager
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/CHANGES.moremanager?view=diff&rev=63244&r1=63243&r2=63244
==============================================================================
--- team/oej/moremanager/CHANGES.moremanager (original)
+++ team/oej/moremanager/CHANGES.moremanager Mon May 7 14:46:47 2007
@@ -10,6 +10,11 @@
* CHANGED EVENTS AND ACTIONS
----------------------------
+- The Hold/Unhold events
+ - Both are now "Hold" events
+ For hold, there's a "Status: On" header, for unhold, status is off
+ - Modules chan_sip/chan_iax2
+
- The Ping Action
- Now use Response: success
- New header "Ping: pong" :-)
@@ -113,6 +118,16 @@
The operation to be done on module
If no module is specified for a reload loadtype, all modules are reloaded
+- Action: ModuleCheck
+ Modules: loader.c
+ Purpose:
+ To check version of a module - if it's loaded
+ Variables:
+ ActionID: <id> Action ID for this transaction. Will be returned.
+ Module: <name> Asterisk module name (not including extension)
+ Returns:
+ If module is loaded, returns version number of the module
+
* NEW EVENTS
------------
Modified: team/oej/moremanager/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/channels/chan_iax2.c?view=diff&rev=63244&r1=63243&r2=63244
==============================================================================
--- team/oej/moremanager/channels/chan_iax2.c (original)
+++ team/oej/moremanager/channels/chan_iax2.c Mon May 7 14:46:47 2007
@@ -6729,6 +6729,7 @@
/* Generate Manager Hold event, if necessary*/
if (iaxs[fr->callno]->owner) {
manager_event(EVENT_FLAG_CALL, "Hold",
+ "Status: On\r\n"
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
iaxs[fr->callno]->owner->name,
@@ -6750,7 +6751,8 @@
if (ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED)) {
/* Generate Manager Unhold event, if necessary*/
if (iaxs[fr->callno]->owner && ast_test_flag(iaxs[fr->callno], IAX_QUELCH)) {
- manager_event(EVENT_FLAG_CALL, "Unhold",
+ manager_event(EVENT_FLAG_CALL, "Hold",
+ "Status: Off\r\n"
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
iaxs[fr->callno]->owner->name,
Modified: team/oej/moremanager/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/channels/chan_sip.c?view=diff&rev=63244&r1=63243&r2=63244
==============================================================================
--- team/oej/moremanager/channels/chan_sip.c (original)
+++ team/oej/moremanager/channels/chan_sip.c Mon May 7 14:46:47 2007
@@ -5258,7 +5258,8 @@
if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
append_history(p, "Unhold", "%s", req->data);
if (global_callevents)
- manager_event(EVENT_FLAG_CALL, "Unhold",
+ manager_event(EVENT_FLAG_CALL, "Hold",
+ "Status: Off\r\n"
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
p->owner->name,
@@ -5273,6 +5274,7 @@
if (global_callevents && !ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
manager_event(EVENT_FLAG_CALL, "Hold",
+ "Status: On\r\n"
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
p->owner->name,
Modified: team/oej/moremanager/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/include/asterisk.h?view=diff&rev=63244&r1=63243&r2=63244
==============================================================================
--- team/oej/moremanager/include/asterisk.h (original)
+++ team/oej/moremanager/include/asterisk.h Mon May 7 14:46:47 2007
@@ -136,6 +136,12 @@
*/
void ast_unregister_file_version(const char *file);
+/*! \brief Find version for given module name
+ * \param file Module name (i.e. chan_sip.so)
+ * \return version string or NULL if the module is not found
+ */
+const char *ast_file_version_find(const char *file);
+
/*!
* \brief Register/unregister a source code file with the core.
* \param file the source file name
Modified: team/oej/moremanager/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/include/asterisk/module.h?view=diff&rev=63244&r1=63243&r2=63244
==============================================================================
--- team/oej/moremanager/include/asterisk/module.h (original)
+++ team/oej/moremanager/include/asterisk/module.h Mon May 7 14:46:47 2007
@@ -201,6 +201,9 @@
void ast_module_register(const struct ast_module_info *);
void ast_module_unregister(const struct ast_module_info *);
+/*! \brief Check if module exists */
+int ast_module_check(const char *name);
+
struct ast_module_user *__ast_module_user_add(struct ast_module *, struct ast_channel *);
void __ast_module_user_remove(struct ast_module *, struct ast_module_user *);
void __ast_module_user_hangup_all(struct ast_module *);
Modified: team/oej/moremanager/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/asterisk.c?view=diff&rev=63244&r1=63243&r2=63244
==============================================================================
--- team/oej/moremanager/main/asterisk.c (original)
+++ team/oej/moremanager/main/asterisk.c Mon May 7 14:46:47 2007
@@ -286,6 +286,23 @@
AST_LIST_UNLOCK(&file_versions);
if (find)
free(find);
+}
+
+/*! \brief Find version for given module name */
+const char *ast_file_version_find(const char *file)
+{
+ struct file_version *iterator;
+
+ AST_LIST_LOCK(&file_versions);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&file_versions, iterator, list) {
+ if (!strcasecmp(iterator->file, file))
+ break;
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ AST_LIST_UNLOCK(&file_versions);
+ if (iterator)
+ return iterator->version;
+ return NULL;
}
struct thread_list_t {
Modified: team/oej/moremanager/main/loader.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/loader.c?view=diff&rev=63244&r1=63243&r2=63244
==============================================================================
--- team/oej/moremanager/main/loader.c (original)
+++ team/oej/moremanager/main/loader.c Mon May 7 14:46:47 2007
@@ -82,6 +82,8 @@
/* Forward declaration */
static int manager_moduleload(struct mansession *s, const struct message *m);
static char mandescr_moduleload[];
+static int manager_modulecheck(struct mansession *s, const struct message *m);
+static char mandescr_modulecheck[];
struct ast_module {
const struct ast_module_info *info;
@@ -858,6 +860,7 @@
AST_LIST_UNLOCK(&module_list);
ast_manager_register2("ModuleLoad", EVENT_FLAG_SYSTEM, manager_moduleload, "Module management", mandescr_moduleload);
+ ast_manager_register2("ModuleCheck", EVENT_FLAG_SYSTEM, manager_modulecheck, "Check if module is loaded", mandescr_modulecheck);
/* Tell manager clients that are aggressive at logging in that we're done
loading modules. If there's a DNS problem in chan_sip, we might not
@@ -898,6 +901,20 @@
return total_mod_loaded;
}
+/*! \brief Check if module exists */
+int ast_module_check(const char *name)
+{
+ struct ast_module *cur;
+
+ if (ast_strlen_zero(name))
+ return 0; /* FALSE */
+
+ cur = find_resource(name, 1);
+
+ return (cur != NULL);
+}
+
+
int ast_loader_register(int (*v)(void))
{
struct loadupdate *tmp;
@@ -943,6 +960,51 @@
ast_atomic_fetchadd_int(&mod->usecount, -1);
ast_update_use_count();
}
+
+static char mandescr_modulecheck[] =
+"Description: Checks if Asterisk module is loaded\n"
+"Variables: \n"
+" ActionID: <id> Action ID for this transaction. Will be returned.\n"
+" Module: <name> Asterisk module name (not including extension)\n"
+"\n"
+"Will return Success/Failure\n"
+"For success returns, the module revision number is included.\n";
+
+/* Manager function to check if module is loaded */
+static int manager_modulecheck(struct mansession *s, const struct message *m)
+{
+ int res;
+ const char *module = astman_get_header(m, "Module");
+ const char *id = astman_get_header(m,"ActionID");
+ char idText[BUFSIZ];
+ const char *version;
+ char filename[BUFSIZ/2];
+ char *cut;
+
+ snprintf(filename, sizeof(filename), module);
+ if ((cut = strchr(filename, '.'))) {
+ *cut = '\0';
+ } else {
+ cut = filename + strlen(filename);
+ }
+ sprintf(cut, ".so");
+ ast_log(LOG_DEBUG, "**** ModuleCheck .so file %s\n", filename);
+ res = ast_module_check(filename);
+ if (!res) {
+ astman_send_error(s, m, "Module not loaded");
+ return 0;
+ }
+ sprintf(cut, ".c");
+ ast_log(LOG_DEBUG, "**** ModuleCheck .c file %s\n", filename);
+ version = ast_file_version_find(filename);
+
+ if (!ast_strlen_zero(id))
+ snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
+ astman_append(s, "Response: Success\r\n%s", idText);
+ astman_append(s, "Version: %s\r\n\r\n", version ? version : "");
+ return 0;
+}
+
static char mandescr_moduleload[] =
"Description: Loads, unloads or reloads an Asterisk module in a running system.\n"
More information about the svn-commits
mailing list