Commit Graph

62 Commits

Author SHA1 Message Date
Luigi Rizzo 0bf4235ff1 add a new cli/manager.conf option "debug" to enable/disable
debugging code in the manager.
At the moment the debugging code is very lightweight, if the option
is enabled manager messages also carry a sequence number and
the info where they have been generated e.g.

SequenceNumber: 10
File: chan_sip.c
Line: 11927
Func: handle_response_register

It is not worthwhile having this as a compile time option
right now, because the extra work involved at runtime is
just checking one variable.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47132 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-03 18:53:26 +00:00
Tilghman Lesher 10875731ec Merged revisions 47051 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r47051 | tilghman | 2006-11-02 17:00:20 -0600 (Thu, 02 Nov 2006) | 2 lines

Reverse change of "show" to "list" and make several other commands more consistent with "category verb arguments"

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47052 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-02 23:16:09 +00:00
Russell Bryant 59dbf47c91 Fix the new send text manager command. There is no way this could have worked.
- Check the channel name string length to be zero, not non-zero
- Check the message string length to be zero, not non-zero
- unlock the channel *after* calling sendtext


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46661 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-31 15:22:28 +00:00
Olle Johansson 1aa8c2cffc Add manager sendtext action. (Issue 6131, ZX81 - thanks!)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-31 10:42:22 +00:00
Olle Johansson 692dc8fd80 Issue #3930 - Add manager command for listing dialplan (coded april 2005, in bugtracker since)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46508 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-30 21:18:39 +00:00
Russell Bryant 0ca6a42d7e fix various spelling mistakes in comments (issue #8237, jmls)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-26 17:52:15 +00:00
Luigi Rizzo 6b2b63a909 fix a problem that i recently introduced when
the manager receives long commands.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46319 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-26 12:47:23 +00:00
Mark Spencer b7517f1231 Fix comment preservation code (thanks murf!)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46288 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-26 01:38:47 +00:00
Luigi Rizzo a7d5fcd8b8 i really think it is safe to commit this version, that
simplifies the manager queue handling as described in
the comment, and will make a lot easier to make further
work on this code.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-24 17:14:12 +00:00
Luigi Rizzo edd8e11889 minor comment changes, code rearrangement and field renaming
to minimize diffs with future modifications.

The current implementation is problematic for the following reasons:
+ all insertions are O(N) because the event list does not have a tail
  pointer;
+ there is only a single lock protecting both session and users queues.
+ the implementation of the queue itself is not documented.
  I think i have figured it out, more or less, but am unclear on
  whether there is proper locking in place

The rewrite (which i have working locally) uses a tailq so insertions
are O(1), separate locks for the event and session queues, and has
a documented implementation so hopefully we can figure out if/where
bug exist.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45753 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-20 11:24:43 +00:00
Olle Johansson e19576388d Doxygen corrections
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45742 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-20 08:00:13 +00:00
Luigi Rizzo e7c2295b81 more fixes to comments and very minor code rearrangement.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45696 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 17:26:20 +00:00
Luigi Rizzo 32214ffc02 implement proper XML/HTML formatting of multiple messages
(e.g. the result of waitevent).

Also fix some comments.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45690 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 17:07:08 +00:00
Luigi Rizzo 9934b7f4d2 more documentation of data structure and functions.
Of interest:
+ ast_get_manager_by_name_locked() is now without the ast_
  prefix as it is a local function;

+ unuse_eventqent() renamed to unref_event(), and returns
  the pointer to the next entry.

+ marked with XXX a couple of usages of unref_event()
  because i suspect we are addressing the wrong entry.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45648 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 07:43:43 +00:00
Russell Bryant bd53e7ee4c Extend the thread storage API such that a custom initialization function can
be called for each thread specific object after they are allocated.  Note that
there was already the ability to define a custom cleanup function.  Also, if
the custom cleanup function is used, it *MUST* call free on the thread
specific object at the end.  There is no way to have this magically done that
I can think of because the cleanup function registered with the pthread
implementation will only call the function back with a pointer to the
thread specific object, not the parent ast_threadstorage object.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45623 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 01:00:57 +00:00
Luigi Rizzo 71c67605ca silent warning from a debugging message (which will go away
soon, anyways)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45611 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 22:40:02 +00:00
Luigi Rizzo eee51dbd1c remove trailing whitespace
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45599 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 21:41:09 +00:00
Luigi Rizzo 9e9edb05ec ouch! remember to unlink temporary files once done with them.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45598 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 21:36:20 +00:00
Luigi Rizzo 3c2eaaf1f0 + move output_format variables in the http section of the file;
+ more comments on struct mansession and global variables;
+ small improvements to the session matching code so it supports
  multiple sessions from the same IP



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45597 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 21:30:21 +00:00
Luigi Rizzo c046fb40d8 another bunch of comments on the data structures.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45583 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 17:53:47 +00:00
Luigi Rizzo a518165207 despite the large changes, this commit only moves functions
around so that functions belonging to the same group are
close to each other.

At the beginning of each group i have added a bit of documentation
to explain what the group does and what is the typical flow - basically,
all i have learned by code inspection over the past few days should
be documented for you to read.

I have not put many doxygen annotations just because i am not
sure what are the proper ones. Hopefully some doxygen experts will jump in.

Next on the plate: try to figure out how "struct eventqent"
are supposed to work.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 17:45:50 +00:00
Luigi Rizzo a18accc09e more comment and formatting fixes, small simplifications
to functions get_input() and session_do()



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45572 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 16:52:13 +00:00
Matt O'Gorman 1783aef1e8 rizzo compile then commit, maybe even run it too ^_^
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45571 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 16:45:22 +00:00
Luigi Rizzo 71cf14207c comment and cleanup the main thread.
On passing, fix a bug: close the socket if the allocation
of a structure for the new session fails.
(the bugfix is a candidate for 1.4)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45561 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 15:49:40 +00:00
Luigi Rizzo eb3767cafe create a new (internal, for the time being) function astman_start_ack()
to start manager responses that need further lines.
This removes a lot of duplicate code from the various handlers
that at the moment build an ActionID string themselves.

Once settled, the function should move to manager.h so
it can be used by other files (chan_agent, chan_iax2, chan_sip,
chan_zap, res_jabber and app_queue).

I am not totally clear if there is a preferred position for
the ActionID: line in a message. Some instances put it at
the end, but one would argue that it is preferable to have
it at the beginning.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 14:21:15 +00:00
Luigi Rizzo df06a40b05 more indentation cleanup from previous commits,
and remove the "busy" field from struct mansession
as it was not used correctly anyways.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45541 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 13:42:14 +00:00
Luigi Rizzo 46b5c26399 create proper handlers for "Challenge" and "Login" actions,
rather than use inline code for them.
Things are more readable this way, and also error processing
is more consistent.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45540 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 13:23:22 +00:00
Luigi Rizzo becfe17739 fix indentation from a commit of a couple of days ago
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45530 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 12:55:12 +00:00
Luigi Rizzo 8e63fb21da another batch of simplifications to authenticate()
(they are committed a bit at a time so it is easier to
revert them in case we find a bug at a later time).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45529 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 12:38:24 +00:00
Luigi Rizzo d171c3d864 remove unused fields and unimplemented options.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45518 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 11:59:08 +00:00
Luigi Rizzo 998732456f first pass as simplifying authenticate(), avoiding whitespace changes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45516 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 11:54:06 +00:00
Luigi Rizzo bc66d9b7d8 more code simplifications
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45515 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 11:43:31 +00:00
Luigi Rizzo c93be15b7e simplify ast_strings_to_mask
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45505 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 10:14:58 +00:00
Luigi Rizzo efd87b68ee add a comment to remember that a block of code is
completely redundant.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45495 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 08:48:50 +00:00
Luigi Rizzo 2102d73bf4 + move the enum declaration for output formats near the head
of the file, so it can be used from more places;
+ make the declaration of contenttype[] more robust;
+ remove the wrappers around __xml_translate(), since they were
  used only in one place, and rename to xml_translate().
  This allows for a bit of simplifications.
+ document the output produced by the above function.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45485 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 06:28:34 +00:00
Luigi Rizzo 3a3b26658e merge xml_translate() and html_translate() into one function since
they do similar things.

Add a small form on top of the html output so request like
http://foo:8088/asterisk/manager will suggest you what to do.

Note: i suspect there is still a bug somewhere in the session matching
code, as sometimes you have to login twice in order for the following
commands to be recognised.

Apart from this, the cli now is basically usable from a web form!



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45475 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 05:31:54 +00:00
Joshua Colp 17fabe225d Warning be gone!
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45398 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 21:09:49 +00:00
Luigi Rizzo 3e2a2bfd7e simplify authority_to_str() using ast_build_string()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 18:08:51 +00:00
Luigi Rizzo 3abf04cc26 Improve the XML formatting of responses coming from web interface.
Normal responses are sequences of lines of the form "Name: value",
with \r\n as line terminators and an empty line as a response
terminator.

Generi CLI commands, however, do not have such a clean formatting,
and the existing code failed to generate valid XML for them.
Obviously we can only use heuristics here, and we do the following:
- accept either \r or \n as a line terminator, trimming trailing whitespace;
- if a line does not have a ":" in it, assume that from this point on
  we have unformatted data, and use "Opaque-data:" as a name;
- if a line does have a ":" in it, the Name field is not always
  a legal identifier, so replace non-alphanum characters with underscores;

All the above is to be refined as we improve the formatting of
responses from the CLI.

And, all the above ought to go as a comment in the code rather than
just in a commit message...
  


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45334 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 17:51:34 +00:00
Luigi Rizzo f2d12f4d06 open a temporary file to receive the output from cli commands
invoked through the http interface.

It is not terribly efficient but better than no output at all.
Todo: use a configurable /tmp directory instead of a hardwired one.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45330 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 17:41:59 +00:00
Luigi Rizzo 0c7e8f99a4 document xml_copy_escape() and add an extra function, namely
replace non-alphanum chars with underscore.
This is useful when building field names in xml formatting.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45325 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 17:19:31 +00:00
Luigi Rizzo 5f395bf38f + comment some unclear fields of struct mansession;
+ let some commands (Challenge, Login) be processed even if
  already authenticated, as it doesn't harm and prevents some
  incorrect error messages

+ remove custom code for Logoff - the existing handler was ok.

Some indentation fixes may be necessary



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45219 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 14:00:53 +00:00
Luigi Rizzo 5fda2a874a + comment some unclear requirements for master_eventq
+ remove the need for an snprintf in astman_get_header()
+ fix comment for manager list eventq
+ localize one variable and minor code simplifications.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45185 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 11:29:22 +00:00
Luigi Rizzo 6d10a245b6 protect access to first_action with actionlock.
Mark with XXX one place (during command execution) where
navigation should be protected with actionlock, but is not
because it would block requests for a long time.

To solve this properly we need to put reference counts in
the struct manager_action.
A suboptimal fix is to copy the record on a search and then
unlock the list while we work on the copy.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45177 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 09:33:00 +00:00
Russell Bryant 43f1054d07 Merged revisions 44945 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r44945 | russell | 2006-10-12 12:56:32 -0400 (Thu, 12 Oct 2006) | 2 lines

fix a silly typo in a comment that I saw while reading the commit list

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44946 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-12 16:57:36 +00:00
Nadi Sarrar 0752be2ec0 Merged revisions 44921 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r44921 | nadi | 2006-10-12 14:55:25 +0200 (Do, 12 Okt 2006) | 2 lines

append_event must be called while holding the session lock

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44922 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-12 13:04:03 +00:00
Luigi Rizzo 684d1f1698 basically fix indentation of a large function after previous
simplifications. On passing, use a single exit point.

(once done with the cleanup i will merge the changes into 1.4,
if applicable)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44626 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-06 21:04:43 +00:00
Luigi Rizzo 35cada23f0 s cannot be null here, so remove the useless test and error-handling block.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44617 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-06 20:34:11 +00:00
Luigi Rizzo acd1073909 simplify logic in preparation to reduce indentation
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44616 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-06 20:16:13 +00:00
Luigi Rizzo 3f641c6048 make sure sockets are blocking when they should be blocking.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44568 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-06 15:59:57 +00:00