mirror of
https://github.com/openNDS/openNDS.git
synced 2026-01-10 20:37:54 -05:00
Add - option to append serial number suffix to gatewayname
Generates serial number based on router mac address Signed-off-by: Rob White <rob@blue-wave.net>
This commit is contained in:
@@ -101,7 +101,7 @@ generate_uci_config() {
|
||||
ratecheckwindow downloadrate uploadrate download_bucket_ratio upload_bucket_ratio downloadquota uploadquota \
|
||||
max_download_bucket_size max_upload_bucket_size upload_unrestricted_bursting download_unrestricted_bursting \
|
||||
syslogfacility ndsctlsocket \
|
||||
dhcp_default_url_enable \
|
||||
dhcp_default_url_enable enable_serial_number_suffix \
|
||||
fw_mark_authenticated fw_mark_blocked fw_mark_trusted
|
||||
do
|
||||
|
||||
|
||||
10
src/conf.c
10
src/conf.c
@@ -71,6 +71,7 @@ typedef enum {
|
||||
oMaxClients,
|
||||
oOnlineStatus,
|
||||
oGatewayName,
|
||||
oEnableSerialNumberSuffix,
|
||||
oGatewayInterface,
|
||||
oGatewayIPRange,
|
||||
oGatewayIP,
|
||||
@@ -150,6 +151,7 @@ static const struct {
|
||||
{ "maxclients", oMaxClients },
|
||||
{ "online_status", oOnlineStatus },
|
||||
{ "gatewayname", oGatewayName },
|
||||
{ "enable_serial_number_suffix", oEnableSerialNumberSuffix },
|
||||
{ "gatewayinterface", oGatewayInterface },
|
||||
{ "gatewayiprange", oGatewayIPRange },
|
||||
{ "gatewayip", oGatewayIP },
|
||||
@@ -251,6 +253,7 @@ config_init(void)
|
||||
config.maxclients = DEFAULT_MAXCLIENTS;
|
||||
config.online_status = DEFAULT_ONLINE_STATUS;
|
||||
config.gw_name = safe_strdup(DEFAULT_GATEWAYNAME);
|
||||
config.enable_serial_number_suffix = DEFAULT_ENABLE_SERIAL_NUMBER_SUFFIX;
|
||||
config.http_encoded_gw_name = NULL;
|
||||
config.url_encoded_gw_name = NULL;
|
||||
config.gw_fqdn = safe_strdup(DEFAULT_GATEWAYFQDN);
|
||||
@@ -850,6 +853,13 @@ config_read(const char *filename)
|
||||
case oGatewayName:
|
||||
config.gw_name = safe_strdup(p1);
|
||||
break;
|
||||
case oEnableSerialNumberSuffix:
|
||||
if (sscanf(p1, "%d", &config.enable_serial_number_suffix) < 1) {
|
||||
debug(LOG_ERR, "Bad arg %s to option %s on line %d in %s", p1, s, linenum, filename);
|
||||
debug(LOG_ERR, "Exiting...");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case oGatewayFQDN:
|
||||
config.gw_fqdn = safe_strdup(p1);
|
||||
break;
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#define DEFAULT_GATEWAYINTERFACE "br-lan"
|
||||
#define DEFAULT_GATEWAY_IPRANGE "0.0.0.0/0"
|
||||
#define DEFAULT_GATEWAYNAME "openNDS"
|
||||
#define DEFAULT_ENABLE_SERIAL_NUMBER_SUFFIX 1
|
||||
#define DEFAULT_GATEWAYPORT 2050
|
||||
#define DEFAULT_GATEWAYFQDN "status.client"
|
||||
#define DEFAULT_DHCP_DEFAULT_URL_ENABLE 1
|
||||
@@ -192,6 +193,7 @@ typedef struct {
|
||||
int maxclients; //@brief Maximum number of clients allowed
|
||||
int online_status; //@brief Online status of the router, 1=online, 0=offline
|
||||
char *gw_name; //@brief Name of the gateway; e.g. its SSID or a unique identifier for use in a remote FAS
|
||||
int enable_serial_number_suffix; //@brief Enable/disable serial number suffix to gateway name
|
||||
char *http_encoded_gw_name; //@brief http encoded name of the gateway, used as a templated variable in splash.htm
|
||||
char *url_encoded_gw_name; //@brief url encoded name of the gateway used as variable in Preauth
|
||||
char *gw_interface; //@brief Interface we will manage
|
||||
|
||||
20
src/main.c
20
src/main.c
@@ -578,6 +578,26 @@ setup_from_config(void)
|
||||
free(dnscmd);
|
||||
|
||||
// Encode gatewayname
|
||||
char idbuf[STATUS_BUF] = {0};
|
||||
char cmd[256] = {0};
|
||||
char gatewayid[256] = {0};
|
||||
|
||||
if (config->enable_serial_number_suffix == 1) {
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "/usr/lib/opennds/libopennds.sh gatewayid \"%s\"",
|
||||
config->gw_interface
|
||||
);
|
||||
|
||||
if (execute_ret(idbuf, sizeof(idbuf), cmd) == 0) {
|
||||
snprintf(gatewayid, sizeof(gatewayid), "%s S/N:%s ",
|
||||
config->gw_name,
|
||||
idbuf
|
||||
);
|
||||
debug(LOG_NOTICE, "Adding Serial Number suffix [%s] to gatewayname", idbuf);
|
||||
config->gw_name = safe_strdup(gatewayid);
|
||||
}
|
||||
}
|
||||
|
||||
htmlentityencode(gw_name_entityencoded, sizeof(gw_name_entityencoded), config->gw_name, strlen(config->gw_name));
|
||||
config->http_encoded_gw_name = safe_strdup(gw_name_entityencoded);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user