[Devel] [rtpproxy] port range configurable through CLI

Daniel-Constantin Mierla daniel at voice-system.ro
Fri Oct 13 18:34:23 CEST 2006


Hello,

ok, htanks for the patch. O will try to contact rtpproxy's developer.

Cheers,
Daniel


On 10/12/06 16:33, Jeremie Le Hen wrote:
> Hi,
>
> (I first tried to contact Maxim Sobolev directly, but he didn't replied).
>
> I dare to post this here because I have not been able to locate where
> RTPProxy is currently developped.  Please, feel free to point me out
> the correct mailing-list to post this if this is not the correct place
> (note that SER website at berlios.de seems really idle though).
>
> I have made a small patch that adds a new option -P to RTPProxy,
> allowing to configure the port range use by rtpproxy from command-line.
>
> You might want to review the checks I've made in the 'P' option character
> handling.  (The patch is attached.)
>
> I've also submitted this patch to the tracker:
> http://sourceforge.net/tracker/index.php?func=detail&aid=1575919&group_id=139143&atid=743022
>
>
> Apart from this, I would like to update the usage() function to make it
> more verbose ; this would relieve a bit of the pain caused by the lack of
> documentation.
>
> I've succeded to understand most of the available options, but I must
> admit I have not been able to understand -r and -s options.  I would be
> glad if you could give me a small explanation of these two options.
>
> ISTR there is a document describing rtpproxy's options more thoroughly
> around the web, but I wasn't able to find it.  If you know a pointer to
> it, please send it to me as well.
>
>
> Thank you for your work.
> Best regards,
>   
> ------------------------------------------------------------------------
>
> Only in rtpproxy: .main.c.swp
> Only in rtpproxy: .rtp_server.c.swp
> Only in rtpproxy: .rtpp_record.c.swp
> Only in rtpproxy: Makefile
> Only in rtpproxy: config.h
> Only in rtpproxy: config.log
> Only in rtpproxy: config.status
> diff -urp rtpproxy.orig/main.c rtpproxy/main.c
> --- rtpproxy.orig/main.c	Wed Jul  5 02:14:19 2006
> +++ rtpproxy/main.c	Fri Sep 29 11:57:32 2006
> @@ -48,6 +48,7 @@
>  #include <poll.h>
>  #include <sched.h>
>  #include <stdio.h>
> +#include <stdint.h>
>  #include <stdlib.h>
>  #include <signal.h>
>  #include <string.h>
> @@ -101,6 +102,8 @@ static struct sockaddr *bindaddr[2];	/* 
>  
>  static rtpp_log_t glog;
>  static int tos = TOS;
> +static int port_min = PORT_MIN;
> +static int port_max = PORT_MAX;
>  static int lastport[2] = {PORT_MIN - 1, PORT_MIN - 1};
>  static const char *rdir = NULL;
>  static const char *sdir = NULL;
> @@ -755,7 +758,7 @@ handle_command(int controlfd)
>  
>  	if (spa->fds[i] == -1) {
>  	    j = ishostseq(bindaddr[0], spa->laddr[i]) ? 0 : 1;
> -	    if (create_listener(spa->laddr[i], PORT_MIN, PORT_MAX,
> +	    if (create_listener(spa->laddr[i], port_min, port_max,
>  	      lastport[j], &lport, fds) == -1) {
>  		rtpp_log_write(RTPP_LOG_ERR, spa->log, "can't create listener");
>  		ecode = 7;
> @@ -826,7 +829,7 @@ handle_command(int controlfd)
>  	call_id, from_tag, weak ? "weak" : "strong");
>  
>      j = ishostseq(bindaddr[0], lia[0]) ? 0 : 1;
> -    if (create_listener(bindaddr[j], PORT_MIN, PORT_MAX,
> +    if (create_listener(bindaddr[j], port_min, port_max,
>        lastport[j], &lport, fds) == -1) {
>  	rtpp_log_write(RTPP_LOG_ERR, glog, "can't create listener");
>  	ecode = 10;
> @@ -1026,7 +1029,7 @@ main(int argc, char **argv)
>  
>      dmode = 0;
>  
> -    while ((ch = getopt(argc, argv, "vf2Rl:6:s:S:t:r:p:T:L:")) != -1)
> +    while ((ch = getopt(argc, argv, "vf2Rl:6:s:S:t:r:p:P:T:L:")) != -1)
>  	switch (ch) {
>  	case 'f':
>  	    nodaemon = 1;
> @@ -1097,6 +1100,26 @@ main(int argc, char **argv)
>  
>  	case 'p':
>  	    pid_file = optarg;
> +	    break;
> +	
> +	case 'P':
> +	    errno = 0;
> +	    port_min = (int)strtoul(optarg, &cp, 10);
> +	    if (errno != 0)
> +		err(1, "%s", optarg);
> +	    if (*cp != ':' || *cp != '-')
> +		errx(1, "%s: Bad port range", optarg);
> +	    cp++;
> +	    port_max = (int)strtoul(cp, &cp, 10);
> +	    if (errno != 0)
> +		err(1, "%s", optarg);
> +	    if (*cp != '\0')
> +		errx(1, "%s: Bad port range", optarg);
> +	    if (port_max - port_min < 4)
> +		errx(1, "%s: Port range too small", optarg);
> +	    if (port_min < 1 || port_max > 65535)
> +		errx(1, "%s: Invalid ports", optarg);
> +	    lastport[0] = lastport[1] = port_min - 1;
>  	    break;
>  
>  	case 'T':
> Only in rtpproxy: main.o
> Only in rtpproxy: rtp_server.o
> Only in rtpproxy: rtpp_record.o
> Only in rtpproxy: rtpp_util.o
> Only in rtpproxy: rtpproxy
> Only in rtpproxy: stamp-h1
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
>   



More information about the Devel mailing list