Browse Source

implement delete UDP command

git.mgm/mediaproxy-ng/2.0
Richard Fuchs 15 years ago
parent
commit
c3ad30063d
6 changed files with 37 additions and 11 deletions
  1. +3
    -1
      daemon/Makefile
  2. +0
    -1
      daemon/aux.c
  3. +25
    -3
      daemon/call.c
  4. +1
    -0
      daemon/call.h
  5. +7
    -5
      daemon/control_udp.c
  6. +1
    -1
      daemon/main.c

+ 3
- 1
daemon/Makefile View File

@ -1,5 +1,7 @@
CC= gcc
CFLAGS= -g -Wall `pkg-config --cflags glib-2.0` `pcre-config --cflags` -I/lib/modules/`uname -r`/build/include/ -I../kernel-module/
CFLAGS= -g -Wall `pkg-config --cflags glib-2.0` `pcre-config --cflags`
CFLAGS+= -I/lib/modules/`uname -r`/build/include/ -I../kernel-module/
CFLAGS+= -D_GNU_SOURCE
#CFLAGS+= -O2
LDFLAGS= `pkg-config --libs glib-2.0` `pcre-config --libs`


+ 0
- 1
daemon/aux.c View File

@ -1,4 +1,3 @@
#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <glib.h>


+ 25
- 3
daemon/call.c View File

@ -288,9 +288,6 @@ static int info_parse_func(char **a, void **ret, void *p) {
static GHashTable *info_parse(const char *s, GHashTable **h) {
GQueue *q;
if (!*h)
*h = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
q = pcre_multi_match(&info_re, &info_ree, "^([^:,]+)(?::(.*?))?(?:$|,)", s, 2, info_parse_func, *h);
g_queue_free(q);
@ -317,6 +314,7 @@ static int streams_parse_func(char **a, void **ret, void *p) {
return 0;
fail:
mylog(LOG_WARNING, "Failed to parse a media stream: %s:%s", a[0], a[1]);
free(st->mediatype);
free(st);
return -1;
@ -889,6 +887,7 @@ static struct call *call_get_or_create(const char *callid, struct callmaster *m)
c->callid = strdup(callid);
c->callstreams = g_queue_new();
c->created = m->poller->now;
c->infohash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
g_hash_table_insert(m->callhash, c->callid, c);
}
@ -919,6 +918,7 @@ char *call_update_udp(const char **o, struct callmaster *m) {
return streams_print(c->callstreams, 1, 0, o[1]);
fail:
mylog(LOG_WARNING, "Failed to parse a media stream: %s:%s", o[5], o[6]);
return NULL;
}
@ -951,6 +951,7 @@ char *call_lookup_udp(const char **o, struct callmaster *m) {
return streams_print(c->callstreams, 1, 1, o[1]);
fail:
mylog(LOG_WARNING, "Failed to parse a media stream: %s:%s", o[5], o[6]);
return NULL;
}
@ -990,6 +991,27 @@ char *call_lookup(const char **o, struct callmaster *m) {
return streams_print(c->callstreams, num, 1, NULL);
}
char *call_delete_udp(const char **o, struct callmaster *m) {
struct call *c;
char *ret;
c = g_hash_table_lookup(m->callhash, o[11]);
if (!c)
goto err;
call_destroy(c);
asprintf(&ret, "%s 0\n", o[1]);
goto out;
err:
asprintf(&ret, "%s E8\n", o[1]);
goto out;
out:
return ret;
}
void call_delete(const char **o, struct callmaster *m) {
struct call *c;


+ 1
- 0
daemon/call.h View File

@ -92,6 +92,7 @@ char *call_update_udp(const char **, struct callmaster *);
char *call_lookup(const char **, struct callmaster *);
char *call_lookup_udp(const char **, struct callmaster *);
void call_delete(const char **, struct callmaster *);
char *call_delete_udp(const char **, struct callmaster *);
void calls_status(struct callmaster *, struct control_stream *);


+ 7
- 5
daemon/control_udp.c View File

@ -50,15 +50,15 @@ static void control_udp_incoming(int fd, void *p) {
if (!parse_re) {
parse_re = pcre_compile(
/* cookie cmd flags callid addr port from_tag to_tag */
"^(\\S+)\\s+(?:([ul])(\\S*)\\s+(\\S+)\\s+([\\d.]+)\\s+(\\d+)\\s+(\\S+)\\s+(\\S+))",
/* cookie cmd flags callid addr port from_tag to_tag cmd flags callid */
"^(\\S+)\\s+(?:([ul])(\\S*)\\s+(\\S+)\\s+([\\d.]+)\\s+(\\d+)\\s+(\\S+?)(?:;\\S+)?(?:\\s+(\\S+?)(?:;\\S+)?)?|(d)(\\S*)\\s+(\\S+))",
PCRE_DOLLAR_ENDONLY | PCRE_DOTALL | PCRE_CASELESS, &errptr, &erroff, NULL);
parse_ree = pcre_study(parse_re, 0, &errptr);
}
ret = pcre_exec(parse_re, parse_ree, buf, ret, 0, 0, ovec, ARRAY_SIZE(ovec));
if (ret <= 0) {
mylog(LOG_WARNING, "Unable to parse command line from " DF ": %s", DP(sin), buf);
mylog(LOG_WARNING, "Unable to parse command line from udp:" DF ": %s", DP(sin), buf);
return;
}
@ -76,10 +76,12 @@ static void control_udp_incoming(int fd, void *p) {
goto out;
}
if (out[1][0] == 'u' || out[1][0] == 'U')
if (out[2][0] == 'u' || out[2][0] == 'U')
reply = call_update_udp(out, u->callmaster);
else if (out[1][0] == 'l' || out[1][0] == 'L')
else if (out[2][0] == 'l' || out[2][0] == 'L')
reply = call_lookup_udp(out, u->callmaster);
else if (out[9][0] == 'd' || out[9][0] == 'D')
reply = call_delete_udp(out, u->callmaster);
if (reply) {
sendto(fd, reply, strlen(reply), 0, (struct sockaddr *) &sin, sin_len);


+ 1
- 1
daemon/main.c View File

@ -123,7 +123,7 @@ static void options(int *argc, char ***argv) {
if (!ips)
die("Missing option IP\n");
if (!listenps || !listenudps)
if (!listenps && !listenudps)
die("Missing option LISTEN or LISTEN-UDP\n");
ip = inet_addr(ips);


Loading…
Cancel
Save