Mercurial > hg > waaad
changeset 101:54c7f5120aa5
Support for LocalPort configuration
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 23 Jul 2008 11:32:40 +0900 |
parents | 50665bb608fd |
children | b9085fed408e |
files | doc/waaad.conf.sample include/waaad/conf-api.h waaad/conf-gram.y waaad/conf-token.l waaad/conf.c |
diffstat | 5 files changed, 33 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/waaad.conf.sample Wed Jul 23 10:53:27 2008 +0900 +++ b/doc/waaad.conf.sample Wed Jul 23 11:32:40 2008 +0900 @@ -11,6 +11,10 @@ # Default: no default diameter-id = "test.local"; +# The port this peer is listening on for incoming connections (TCP and SCTP). +# Default: 3868 +# LocalPort = 3868; + # Where the messages are sent? # Valid values: console, syslog. # Multiple values are allowed. Separator is ','. Example: @@ -31,7 +35,7 @@ # If this variable is set to non-0 value, then the messages are not relayed and # the "0xffffff" application is not advertised in CER/CEA exchanges. # Default: 0 -# disable_relay = 0; +# DisableRelay = 0; [extensions]
--- a/include/waaad/conf-api.h Wed Jul 23 10:53:27 2008 +0900 +++ b/include/waaad/conf-api.h Wed Jul 23 11:32:40 2008 +0900 @@ -49,6 +49,8 @@ char *diameter_identity; /* The Diameter Identity of the local peer */ + uint16_t local_port; /* The port on which to listen for incoming connexions. */ + int tctimer; /* The value in seconds of the Tc timer */ int disable_relay; /* if != 0, the local host do not relay Diameter messages */
--- a/waaad/conf-gram.y Wed Jul 23 10:53:27 2008 +0900 +++ b/waaad/conf-gram.y Wed Jul 23 11:32:40 2008 +0900 @@ -169,6 +169,8 @@ %token GEN_LOG_CONSOLE %token GEN_LOG_SYSLOG %token GEN_DIAMID +%token GEN_PORT +%type <u16> gen_port_val %token GEN_TCTIMER %token GEN_DISABLERELAY @@ -236,6 +238,7 @@ general_content: /* empty is allowed */ | general_content gen_log | general_content gen_diamid + | general_content gen_port | general_content gen_tctimer | general_content gen_disablerelay ; @@ -287,6 +290,22 @@ } ; +gen_port: GEN_PORT '=' gen_port_val ';' + { + pconfig->pub.local_port = $3; + } + ; + +gen_port_val: INTEGER + { + if (( $1 <= 0) || ($1 > 65535)) { + log_error("The LocalPort value (%d) is invalid. Exiting...\n", $1); + YYERROR; + } + $$ = (uint16_t) $1 ; + } + ; + gen_tctimer: GEN_TCTIMER '=' INTEGER ';' { pconfig->pub.tctimer = $3;
--- a/waaad/conf-token.l Wed Jul 23 10:53:27 2008 +0900 +++ b/waaad/conf-token.l Wed Jul 23 11:32:40 2008 +0900 @@ -121,9 +121,11 @@ (?i:"Diameter-Id") { return GEN_DIAMID; } /* How to specify the Diameter Identity of the local peer */ +(?i:"LocalPort") { return GEN_PORT; } /* The port the local peer is listening on */ + (?i:"TcTimer") { return GEN_TCTIMER; } /* Specify the Tc timer value */ -(?i:"Disable_Relay") { return GEN_DISABLERELAY; } /* Is relaying disabled? */ +(?i:"DisableRelay") { return GEN_DISABLERELAY; } /* Is relaying disabled? */ /* The EXTENSION section tokens */ (?i:"[extensions]") { return SECTION_EXTENSION; } /* enter the Extension section */
--- a/waaad/conf.c Wed Jul 23 10:53:27 2008 +0900 +++ b/waaad/conf.c Wed Jul 23 11:32:40 2008 +0900 @@ -68,6 +68,9 @@ /* The default configuration file path (from configure) */ conf->filepath = DEFAULT_CONF_FILE; + /* The default port */ + conf->pub.local_port = 3868; + /* The default tctimer value */ conf->pub.tctimer = 30; @@ -79,6 +82,7 @@ { TRACE_DEBUG( INFO, "--- Parsed configuration : ---"); TRACE_DEBUG( INFO, " Diameter-Id : %s", g_pconf->diameter_identity); + TRACE_DEBUG( INFO, " Local port : %hd",g_pconf->local_port); TRACE_DEBUG( INFO, " Tc timer : %d", g_pconf->tctimer); TRACE_DEBUG( INFO, " Relaying : %s", g_pconf->disable_relay ? "Disabled" : "Enabled"); TRACE_DEBUG( INFO, "------------------------------");