From bb0d1da6daeede6fc1236bff37814353ef5480ee Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 14 Oct 2005 07:07:35 +0000 Subject: added capability to specify listen port for rfc3195d --- rfc3195d.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'rfc3195d.c') diff --git a/rfc3195d.c b/rfc3195d.c index f7508be5..aa5da7b5 100644 --- a/rfc3195d.c +++ b/rfc3195d.c @@ -51,6 +51,7 @@ static char* pPathLogname = "/dev/log3195"; static char *PidFile; static int NoFork = 0; static int Debug = 0; +static int listenPort = 0; /* we use a global API object below, because this listener is * not very complex. As such, this hack should not harm anything. @@ -70,7 +71,7 @@ static int usage() * currently actually do... fprintf(stderr, "usage: rfc3195d [-dv] [-i pidfile] [-n] [-p path]\n"); */ - fprintf(stderr, "usage: rfc3195d [-dv] [-p path]\n"); + fprintf(stderr, "usage: rfc3195d [-dv] [-r port] [-p path]\n"); exit(1); } @@ -187,7 +188,7 @@ int main(int argc, char* argv[]) srRetVal iRet; int ch; - while ((ch = getopt(argc, argv, "di:np:v")) != EOF) + while ((ch = getopt(argc, argv, "di:np:r:v")) != EOF) switch((char)ch) { case 'd': /* debug */ Debug = 1; @@ -201,6 +202,14 @@ int main(int argc, char* argv[]) case 'p': /* path to regular log socket */ pPathLogname = optarg; break; + case 'r': /* listen port */ + listenPort = atoi(optarg); + if(listenPort < 1 || listenPort > 65535) { + printf("Error: invalid listen port '%s', using 601 instead\n", + optarg); + listenPort = 601; + } + break; case 'v': printf("rfc3195d %s.%s (using liblogging version %d.%d.%d).\n", VERSION, PATCHLEVEL, @@ -226,10 +235,17 @@ int main(int argc, char* argv[]) exit(1); } +printf("Setting listen port %d\n", listenPort); + if((iRet = srAPISetOption(pAPI, srOPTION_BEEP_LISTENPORT, listenPort)) != SR_RET_OK) + { + printf("Error %d setting listen port - aborting\n", iRet); + exit(100); + } + if((iRet = srAPISetupListener(pAPI, OnReceive)) != SR_RET_OK) { printf("Error %d setting up listener - aborting\n", iRet); - exit(100); + exit(101); } /* now move the listener to running state. Control will only @@ -238,7 +254,7 @@ int main(int argc, char* argv[]) if((iRet = srAPIRunListener(pAPI)) != SR_RET_OK) { printf("Error %d running the listener - aborting\n", iRet); - exit(101); + exit(102); } /** control will reach this point after shutdown */ -- cgit