Add configurable hostname

This commit is contained in:
fred_nerk 2004-09-19 23:26:46 +00:00
parent 7f13b85569
commit b183ede15d
4 changed files with 22 additions and 18 deletions

View file

@ -1,7 +1,7 @@
* ? David Parrish <david@dparrish.com> ? * ? David Parrish <david@dparrish.com> ?
- Added support for hidden AVPs by Robert Clark - Added support for hidden AVPs by Robert Clark
- l2tpns-chap-response.patch from Robert Clark - l2tpns-chap-response.patch from Robert Clark
- l2tpns-config-hostname.patch from Robert Clark - merge l2tpns-config-hostname.patch from Robert Clark
* Thu Sep 02 2004 David Parrish <david@dparrish.com> 2.0.2 * Thu Sep 02 2004 David Parrish <david@dparrish.com> 2.0.2
- Combined LCP patches from Iain and Yuri. This should allow Windows 2k/XP - Combined LCP patches from Iain and Yuri. This should allow Windows 2k/XP

13
cli.c
View file

@ -2,7 +2,7 @@
// vim: sw=8 ts=8 // vim: sw=8 ts=8
char const *cvs_name = "$Name: $"; char const *cvs_name = "$Name: $";
char const *cvs_id_cli = "$Id: cli.c,v 1.15 2004/09/02 04:18:07 fred_nerk Exp $"; char const *cvs_id_cli = "$Id: cli.c,v 1.16 2004/09/19 23:26:46 fred_nerk Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@ -103,7 +103,7 @@ int cmd_remove_plugin(struct cli_def *cli, char *command, char **argv, int argc)
int cmd_uptime(struct cli_def *cli, char *command, char **argv, int argc); int cmd_uptime(struct cli_def *cli, char *command, char **argv, int argc);
int regular_stuff(struct cli_def *cli); int regular_stuff(struct cli_def *cli);
void init_cli(char *hostname) void init_cli()
{ {
FILE *f; FILE *f;
char buf[4096]; char buf[4096];
@ -113,10 +113,10 @@ void init_cli(char *hostname)
struct sockaddr_in addr; struct sockaddr_in addr;
cli = cli_init(); cli = cli_init();
if (hostname && *hostname) if (config->hostname && *config->hostname)
cli_set_hostname(cli, hostname); cli_set_hostname(cli, config->hostname);
else else
cli_set_hostname(cli, "l2tpns"); cli_set_hostname(cli, "l2tpns");
c = cli_register_command(cli, NULL, "show", NULL, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, NULL); c = cli_register_command(cli, NULL, "show", NULL, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, NULL);
cli_register_command(cli, c, "banana", cmd_show_banana, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Show a banana"); cli_register_command(cli, c, "banana", cmd_show_banana, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Show a banana");
@ -258,6 +258,9 @@ void cli_do(int sockfd)
} }
} }
if (config->hostname && *config->hostname)
cli_set_hostname(cli, config->hostname);
signal(SIGPIPE, SIG_DFL); signal(SIGPIPE, SIG_DFL);
signal(SIGCHLD, SIG_DFL); signal(SIGCHLD, SIG_DFL);
signal(SIGHUP, SIG_DFL); signal(SIGHUP, SIG_DFL);

View file

@ -4,7 +4,7 @@
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
// vim: sw=8 ts=8 // vim: sw=8 ts=8
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.26 2004/09/19 23:19:23 fred_nerk Exp $"; char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.27 2004/09/19 23:26:46 fred_nerk Exp $";
#include <arpa/inet.h> #include <arpa/inet.h>
#include <assert.h> #include <assert.h>
@ -57,7 +57,7 @@ int snoopfd = -1; // UDP file handle for sending out intercept data
int *radfds = NULL; // RADIUS requests file handles int *radfds = NULL; // RADIUS requests file handles
int ifrfd = -1; // File descriptor for routing, etc int ifrfd = -1; // File descriptor for routing, etc
time_t basetime = 0; // base clock time_t basetime = 0; // base clock
char hostname[1000] = ""; // us. char *hostname = NULL; // us.
int tunidx; // ifr_ifindex of tun device int tunidx; // ifr_ifindex of tun device
u32 sessionid = 0; // session id for radius accounting u32 sessionid = 0; // session id for radius accounting
int syslog_log = 0; // are we logging to syslog int syslog_log = 0; // are we logging to syslog
@ -95,6 +95,7 @@ struct config_descriptt config_values[] = {
CONFIG("debug", debug, INT), CONFIG("debug", debug, INT),
CONFIG("log_file", log_filename, STRING), CONFIG("log_file", log_filename, STRING),
CONFIG("pid_file", pid_file, STRING), CONFIG("pid_file", pid_file, STRING),
CONFIG("hostname", hostname, STRING),
CONFIG("l2tp_secret", l2tpsecret, STRING), CONFIG("l2tp_secret", l2tpsecret, STRING),
CONFIG("primary_dns", default_dns1, IP), CONFIG("primary_dns", default_dns1, IP),
CONFIG("secondary_dns", default_dns2, IP), CONFIG("secondary_dns", default_dns2, IP),
@ -2461,6 +2462,7 @@ void mainloop(void)
void initdata(void) void initdata(void)
{ {
int i; int i;
char *p;
if ((_statistics = shared_malloc(sizeof(struct Tstats))) == MAP_FAILED) if ((_statistics = shared_malloc(sizeof(struct Tstats))) == MAP_FAILED)
{ {
@ -2547,13 +2549,11 @@ void initdata(void)
for (i = 1; i < MAXTUNNEL- 1; i++) for (i = 1; i < MAXTUNNEL- 1; i++)
tunnel[i].state = TUNNELUNDEF; // mark it as not filled in. tunnel[i].state = TUNNELUNDEF; // mark it as not filled in.
if (!*hostname) // Grab my hostname unless it's been specified
{ gethostname(config->hostname, sizeof(config->hostname));
char *p; if ((p = strchr(config->hostname, '.'))) *p = 0;
// Grab my hostname unless it's been specified hostname = config->hostname;
gethostname(hostname, sizeof(hostname));
if ((p = strchr(hostname, '.'))) *p = 0;
}
_statistics->start_time = _statistics->last_reset = time(NULL); _statistics->start_time = _statistics->last_reset = time(NULL);
#ifdef BGP #ifdef BGP
@ -2957,7 +2957,7 @@ int main(int argc, char *argv[])
config->debug = optdebug; config->debug = optdebug;
init_tbf(); init_tbf();
init_cli(hostname); init_cli();
read_config_file(); read_config_file();
log(0, 0, 0, 0, "L2TPNS version " VERSION "\n"); log(0, 0, 0, 0, "L2TPNS version " VERSION "\n");

View file

@ -1,5 +1,5 @@
// L2TPNS Global Stuff // L2TPNS Global Stuff
// $Id: l2tpns.h,v 1.17 2004/09/02 04:18:07 fred_nerk Exp $ // $Id: l2tpns.h,v 1.18 2004/09/19 23:26:46 fred_nerk Exp $
#ifndef __L2TPNS_H__ #ifndef __L2TPNS_H__
#define __L2TPNS_H__ #define __L2TPNS_H__
@ -448,6 +448,7 @@ struct configt
char bgp_peer[2][64]; char bgp_peer[2][64];
u16 bgp_peer_as[2]; u16 bgp_peer_as[2];
#endif #endif
char hostname[256]; // our hostname - set to gethostname() by default
}; };
struct config_descriptt struct config_descriptt
@ -546,7 +547,7 @@ int sessionsetup(tunnelidt t, sessionidt s);
int cluster_send_session(int s); int cluster_send_session(int s);
int cluster_send_tunnel(int t); int cluster_send_tunnel(int t);
int cluster_send_goodbye(); int cluster_send_goodbye();
void init_cli(char *hostname); void init_cli();
void cli_do_file(FILE *fh); void cli_do_file(FILE *fh);
void cli_do(int sockfd); void cli_do(int sockfd);
int cli_arg_help(struct cli_def *cli, int cr_ok, char *entry, ...); int cli_arg_help(struct cli_def *cli, int cr_ok, char *entry, ...);