From d200fb748f048ae09bd41a4db8bee8dcf1b90209 Mon Sep 17 00:00:00 2001 From: Leo Moll Date: Sun, 20 Oct 2013 23:02:19 +0200 Subject: [PATCH] Made all manufacturer related information configurable: - manufacturer_name, default is "`uname -s`" - manufacturer_url, default is URL of OS verndor - model_name, default is "`uname -s` router" - model_description, default is "`uname -s` router" - model_url, default is URL of OS verndor --- miniupnpd/miniupnpd.c | 20 ++++++++++++++++++++ miniupnpd/miniupnpd.conf | 17 ++++++++++++++++- miniupnpd/options.c | 5 +++++ miniupnpd/options.h | 5 +++++ miniupnpd/testupnpdescgen.c | 6 ++++++ miniupnpd/upnpdescgen.c | 10 +++++----- miniupnpd/upnpglobalvars.c | 16 ++++++++++++++++ miniupnpd/upnpglobalvars.h | 15 +++++++++++++++ 8 files changed, 88 insertions(+), 6 deletions(-) diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index 2d770a0..bcbd970 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -782,6 +782,26 @@ init(int argc, char * * argv, struct runtime_vars * v) strncpy(friendly_name, ary_options[i].value, FRIENDLY_NAME_MAX_LEN); friendly_name[FRIENDLY_NAME_MAX_LEN-1] = '\0'; break; + case UPNPMANUFACTURER_NAME: + strncpy(manufacturer_name, ary_options[i].value, MANUFACTURER_NAME_MAX_LEN); + manufacturer_name[MANUFACTURER_NAME_MAX_LEN-1] = '\0'; + break; + case UPNPMANUFACTURER_URL: + strncpy(manufacturer_url, ary_options[i].value, MANUFACTURER_URL_MAX_LEN); + manufacturer_url[MANUFACTURER_URL_MAX_LEN-1] = '\0'; + break; + case UPNPMODEL_NAME: + strncpy(model_name, ary_options[i].value, MODEL_NAME_MAX_LEN); + model_name[MODEL_NAME_MAX_LEN-1] = '\0'; + break; + case UPNPMODEL_DESCRIPTION: + strncpy(model_description, ary_options[i].value, MODEL_DESCRIPTION_MAX_LEN); + model_description[MODEL_DESCRIPTION_MAX_LEN-1] = '\0'; + break; + case UPNPMODEL_URL: + strncpy(model_url, ary_options[i].value, MODEL_URL_MAX_LEN); + model_url[MODEL_URL_MAX_LEN-1] = '\0'; + break; #ifdef USE_NETFILTER case UPNPFORWARDCHAIN: miniupnpd_forward_chain = ary_options[i].value; diff --git a/miniupnpd/miniupnpd.conf b/miniupnpd/miniupnpd.conf index 53957af..96944cd 100644 --- a/miniupnpd/miniupnpd.conf +++ b/miniupnpd/miniupnpd.conf @@ -44,9 +44,24 @@ max_lifetime=86400 # lease file location #lease_file=/var/log/upnp.leases -# name of this service, default is "`uname -s` Router" +# name of this service, default is "`uname -s` router" #friendly_name=MiniUPnPd router +# manufacturer name, default is "`uname -s`" +#manufacturer_name=ACME Inc. + +# manufacturer url, default is URL of OS verndor +#manufacturer_url=http://www.acme.com + +# model name, default is "`uname -s` router" +#model_name=VSR-3030 + +# model description, default is "`uname -s` router" +#model_description=Very Secure Router - Model 3030 + +# model url, default is URL of OS verndor +#model_url=http://www.acme.com/products/vsr3030 + # bitrates reported by daemon in bits per second bitrate_up=1000000 bitrate_down=10000000 diff --git a/miniupnpd/options.c b/miniupnpd/options.c index 32cb800..9904a26 100644 --- a/miniupnpd/options.c +++ b/miniupnpd/options.c @@ -36,6 +36,11 @@ static const struct { { UPNPBITRATE_DOWN, "bitrate_down" }, { UPNPPRESENTATIONURL, "presentation_url" }, { UPNPFRIENDLY_NAME, "friendly_name" }, + { UPNPMANUFACTURER_NAME, "manufacturer_name" }, + { UPNPMANUFACTURER_URL, "manufacturer_url" }, + { UPNPMODEL_NAME, "model_name" }, + { UPNPMODEL_DESCRIPTION, "model_description" }, + { UPNPMODEL_URL, "model_url" }, { UPNPNOTIFY_INTERVAL, "notify_interval" }, { UPNPSYSTEM_UPTIME, "system_uptime" }, { UPNPPACKET_LOG, "packet_log" }, diff --git a/miniupnpd/options.h b/miniupnpd/options.h index 5a44e27..1a46e57 100644 --- a/miniupnpd/options.h +++ b/miniupnpd/options.h @@ -23,6 +23,11 @@ enum upnpconfigoptions { UPNPBITRATE_DOWN, /* "bitrate_down" */ UPNPPRESENTATIONURL, /* presentation_url */ UPNPFRIENDLY_NAME, /* "friendly_name" */ + UPNPMANUFACTURER_NAME, /* "manufacturer_name" */ + UPNPMANUFACTURER_URL, /* "manufacturer_url" */ + UPNPMODEL_NAME, /* "model_name" */ + UPNPMODEL_DESCRIPTION, /* "model_description" */ + UPNPMODEL_URL, /* "model_url" */ UPNPNOTIFY_INTERVAL, /* notify_interval */ UPNPSYSTEM_UPTIME, /* "system_uptime" */ UPNPPACKET_LOG, /* "packet_log" */ diff --git a/miniupnpd/testupnpdescgen.c b/miniupnpd/testupnpdescgen.c index cb5aa23..379bfa1 100644 --- a/miniupnpd/testupnpdescgen.c +++ b/miniupnpd/testupnpdescgen.c @@ -16,6 +16,7 @@ #include "macros.h" #include "config.h" #include "upnpdescgen.h" +#include "upnpdescstrings.h" char uuidvalue_igd[] = "uuid:12345678-0000-0000-0000-000000abcd01"; char uuidvalue_wan[] = "uuid:12345678-0000-0000-0000-000000abcd02"; @@ -25,6 +26,11 @@ char modelnumber[] = "1"; char presentationurl[] = "http://192.168.0.1:8080/"; /*char presentationurl[] = "";*/ char friendly_name[] = OS_NAME " router"; +char manufacturer_name[] = ROOTDEV_MANUFACTURER; +char manufacturer_url[] = ROOTDEV_MANUFACTURERURL; +char model_name[] = ROOTDEV_MODELNAME; +char model_description[] = ROOTDEV_MODELDESCRIPTION; +char model_url[] = ROOTDEV_MODELURL; char * use_ext_ip_addr = NULL; const char * ext_if_name = "eth0"; diff --git a/miniupnpd/upnpdescgen.c b/miniupnpd/upnpdescgen.c index 24e408f..9c90ded 100644 --- a/miniupnpd/upnpdescgen.c +++ b/miniupnpd/upnpdescgen.c @@ -146,13 +146,13 @@ static const struct XMLElt rootDesc[] = {"/deviceType", DEVICE_TYPE_IGD}, /* urn:schemas-upnp-org:device:InternetGatewayDevice:1 or 2 */ {"/friendlyName", friendly_name/*ROOTDEV_FRIENDLYNAME*/}, /* required */ - {"/manufacturer", ROOTDEV_MANUFACTURER}, /* required */ + {"/manufacturer", manufacturer_name/*ROOTDEV_MANUFACTURER*/}, /* required */ /* 8 */ - {"/manufacturerURL", ROOTDEV_MANUFACTURERURL}, /* optional */ - {"/modelDescription", ROOTDEV_MODELDESCRIPTION}, /* recommended */ - {"/modelName", ROOTDEV_MODELNAME}, /* required */ + {"/manufacturerURL", manufacturer_url/*ROOTDEV_MANUFACTURERURL*/}, /* optional */ + {"/modelDescription", model_description/*ROOTDEV_MODELDESCRIPTION*/}, /* recommended */ + {"/modelName", model_name/*ROOTDEV_MODELNAME*/}, /* required */ {"/modelNumber", modelnumber}, - {"/modelURL", ROOTDEV_MODELURL}, + {"/modelURL", model_url/*ROOTDEV_MODELURL*/}, {"/serialNumber", serialnumber}, {"/UDN", uuidvalue_igd}, /* required */ /* see if /UPC is needed. */ diff --git a/miniupnpd/upnpglobalvars.c b/miniupnpd/upnpglobalvars.c index bf07eae..1c0c6ce 100644 --- a/miniupnpd/upnpglobalvars.c +++ b/miniupnpd/upnpglobalvars.c @@ -10,6 +10,7 @@ #include "config.h" #include "upnpglobalvars.h" +#include "upnpdescstrings.h" /* network interface for internet */ const char * ext_if_name = 0; @@ -53,6 +54,21 @@ char presentationurl[PRESENTATIONURL_MAX_LEN]; /* friendly name for root devices in XML description */ char friendly_name[FRIENDLY_NAME_MAX_LEN] = OS_NAME " router"; +/* manufacturer name for root devices in XML description */ +char manufacturer_name[MANUFACTURER_NAME_MAX_LEN] = ROOTDEV_MANUFACTURER; + +/* manufacturer url for root devices in XML description */ +char manufacturer_url[MANUFACTURER_URL_MAX_LEN] = ROOTDEV_MANUFACTURERURL; + +/* model name for root devices in XML description */ +char model_name[MODEL_NAME_MAX_LEN] = ROOTDEV_MODELNAME; + +/* model description for root devices in XML description */ +char model_description[MODEL_DESCRIPTION_MAX_LEN] = ROOTDEV_MODELDESCRIPTION; + +/* model url for root devices in XML description */ +char model_url[MODEL_URL_MAX_LEN] = ROOTDEV_MODELURL; + /* UPnP permission rules : */ struct upnpperm * upnppermlist = 0; unsigned int num_upnpperm = 0; diff --git a/miniupnpd/upnpglobalvars.h b/miniupnpd/upnpglobalvars.h index f7d5705..789f5b9 100644 --- a/miniupnpd/upnpglobalvars.h +++ b/miniupnpd/upnpglobalvars.h @@ -74,6 +74,21 @@ extern char presentationurl[]; #define FRIENDLY_NAME_MAX_LEN (64) extern char friendly_name[]; +#define MANUFACTURER_NAME_MAX_LEN (64) +extern char manufacturer_name[]; + +#define MANUFACTURER_URL_MAX_LEN (64) +extern char manufacturer_url[]; + +#define MODEL_NAME_MAX_LEN (64) +extern char model_name[]; + +#define MODEL_DESCRIPTION_MAX_LEN (64) +extern char model_description[]; + +#define MODEL_URL_MAX_LEN (64) +extern char model_url[]; + /* UPnP permission rules : */ extern struct upnpperm * upnppermlist; extern unsigned int num_upnpperm;