Mercurial > hg > freeDiameter
changeset 440:f38bff0bf3e9
Added dynamic port choice for app_sip
author | Alexandre Westfahl <awestfahl@freediameter.net> |
---|---|
date | Wed, 28 Jul 2010 16:17:29 +0900 |
parents | 1073e261170e |
children | 70eabd4f8a31 |
files | doc/app_sip.conf.sample extensions/app_sip/app_sip.h extensions/app_sip/app_sip.l extensions/app_sip/app_sip.y extensions/app_sip/pushprofile.c extensions/app_sip/registrationtermination.c extensions/app_sip/tools/app_sip_ppr.c extensions/app_sip/tools/app_sip_rtr.c |
diffstat | 8 files changed, 71 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/app_sip.conf.sample Wed Jul 28 16:01:53 2010 +0900 +++ b/doc/app_sip.conf.sample Wed Jul 28 16:17:29 2010 +0900 @@ -4,6 +4,11 @@ mode = DSSERVER; +# Administrator commands port (port should be provided with "-p" in remote line) +ppr_port=90; +rtr_port=91; + + #******************# #*****DATABASE*****# #******************#
--- a/extensions/app_sip/app_sip.h Wed Jul 28 16:01:53 2010 +0900 +++ b/extensions/app_sip/app_sip.h Wed Jul 28 16:17:29 2010 +0900 @@ -65,7 +65,8 @@ char * mysql_server; char mysql_prefix[10]; //default: as_ uint16_t mysql_port; //if 0, default port will be used - + uint16_t rtr_port; + uint16_t ppr_port; }; extern struct as_conf * as_conf; @@ -134,7 +135,7 @@ int app_sip_RTR_cb(struct rtrsipaor structure); int app_sip_PPR_cb(struct pprsipaor structure); -#define PORT 666 //TODO:put in conf file + int ds_entry(); void fd_ext_fini(void);
--- a/extensions/app_sip/app_sip.l Wed Jul 28 16:01:53 2010 +0900 +++ b/extensions/app_sip/app_sip.l Wed Jul 28 16:17:29 2010 +0900 @@ -120,7 +120,12 @@ (?i:"mysql_port") { return ASMYSQL_PORT; } - +(?i:"rtr_port") { + return RTR_PORT; + } +(?i:"ppr_port") { + return PPR_PORT; + } (?i:"mode") { return MODE; }
--- a/extensions/app_sip/app_sip.y Wed Jul 28 16:01:53 2010 +0900 +++ b/extensions/app_sip/app_sip.y Wed Jul 28 16:17:29 2010 +0900 @@ -123,6 +123,8 @@ %token ASMYSQL_DATABASE %token ASMYSQL_SERVER %token ASMYSQL_PORT +%token RTR_PORT +%token PPR_PORT /* Tokens and types for routing table definition */ /* A (de)quoted string (malloc'd in lex parser; it must be freed after use) */ @@ -145,6 +147,8 @@ | conffile mysql_database | conffile mysql_server | conffile mysql_port + | conffile rtr_port + | conffile ppr_port ; mode: MODE '=' INTEGER ';' @@ -192,3 +196,13 @@ as_conf->mysql_port = (uint16_t)$3; } ; +rtr_port: RTR_PORT '=' INTEGER ';' + { + as_conf->rtr_port = (uint16_t)$3; + } + ; +ppr_port: PPR_PORT '=' INTEGER ';' + { + as_conf->ppr_port = (uint16_t)$3; + } + ;
--- a/extensions/app_sip/pushprofile.c Wed Jul 28 16:01:53 2010 +0900 +++ b/extensions/app_sip/pushprofile.c Wed Jul 28 16:17:29 2010 +0900 @@ -46,15 +46,15 @@ //Procedure which always wait for data on socket void *ppr_socket(void *arg) { - /* + SOCKET sock; SOCKADDR_IN sin, csin; - struct rtrsipaor rtrsip; + struct pprsipaor pprsip; int rcvbytes=0; sock = socket(AF_INET, SOCK_STREAM, 0); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); sin.sin_family = AF_INET; - sin.sin_port = htons(PORT); + sin.sin_port = htons(as_conf->ppr_port); socklen_t sinsize = sizeof(csin); int accepted=0; @@ -71,7 +71,7 @@ accepted=accept(sock, (struct sockaddr *)&csin,&sinsize); if(accepted>-1) { - rcvbytes=recv(accepted, &rtrsip, sizeof(struct rtrsipaor),0); + rcvbytes=recv(accepted, &pprsip, sizeof(struct pprsipaor),0); if(rcvbytes>-1) { @@ -85,7 +85,7 @@ } else TRACE_DEBUG(INFO,"Can't create socket!"); -*/ + pthread_exit(NULL);
--- a/extensions/app_sip/registrationtermination.c Wed Jul 28 16:01:53 2010 +0900 +++ b/extensions/app_sip/registrationtermination.c Wed Jul 28 16:17:29 2010 +0900 @@ -53,7 +53,7 @@ sock = socket(AF_INET, SOCK_STREAM, 0); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); sin.sin_family = AF_INET; - sin.sin_port = htons(PORT); + sin.sin_port = htons(as_conf->rtr_port); socklen_t sinsize = sizeof(csin); int accepted=0; @@ -250,7 +250,7 @@ } //TODO:remove for debug - fd_msg_dump_walk(INFO,message); + //fd_msg_dump_walk(INFO,message); CHECK_FCT( fd_msg_send( &message, NULL, NULL )); return 0;
--- a/extensions/app_sip/tools/app_sip_ppr.c Wed Jul 28 16:01:53 2010 +0900 +++ b/extensions/app_sip/tools/app_sip_ppr.c Wed Jul 28 16:17:29 2010 +0900 @@ -47,7 +47,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#define PORT 667 + #include <errno.h> struct pprsipaor @@ -65,11 +65,12 @@ SOCKADDR_IN sin; struct pprsipaor pprsip; int numdatatype=0,i=0; - + int port=667; + sock = socket(AF_INET, SOCK_STREAM, 0); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); sin.sin_family = AF_INET; - sin.sin_port = htons(PORT); + //We initialize the structure pprsip.username[0]='\0'; @@ -157,6 +158,18 @@ { pprsip.accounting=1; + + } + else if(strcmp(argv[i],"-p")==0) + { + + if(sscanf(argv[i+1],"%d", &port)!=1) + { + fprintf(stderr,"Incorrect port number!\n"); + return 1; + } + + i++; } @@ -169,6 +182,8 @@ } + //We set the port number + sin.sin_port = htons(port); //We want a username @@ -179,7 +194,7 @@ } - + fprintf(stderr,"%d!\n",port); /* //DEBUG
--- a/extensions/app_sip/tools/app_sip_rtr.c Wed Jul 28 16:01:53 2010 +0900 +++ b/extensions/app_sip/tools/app_sip_rtr.c Wed Jul 28 16:17:29 2010 +0900 @@ -47,7 +47,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#define PORT 666 #include <errno.h> struct rtrsipaor @@ -67,11 +66,12 @@ SOCKADDR_IN sin; struct rtrsipaor rtrsip; int numaor=0,i=0; - + int port=666; + sock = socket(AF_INET, SOCK_STREAM, 0); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); sin.sin_family = AF_INET; - sin.sin_port = htons(PORT); + //We initialize the structure rtrsip.username[0]='\0'; @@ -214,6 +214,18 @@ //Remote SIP Server rtrsip.reason=3; } + else if(strcmp(argv[i],"-p")==0) + { + + if(sscanf(argv[i+1],"%d", &port)!=1) + { + fprintf(stderr,"Incorrect port number!\n"); + return 1; + } + + + i++; + } else { fprintf(stderr,"Unknown argument: %s\n",argv[i]); @@ -246,7 +258,8 @@ return 1; } - + //We set the port number + sin.sin_port = htons(port); /*