- priority: 5 --> 1
- status: open --> open-works-for-me
Here are some small modifications that may be useful for future versions. The main goal was to allow two instances running on the same machine
(running on different interfaces).
- new command line
-p <port> cli listening port (default: 23)
-l <addr> cli bind address (default: INADDR_ANY)
- configuration file
set ippool_file <filename> (default: const IPPOOLFILE)
Btw: Thanks for this great implementation... Any other implementations I've seen were awful but this works perfectly since about one year.
Below the diff against 2.1.21
diff l2tpns-2.1.21/cli.c l2tpns-2.1.21-mz/cli.c
132c132
< void init_cli(char *hostname)
---
> void init_cli(char *hostname, char *cliaddr, int cliport)
270a271,289
> addr.sin_family = AF_INET;
> addr.sin_port = htons(cliport);
>
> if (cliaddr && *cliaddr)
> {
> addr.sin_addr.s_addr = htonl(INADDR_ANY);
> }
> else
> {
> struct hostent *hp = gethostbyname2(cliaddr, AF_INET);
> if (hp == NULL || hp->h_addr_list[0] == NULL)
> {
> LOG(0, 0, 0, "Error resolving cli bind address %s: %s\n",
cliaddr, strerror(errno));
> return;
> }
> bcopy(hp->h_addr_list[0], &addr.sin_addr, hp->h_length);
> }
>
>
279,280c298
< addr.sin_family = AF_INET;
< addr.sin_port = htons(23);
---
>
283c301,302
< LOG(0, 0, 0, "Error listening on cli port 23: %s\n",
strerror(errno));
---
> LOG(0, 0, 0, "Error listening on cli address %s:%d: %s\n",
> inet_ntoa(addr.sin_addr), cliport, strerror(errno));
Common subdirectories: l2tpns-2.1.21/Docs and l2tpns-2.1.21-mz/Docs
Common subdirectories: l2tpns-2.1.21/etc and l2tpns-2.1.21-mz/etc
diff l2tpns-2.1.21/l2tpns.c l2tpns-2.1.21-mz/l2tpns.c
72a73,74
> char cliaddr[1000] = ""; // us.
> int cliport = 23; // port to bind cli, default is 23
149a152
> CONFIG("ippool_file", ippool_file, STRING),
4013c4016
< if (!(f = fopen(IPPOOLFILE, "r")))
---
> if (!(f = fopen(config->ippool_file, "r")))
4015c4018
< LOG(0, 0, 0, "Can't load pool file " IPPOOLFILE ": %s\n",
strerror(errno));
---
> LOG(0, 0, 0, "Can't load pool file %s: %s\n",
config->ippool_file, strerror(errno));
4177c4180
< while ((i = getopt(argc, argv, "dvc:h:")) >= 0)
---
> while ((i = getopt(argc, argv, "dvc:h:p:l:")) >= 0)
4196a4200,4205
> case 'l':
> snprintf(cliaddr, sizeof(cliaddr), "%s", optarg);
> break;
> case 'p':
> cliport = atoi(optarg);
> break;
4200a4210,4211
> "\t-l <address>\tCLI listen address (default:
any)\n"
> "\t-p <port>\tCLI listen port (default:
23)\n"
4216c4227
< init_cli(hostname);
---
> init_cli(hostname, cliaddr, cliport);
4381a4393,4397
> if (! *config->ippool_file)
> {
> strncpy(config->ippool_file, IPPOOLFILE,
sizeof(config->ippool_file));
> }
>
diff l2tpns-2.1.21/l2tpns.h l2tpns-2.1.21-mz/l2tpns.h
613c613,615
< // slaves is less
than this value.
---
>
> // slaves is
less than this value.
> char ippool_file[256]; // file to read ip
pool from (default is IPPOOLFILE)
794c796
< void init_cli(char *hostname);
---
> void init_cli(char *hostname, char *cliaddr, int cliport);
Common subdirectories: l2tpns-2.1.21/scripts and l2tpns-2.1.21-mz/scripts
Common subdirectories: l2tpns-2.1.21/test and l2tpns-2.1.21-mz/test