From ab24a79de9d5815ec1e01ab2156ad025b44b0f03 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 22 Jan 2013 10:36:56 -0500 Subject: [PATCH] adding control_ng stubs --- daemon/Makefile | 2 +- daemon/control_ng.c | 30 ++++++++++++++++++++++++++++++ daemon/control_ng.h | 22 ++++++++++++++++++++++ daemon/main.c | 41 +++++++++++++++++++++++++++++------------ 4 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 daemon/control_ng.c create mode 100644 daemon/control_ng.h diff --git a/daemon/Makefile b/daemon/Makefile index 5c63fe2..0559a00 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -26,7 +26,7 @@ CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS` LDFLAGS+= `dpkg-buildflags --get LDFLAGS` SRCS= main.c kernel.c poller.c aux.c control.c streambuf.c call.c control_udp.c redis.c \ - bencode.c cookie_cache.c udp_listener.c + bencode.c cookie_cache.c udp_listener.c control_ng.c OBJS= $(SRCS:.c=.o) diff --git a/daemon/control_ng.c b/daemon/control_ng.c new file mode 100644 index 0000000..c3ac7db --- /dev/null +++ b/daemon/control_ng.c @@ -0,0 +1,30 @@ +#include "control_ng.h" +#include "obj.h" +#include "poller.h" +#include "bencode.h" + + +static void control_ng_incoming(int fd, void *p, uintptr_t x) { +} + +struct control_ng *control_ng_new(struct poller *p, struct in6_addr ip, u_int16_t port, struct callmaster *m) { + struct control_ng *c; + + if (!p || !m) + return NULL; + + c = obj_alloc0("control_ng", sizeof(*c), NULL); + + c->callmaster = m; + cookie_cache_init(&c->cookie_cache); + + if (udp_listener_init(&c->udp_listener, p, ip, port, control_ng_incoming, &c->obj)) + goto fail2; + + return c; + +fail2: + obj_put(c); + return NULL; + +} diff --git a/daemon/control_ng.h b/daemon/control_ng.h new file mode 100644 index 0000000..e332f64 --- /dev/null +++ b/daemon/control_ng.h @@ -0,0 +1,22 @@ +#ifndef _CONTROL_NG_H_ +#define _CONTROL_NG_H_ + +#include "obj.h" +#include "cookie_cache.h" +#include "udp_listener.h" + + +struct poller; +struct callmaster; + +struct control_ng { + struct obj obj; + struct callmaster *callmaster; + struct cookie_cache cookie_cache; + struct udp_listener udp_listener; +}; + +struct control_ng *control_ng_new(struct poller *, struct in6_addr, u_int16_t, struct callmaster *); + + +#endif diff --git a/daemon/main.c b/daemon/main.c index 0078589..d400675 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -12,6 +12,7 @@ #include "poller.h" #include "control.h" #include "control_udp.h" +#include "control_ng.h" #include "aux.h" #include "log.h" #include "call.h" @@ -67,6 +68,8 @@ static u_int32_t listenp; static u_int16_t listenport; static struct in6_addr udp_listenp; static u_int16_t udp_listenport; +static struct in6_addr ng_listenp; +static u_int16_t ng_listenport; static int tos; static int table; static int no_fallback; @@ -198,16 +201,17 @@ fail: static void options(int *argc, char ***argv) { - static char *ipv4s; - static char *adv_ipv4s; - static char *ipv6s; - static char *adv_ipv6s; - static char *listenps; - static char *listenudps; - static char *redisps; - static int version; - - static GOptionEntry e[] = { + char *ipv4s; + char *adv_ipv4s; + char *ipv6s; + char *adv_ipv6s; + char *listenps; + char *listenudps; + char *listenngs; + char *redisps; + int version; + + GOptionEntry e[] = { { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Print build time and exit", NULL }, { "table", 't', 0, G_OPTION_ARG_INT, &table, "Kernel table to use", "INT" }, { "no-fallback",'F', 0, G_OPTION_ARG_NONE, &no_fallback, "Only start when kernel module is available", NULL }, @@ -217,6 +221,7 @@ static void options(int *argc, char ***argv) { { "advertised-ip6",'A',0,G_OPTION_ARG_STRING, &adv_ipv6s, "IPv6 address to advertise", "IP6" }, { "listen-tcp", 'l', 0, G_OPTION_ARG_STRING, &listenps, "TCP port to listen on", "[IP:]PORT" }, { "listen-udp", 'u', 0, G_OPTION_ARG_STRING, &listenudps, "UDP port to listen on", "[IP46:]PORT" }, + { "listen-ng", 'n', 0, G_OPTION_ARG_STRING, &listenngs, "UDP port to listen on, NG protocol", "[IP46:]PORT" }, { "tos", 'T', 0, G_OPTION_ARG_INT, &tos, "TOS value to set on streams", "INT" }, { "timeout", 'o', 0, G_OPTION_ARG_INT, &timeout, "RTP timeout", "SECS" }, { "silent-timeout",'s',0,G_OPTION_ARG_INT, &silent_timeout,"RTP timeout for muted", "SECS" }, @@ -243,8 +248,8 @@ static void options(int *argc, char ***argv) { if (!ipv4s) die("Missing option --ip\n"); - if (!listenps && !listenudps) - die("Missing option --listen-tcp or --listen-udp\n"); + if (!listenps && !listenudps && !listenngs) + die("Missing option --listen-tcp, --listen-udp or --listen-ng\n"); ipv4 = inet_addr(ipv4s); if (ipv4 == -1) @@ -273,6 +278,10 @@ static void options(int *argc, char ***argv) { if (parse_ip6_port(&udp_listenp, &udp_listenport, listenudps)) die("Invalid IP or port (--listen-udp)\n"); } + if (listenngs) { + if (parse_ip6_port(&ng_listenp, &ng_listenport, listenngs)) + die("Invalid IP or port (--listen-ng)\n"); + } if (tos < 0 || tos > 255) die("Invalid TOS value\n"); @@ -364,6 +373,7 @@ void create_everything(struct main_context *ctx) { struct callmaster_config mc; struct control *c; struct control_udp *cu; + struct control_ng *cn; int kfd = -1; void *dlh; const char **strp; @@ -422,6 +432,13 @@ void create_everything(struct main_context *ctx) { die("Failed to open UDP control connection port\n"); } + cn = NULL; + if (ng_listenport) { + cn = control_ng_new(ctx->p, ng_listenp, ng_listenport, ctx->m); + if (!cn) + die("Failed to open UDP control connection port\n"); + } + if (redis_ip) { dlh = dlopen(MP_PLUGIN_DIR "/mediaproxy-redis.so", RTLD_NOW | RTLD_GLOBAL); if (!dlh && errno == ENOENT)