summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Troy <dave@popvox.com>2006-06-18 06:44:59 +0000
committerDavid Troy <dave@popvox.com>2006-06-18 06:44:59 +0000
commit19384d35b64e626c5dbd54a066b04a9bf1b3a0d3 (patch)
tree21422fff08329615fd8d463b1ca6ba01339c0132
parentb16db019573b76082f3d08d5c07bdd288bf6530f (diff)
downloadastmanproxy-19384d35b64e626c5dbd54a066b04a9bf1b3a0d3.tar.gz
astmanproxy-19384d35b64e626c5dbd54a066b04a9bf1b3a0d3.tar.xz
astmanproxy-19384d35b64e626c5dbd54a066b04a9bf1b3a0d3.zip
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/branches/1.21pre@122 f02b47b9-160a-0410-81a6-dc3441afb0ec
-rw-r--r--src/astmanproxy.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/astmanproxy.c b/src/astmanproxy.c
index 5a865ff..bb17935 100644
--- a/src/astmanproxy.c
+++ b/src/astmanproxy.c
@@ -1,5 +1,5 @@
/* Asterisk Manager Proxy
- Copyright (c) 2005 David C. Troy <dave@popvox.com>
+ Copyright (c) 2005-2006 David C. Troy <dave@popvox.com>
This program is free software, distributed under the terms of
the GNU General Public License.
@@ -311,41 +311,44 @@ void *session_do(struct mansession *s)
void *HandleAsterisk(struct mansession *s)
{
- struct message m;
+ struct message *m;
int res,i;
char iabuf[INET_ADDRSTRLEN];
if (ConnectAsterisk(s))
goto leave;
+ if (! (m = malloc(sizeof(struct message))) )
+ goto leave;
+
for (;;) {
debugmsg("asterisk@%s: attempting read...", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
memset(&m, 0, sizeof(struct message) );
- res = s->input->read(s, &m);
- m.session = s;
+ res = s->input->read(s, m);
+ m->session = s;
if (res > 0) {
if (debug) {
- for(i=0; i<m.hdrcount; i++) {
- debugmsg("asterisk@%s got: %s", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), m.headers[i]);
+ for(i=0; i<m->hdrcount; i++) {
+ debugmsg("asterisk@%s got: %s", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), m->headers[i]);
}
}
if (!s->connected) {
- if ( !strcmp("Authentication accepted", astman_get_header(&m, "Message")) ) {
+ if ( !strcmp("Authentication accepted", astman_get_header(m, "Message")) ) {
s->connected = 1;
if (debug)
debugmsg("asterisk@%s: connected successfully!", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr) );
}
- if ( !strcmp("Authentication failed", astman_get_header(&m, "Message")) ) {
+ if ( !strcmp("Authentication failed", astman_get_header(m, "Message")) ) {
s->connected = -1;
}
}
- m.session = s;
- AddHeader(&m, "Server: %s", m.session->server->ast_host);
+ m->session = s;
+ AddHeader(m, "Server: %s", m->session->server->ast_host);
- if (!WriteClients(&m))
+ if (!WriteClients(m))
break;
} else if (res < 0) {
/* TODO: do we need to do more than this here? or something different? */
@@ -355,6 +358,7 @@ void *HandleAsterisk(struct mansession *s)
break;
}
}
+ free(m);
leave:
if (debug)