dect
/
asterisk
Archived
13
0
Fork 0
Commit Graph

76 Commits

Author SHA1 Message Date
rizzo dcc00a652f remove duplicated code to start the server threads, use
the infrastructure exposed in http.c earlier today.

As a bonus, now we can restart the session on a different
port just reloading the module.

On passing, fix a bug in the handling of 'enabled' in the configuration
file - previously, a missing "enabled=" line in manager.conf meant
"whatever the state was before" instead of a specific value.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48338 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-06 20:46:01 +00:00
rizzo 4b06443b14 Part of the transformations necessary to add TLS support,
as described in
http://lists.digium.com/pipermail/asterisk-dev/2006-December/025213.html

In detail, this commit does the following:

b) change the function get_input() to use fread() instead of read()
   to collect the data. One can still do the ast_wait_for_input() on
   the original descriptor returned by accept().

c) change the function send_string() to work on the FILE *.
   As a side effect, this change now really guarantees that
   we don't spend more than "writetimeout" milliseconds on
   each line sent.

d) modify the function action_command() so that it creates a
   temporary file descriptor to be passed to ast_cli_command(),
   and then read back the data from the temp file and write it
   to the output with send_string(). The code is similar to
   what is done in generic_http_callback() to support AMI-over-HTTP.




git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48332 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-06 18:45:19 +00:00
rizzo b507cb90af don't use outputstr in the struct mansession, it's just
an extra allocation on a path where we have way too many already.

Unfortunately the AMI-over-HTTP requires multiple copies,
because we need to generate a header, then the raw output to
an intermediate buffer, then convert it to html/xml, and
finally copy everything into a malloc'ed buffer because
that's what the generic_http_callback interface expects.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48090 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 17:08:19 +00:00
rizzo 41ac55742c initialize the dynamic string in a sane way.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48086 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 15:53:12 +00:00
rizzo a522c1ce0f do not return 500 Internal error if the AMI command provides
no output.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48083 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 13:08:56 +00:00
rizzo 062fee49d6 mosty comment and documentation cleanup on waitevent.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48082 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 12:05:25 +00:00
rizzo bdf4f81f22 Move the code to purge stale sessions to a function,
to simplify the body of the main loop of the accepting thread.
Rename purge_unused() to purge_events() so one knows what the
function does.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48081 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 11:20:39 +00:00
rizzo 917af9ad51 Various simplifications of the code:
+ use a wrapper around ast_carefulwrite(), used in two places,
  to make life easier when we decide to use a different interface
  to the socket.

+ put an ast_verbose() message on astman_append on a case that
  should never happen now that we use a temporary file for
  AMI-over-HTTP sessions

+ document and slightly simplify process_events() by removing
  unnecessary parentheses.

+ in get_input(), use ast_wait_for_input() instead of poll().

  We may want to move to a completely non-blocking


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48080 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 10:23:25 +00:00
rizzo 30830453fb More informative message on invalid commands.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48079 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 09:43:44 +00:00
rizzo 8cc315343f another normalization of AMI vs HTTP identification.
Should really define a macro IS_AMI(s) so it is clear what
we want to do.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48078 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 09:39:16 +00:00
rizzo e8f45989fe always use managerid to determine whether this is an AMI or HTTP session,
and document it.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48077 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-28 09:27:37 +00:00
markster 47f912f6e6 Restore some sense of security to manager
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@47912 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-22 05:49:06 +00:00
rizzo 35b5ab3bc1 comments-only change:
document a bit more when manager events are delivered
to the clients.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@47834 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-18 22:14:20 +00:00
file fd703bef54 Add support for manager hooks, so you could fire off manager events over IRC if you were crazy enough. (issue #5161 reported by anthm with mods by moi)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@47229 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-06 17:05:04 +00:00
rizzo 3094fdaa97 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: http://svn.digium.com/svn/asterisk/trunk@47132 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-03 18:53:26 +00:00
tilghman 278341b071 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: http://svn.digium.com/svn/asterisk/trunk@47052 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-02 23:16:09 +00:00
russell d67754f068 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: http://svn.digium.com/svn/asterisk/trunk@46661 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-31 15:22:28 +00:00
oej dac4a9956e Add manager sendtext action. (Issue 6131, ZX81 - thanks!)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@46630 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-31 10:42:22 +00:00
oej f171dba1a0 Issue #3930 - Add manager command for listing dialplan (coded april 2005, in bugtracker since)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@46508 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-30 21:18:39 +00:00
russell b1b9710998 fix various spelling mistakes in comments (issue #8237, jmls)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@46339 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-26 17:52:15 +00:00
rizzo 88fc4c588b fix a problem that i recently introduced when
the manager receives long commands.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@46319 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-26 12:47:23 +00:00
markster 6e270f0ae8 Fix comment preservation code (thanks murf!)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@46288 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-26 01:38:47 +00:00
rizzo 2e548a50d5 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: http://svn.digium.com/svn/asterisk/trunk@46120 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-24 17:14:12 +00:00
rizzo 5e167d54c8 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: http://svn.digium.com/svn/asterisk/trunk@45753 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-20 11:24:43 +00:00
oej bc7883b922 Doxygen corrections
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45742 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-20 08:00:13 +00:00
rizzo 9fc4cf6980 more fixes to comments and very minor code rearrangement.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45696 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-19 17:26:20 +00:00
rizzo 96167b391b implement proper XML/HTML formatting of multiple messages
(e.g. the result of waitevent).

Also fix some comments.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45690 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-19 17:07:08 +00:00
rizzo cc60583cb6 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: http://svn.digium.com/svn/asterisk/trunk@45648 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-19 07:43:43 +00:00
russell 21cbb8bb68 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: http://svn.digium.com/svn/asterisk/trunk@45623 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-19 01:00:57 +00:00
rizzo 6a1a45a520 silent warning from a debugging message (which will go away
soon, anyways)



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45611 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 22:40:02 +00:00
rizzo fb300e0612 remove trailing whitespace
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45599 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 21:41:09 +00:00
rizzo d68ba2d09f ouch! remember to unlink temporary files once done with them.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45598 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 21:36:20 +00:00
rizzo 93784d6aba + 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: http://svn.digium.com/svn/asterisk/trunk@45597 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 21:30:21 +00:00
rizzo 90c480f49d another bunch of comments on the data structures.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45583 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 17:53:47 +00:00
rizzo 713b6b817a 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: http://svn.digium.com/svn/asterisk/trunk@45582 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 17:45:50 +00:00
rizzo 78cdd30eba more comment and formatting fixes, small simplifications
to functions get_input() and session_do()



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45572 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 16:52:13 +00:00
mogorman da8aef1fc3 rizzo compile then commit, maybe even run it too ^_^
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45571 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 16:45:22 +00:00
rizzo 13dc47f57d 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: http://svn.digium.com/svn/asterisk/trunk@45561 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 15:49:40 +00:00
rizzo fdb5962fae 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: http://svn.digium.com/svn/asterisk/trunk@45551 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 14:21:15 +00:00
rizzo 59bee9954d more indentation cleanup from previous commits,
and remove the "busy" field from struct mansession
as it was not used correctly anyways.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45541 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 13:42:14 +00:00
rizzo 67fc1bcd75 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: http://svn.digium.com/svn/asterisk/trunk@45540 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 13:23:22 +00:00
rizzo 2a74685732 fix indentation from a commit of a couple of days ago
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45530 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 12:55:12 +00:00
rizzo 18827b8ac3 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: http://svn.digium.com/svn/asterisk/trunk@45529 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 12:38:24 +00:00
rizzo 3933708d51 remove unused fields and unimplemented options.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45518 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 11:59:08 +00:00
rizzo 440510b692 first pass as simplifying authenticate(), avoiding whitespace changes
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45516 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 11:54:06 +00:00
rizzo fbe8d94965 more code simplifications
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45515 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 11:43:31 +00:00
rizzo ab2bb64d8a simplify ast_strings_to_mask
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45505 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 10:14:58 +00:00
rizzo 22d613b827 add a comment to remember that a block of code is
completely redundant.



git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45495 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 08:48:50 +00:00
rizzo 155fe80952 + 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: http://svn.digium.com/svn/asterisk/trunk@45485 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 06:28:34 +00:00
rizzo 519206a7ef 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: http://svn.digium.com/svn/asterisk/trunk@45475 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-18 05:31:54 +00:00