diff options
author | David Troy <dave@popvox.com> | 2006-06-19 09:16:45 +0000 |
---|---|---|
committer | David Troy <dave@popvox.com> | 2006-06-19 09:16:45 +0000 |
commit | 933875c14b2c937bcec409231e3467ecc602032b (patch) | |
tree | 8c5cc3936a1bc8e6a58c3bf64402cdcf7dd60539 /src/astmanproxy.c | |
parent | 65b1273dabf6f8129ebca43bfefb4ec07adcaddc (diff) | |
download | astmanproxy-933875c14b2c937bcec409231e3467ecc602032b.tar.gz astmanproxy-933875c14b2c937bcec409231e3467ecc602032b.tar.xz astmanproxy-933875c14b2c937bcec409231e3467ecc602032b.zip |
Resolved 1.21pre merge conflicts
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/trunk@125 f02b47b9-160a-0410-81a6-dc3441afb0ec
Diffstat (limited to 'src/astmanproxy.c')
-rw-r--r-- | src/astmanproxy.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/astmanproxy.c b/src/astmanproxy.c index 1c07c66..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) @@ -511,7 +515,7 @@ static void *accept_thread() { int as; struct sockaddr_in sin; - int sinlen; + socklen_t sinlen; struct mansession *s; struct protoent *p; int arg = 1; |