Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. Re: Predefined hostname in dhcp requests (Marco Gigante)
2. [PATCH] ForcedHostname config option for DHCP requests
(Marco Gigante)
----------------------------------------------------------------------
Message: 1
Date: Fri, 17 Nov 2017 10:13:33 +0100
From: Marco Gigante <[email protected]>
To: Daniel Wagner <[email protected]>
Cc: [email protected]
Subject: Re: Predefined hostname in dhcp requests
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
On 12/11/2017 10:51, Daniel Wagner wrote:
> Hi Marco,
Hi Daniel,
sorry for the late reply.
>
> On 11/06/2017 03:46 PM, Marco Gigante wrote:
>> Hi all,
>> I'm new to connman. I'm writing here to ask for informations about
>> proposing modifications to connman.
>
> Welcome!
>
>> I made changes to connman for a project I'm working on, which required
>> to send a fixed hostname in connman dhcp requests during network
>> interface configuration (regardless of the actual system hostname).
>> My system hostname may change since its startup, so I added a
>> configuration option to put into main.conf to have a fixed hostname into
>> dhcp requests.
>
> It's a while since since I touched that code. So my knowledge is a bit
> rusty. I suspect you know the details better than me. So bear with me :)
>
> So I checked what we currently do. If I am not completely mistaken we
> extract the hostname and domain name at ConnMan startup time in the
> loopback plugin. There is no tracking if the hostname changes over time.
It looks so to me too, as far as I can understand from a more in dept
check I did by following your description.
My connman knowledge is pretty poor, I just made changes to suite the
project needs I'm working on.
>
> And then we have some code for "org.freedesktop.hostname1"
> (src/machine.c) in place. Which just extracts the machine type. This
> code is able to track hostname changes provided
> org.freedesktop.hostname1 is doing its job.
>
> I rather like to avoid adding the hostname setting into connman config
> file. It would be better to extract this from the main source.
>
> So I suggest to extend the src/machine.c code instead. Provided this
> works. Probably loopback.c should only used as fallback if
> org.freedesktop.hostname1 is not working.
Thanks for the references. Not sure I will be able to allocate some
bandwidth to add hostname tracking in the following days. Should I'll be
able to have some patches, I'll send them for sure.
>
>> Can such a modification be of any interest? I would be more than happy
>> to send a patch so you can evaluate it.
>
> Yes, of course. Having some patches (even though they might just be a
> prove of concept) are usually much better to understand and to discuss.
Going to send the patch.
My need was to set the hostname to a well known value. My system boots
with, lets say, 'host-factory' hostname and during its running time the
hostname may become 'host-id', where id is a host identifier locally
defined. Also the end-user can manually change the hostname from system
gui and restart the network, hence connman.
The problem is that the dhcp request can contain either 'host-factory'
or 'host-id' depending upon who runs first between connman dhcp client
and id negotiator component or end-user actions.
The dhcp server in my network assigns IP addresses depending upon host
type, inferred by client hostname.
>
>> I also want to ask whether I can eventually send the git formatted-patch
>> directly to this ML or I have to follow some other procedure.
>
> Yes, 'git send-email' is the preferred contribution way on this
> mailing list. Same procedures and etiquette as on LKML :)
I just realized, while up-merging my changes from connman v1.33 to
latest v1.35, that 'VendorClassID' config option has been added, and I
guess it could be used for my needs in some way.
Anyhow, patch already done :-) The code should follow LKML etiquette.
>
> Thanks,
> Daniel
Thank you
marco
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.01.org/pipermail/connman/attachments/20171117/91edf159/attachment-0001.html>
------------------------------
Message: 2
Date: Fri, 17 Nov 2017 10:14:34 +0100
From: Marco Gigante <[email protected]>
To: [email protected]
Subject: [PATCH] ForcedHostname config option for DHCP requests
Message-ID: <[email protected]>
ForcedHostname config option permits to set a fixed or empty hostname
into dhcp requests, different from the actual system hostname.
---
AUTHORS | 1 +
doc/connman.conf.5.in | 7 +++++++
src/dhcp.c | 12 ++++++++++--
src/main.c | 18 +++++++++++++++++-
src/main.conf | 6 ++++++
5 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 5e71067..d63f95b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -134,3 +134,4 @@ Guillaume Deroire <[email protected]>
Angus Gratton <[email protected]>
Gerald Loacker <[email protected]>
Mikhail Kovyazin <[email protected]>
+Marco Gigante <[email protected]>
diff --git a/doc/connman.conf.5.in b/doc/connman.conf.5.in
index 95b177f..75049af 100644
--- a/doc/connman.conf.5.in
+++ b/doc/connman.conf.5.in
@@ -98,6 +98,13 @@ Allow connman to change the system hostname. This can
happen for example if we receive DHCP hostname option.
Default value is true.
.TP
+.BI ForcedHostname= hostname\fR
+Use the specified hostname in the DHCP requests as
+host name option instead of the actual system hostname.
+This can be used to send a fixed hostname to the DHCP server.
+When not defined, the current system hostname is used.
+When set to empty, empty hostname is sent.
+.TP
.BI SingleConnectedTechnology=true\ \fR|\fB\ false
Keep only a single connected technology at any time. When a new
service is connected by the user or a better one is found according
diff --git a/src/dhcp.c b/src/dhcp.c
index 1af1eb5..4514693 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -212,7 +212,11 @@ static int ipv4ll_start_client(struct connman_dhcp *dhcp)
g_dhcp_client_set_id(ipv4ll_client);
if (dhcp->network) {
- hostname = connman_utsname_get_hostname();
+ hostname = connman_option_get_string("ForcedHostname");
+
+ if (!hostname)
+ hostname = connman_utsname_get_hostname();
+
if (hostname)
g_dhcp_client_set_send(ipv4ll_client,
G_DHCP_HOST_NAME, hostname);
@@ -597,7 +601,11 @@ static int dhcp_initialize(struct connman_dhcp *dhcp)
service = connman_service_lookup_from_network(dhcp->network);
- hostname = __connman_service_get_hostname(service);
+ hostname = connman_option_get_string("ForcedHostname");
+
+ if (!hostname)
+ hostname = __connman_service_get_hostname(service);
+
if (!hostname)
hostname = connman_utsname_get_hostname();
diff --git a/src/main.c b/src/main.c
index 7b00eb3..5d13436 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,6 +78,7 @@ static struct {
bool persistent_tethering_mode;
bool enable_6to4;
char *vendor_class_id;
+ char *forced_hostname;
bool enable_online_check;
} connman_settings = {
.bg_scan = true,
@@ -95,6 +96,7 @@ static struct {
.persistent_tethering_mode = false,
.enable_6to4 = false,
.vendor_class_id = NULL,
+ .forced_hostname = NULL,
.enable_online_check = true,
};
@@ -113,6 +115,7 @@ static struct {
#define CONF_PERSISTENT_TETHERING_MODE "PersistentTetheringMode"
#define CONF_ENABLE_6TO4 "Enable6to4"
#define CONF_VENDOR_CLASS_ID "VendorClassID"
+#define CONF_FORCED_HOSTNAME "ForcedHostname"
#define CONF_ENABLE_ONLINE_CHECK "EnableOnlineCheck"
static const char *supported_options[] = {
@@ -131,6 +134,7 @@ static const char *supported_options[] = {
CONF_PERSISTENT_TETHERING_MODE,
CONF_ENABLE_6TO4,
CONF_VENDOR_CLASS_ID,
+ CONF_FORCED_HOSTNAME,
CONF_ENABLE_ONLINE_CHECK,
NULL
};
@@ -254,7 +258,8 @@ static void parse_config(GKeyFile *config)
char **interfaces;
char **str_list;
char **tethering;
- char *vendor_class_id;
+ char *vendor_class_id;
+ char *hostname;
gsize len;
int timeout;
@@ -362,6 +367,14 @@ static void parse_config(GKeyFile *config)
g_clear_error(&error);
+ hostname = __connman_config_get_string(config, "General",
+ CONF_FORCED_HOSTNAME,
+ &error);
+ if (!error)
+ connman_settings.forced_hostname = hostname;
+
+ g_clear_error(&error);
+
boolean = __connman_config_get_bool(config, "General",
CONF_SINGLE_TECH, &error);
if (!error)
@@ -585,6 +598,9 @@ const char *connman_option_get_string(const char *key)
if (g_str_equal(key, CONF_VENDOR_CLASS_ID))
return connman_settings.vendor_class_id;
+ if (g_str_equal(key, CONF_FORCED_HOSTNAME))
+ return connman_settings.forced_hostname;
+
if (g_strcmp0(key, "wifi") == 0) {
if (!option_wifi)
return "nl80211,wext";
diff --git a/src/main.conf b/src/main.conf
index 68870b2..27c9f91 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -65,6 +65,12 @@
# Default value is true.
# AllowHostnameUpdates = true
+# Use the specified hostname instead of the actual system hostname
+# in DHCP requests.
+# When unset, use current hostname.
+# When set to empty, do not send hostname.
+# ForcedHostname = myhostname
+
# Keep only a single connected technology at any time. When a new
# service is connected by the user or a better one is found according
# to PreferredTechnologies, the new service is kept connected and all
--
2.7.4
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 25, Issue 8
**************************************