Browse Source

add port-min and port-max parameters

integrate into init script and provide basic defaults script
git.mgm/mediaproxy-ng/2.0
Richard Fuchs 15 years ago
parent
commit
fd623f2754
5 changed files with 35 additions and 6 deletions
  1. +13
    -4
      daemon/call.c
  2. +3
    -1
      daemon/call.h
  3. +5
    -1
      daemon/main.c
  4. +12
    -0
      debian/ngcp-mediaproxy-ng-daemon.default
  5. +2
    -0
      debian/ngcp-mediaproxy-ng-daemon.init

+ 13
- 4
daemon/call.c View File

@ -449,7 +449,7 @@ next:
#undef DS
struct callmaster *callmaster_new(struct poller *p) {
struct callmaster *callmaster_new(struct poller *p, int min, int max) {
struct callmaster *c;
c = malloc(sizeof(*c));
@ -459,6 +459,8 @@ struct callmaster *callmaster_new(struct poller *p) {
if (!c->callhash)
goto fail;
c->poller = p;
c->port_min = min;
c->port_max = max;
poller_timer(p, callmaster_timer, c);
@ -504,7 +506,7 @@ static void get_port_pair(struct peer *p) {
struct call *c;
struct callmaster *m;
struct streamrelay *a, *b;
u_int16_t port;
u_int16_t port, min, max;
c = p->up->call;
m = c->callmaster;
@ -513,11 +515,18 @@ static void get_port_pair(struct peer *p) {
assert(a->fd == -1 && b->fd == -1);
min = (m->port_min > 0 && m->port_min < 0xfff0) ? m->port_min : 1024;
max = (m->port_max > 0 && m->port_max > min && m->port_max < 0xfff0) ? m->port_max : 0;
if (!m->lastport)
m->lastport = max;
port = m->lastport + 1;
for (;;) {
if (port < 1024)
port = 1024;
if (port < min)
port = min;
else if (max && port > max)
port = min;
if (port == m->lastport)
goto fail;


+ 3
- 1
daemon/call.h View File

@ -68,6 +68,8 @@ struct call {
struct callmaster {
GHashTable *callhash;
u_int16_t lastport;
int port_min;
int port_max;
struct mediaproxy_stats statsps;
struct mediaproxy_stats stats;
@ -83,7 +85,7 @@ struct callmaster {
struct callmaster *callmaster_new(struct poller *);
struct callmaster *callmaster_new(struct poller *, int, int);


+ 5
- 1
daemon/main.c View File

@ -35,6 +35,8 @@ static int tos;
static int table;
static int timeout;
static int silent_timeout;
static int port_min;
static int port_max;
@ -110,6 +112,8 @@ static void options(int *argc, char ***argv) {
{ "silent-timeout",'s',0,G_OPTION_ARG_INT, &silent_timeout,"RTP timeout for muted", "SECS" },
{ "pidfile", 'p', 0, G_OPTION_ARG_STRING, &pidfile, "Write PID to file", "FILE" },
{ "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Don't fork to background", NULL },
{ "port-min", 'm', 0, G_OPTION_ARG_INT, &port_min, "Lowest port to use for RTP", "INT" },
{ "port-max", 'M', 0, G_OPTION_ARG_INT, &port_max, "Highest port to use for RTP", "INT" },
{ NULL, }
};
@ -196,7 +200,7 @@ int main(int argc, char **argv) {
if (!p)
die("poller creation failed\n");
m = callmaster_new(p);
m = callmaster_new(p, port_min, port_max);
if (!m)
return -1;
m->kernelfd = kfd;


+ 12
- 0
debian/ngcp-mediaproxy-ng-daemon.default View File

@ -0,0 +1,12 @@
RUN_MEDIAPROXY=no
LISTEN=25060
LISTEN_UDP=12222
# ADDRESS=...
TIMEOUT=60
SILENT_TIMEOUT=3600
PIDFILE=/var/run/ngcp-mediaproxy-ng-daemon.pid
FORK=yes
# TOS=184
TABLE=0
# PORT_MIN=30000
# PORT_MAX=50000

+ 2
- 0
debian/ngcp-mediaproxy-ng-daemon.init View File

@ -50,6 +50,8 @@ OPTIONS=""
[ -z "$SILENT_TIMEOUT" ] || OPTIONS="$OPTIONS --silent-timeout=$SILENT_TIMEOUT"
[ -z "$PIDFILE" ] || OPTIONS="$OPTIONS --pidfile=$PIDFILE"
[ -z "$TOS" ] || OPTIONS="$OPTIONS --tos=$TOS"
[ -z "$PORT_MIN" ] || OPTIONS="$OPTIONS --port-min=$PORT_MIN"
[ -z "$PORT_MAX" ] || OPTIONS="$OPTIONS --port-max=$PORT_MAX"
OPTIONS="$OPTIONS --table=$TABLE"
if test "$FORK" = "no" ; then
OPTIONS="$OPTIONS --foreground"


Loading…
Cancel
Save