mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] extend dhcp functionality
@ 2018-08-31  9:01 Oleg.Karfich
  2018-08-31  9:01 ` [PATCH 2/3] commands: dhcp: add parameter for private data Oleg.Karfich
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Oleg.Karfich @ 2018-08-31  9:01 UTC (permalink / raw)
  To: barebox; +Cc: Oleg.Karfich

Hi,

this little patch series adds:

	1. possibility to send private data with the option 224 (dhcp request)
	   trough global variable or dhcp command

	2. add possibility back to configure retry limit trough global variable

Regards
Oleg

Oleg Karfich (3):
  net: dhcp: use private extension 224 also in discover requests
  commands: dhcp: add parameter for private data
  net: dhcp: add global variable for retries

 commands/Kconfig |  5 +++--
 commands/dhcp.c  | 10 +++++++---
 include/dhcp.h   |  1 +
 net/dhcp.c       |  9 +++++++++
 4 files changed, 20 insertions(+), 5 deletions(-)

-- 
2.7.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] net: dhcp: use private extension 224 also in discover requests
  2018-08-31  9:01 [PATCH 0/3] extend dhcp functionality Oleg.Karfich
  2018-08-31  9:01 ` [PATCH 2/3] commands: dhcp: add parameter for private data Oleg.Karfich
@ 2018-08-31  9:01 ` Oleg.Karfich
  2018-08-31  9:01 ` [PATCH 3/3] net: dhcp: add global variable for retries Oleg.Karfich
  2 siblings, 0 replies; 6+ messages in thread
From: Oleg.Karfich @ 2018-08-31  9:01 UTC (permalink / raw)
  To: barebox; +Cc: Oleg.Karfich

Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
---
 include/dhcp.h | 1 +
 net/dhcp.c     | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/include/dhcp.h b/include/dhcp.h
index 0977ff4..ce5ed61 100644
--- a/include/dhcp.h
+++ b/include/dhcp.h
@@ -18,6 +18,7 @@ struct dhcp_req_param {
 	char *client_id;
 	char *user_class;
 	char *client_uuid;
+	char *option224;
 	int retries;
 };
 
diff --git a/net/dhcp.c b/net/dhcp.c
index d30551d..6394397 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -98,6 +98,7 @@ struct dhcp_receivce_opts {
 #define DHCP_CLIENT_ID		61
 #define DHCP_USER_CLASS		77
 #define DHCP_CLIENT_UUID	97
+#define DHCP_OPTION224		224
 
 static int dhcp_set_ip_options(int option, u8 *e, IPaddr_t ip)
 {
@@ -212,6 +213,7 @@ static int dhcp_extended(u8 *e, int message_type, IPaddr_t ServerID,
 	e += dhcp_set_string_options(DHCP_CLIENT_ID, dhcp_param.client_id, e);
 	e += dhcp_set_string_options(DHCP_USER_CLASS, dhcp_param.user_class, e);
 	e += dhcp_set_string_options(DHCP_CLIENT_UUID, dhcp_param.client_uuid, e);
+	e += dhcp_set_string_options(DHCP_OPTION224, dhcp_param.option224, e);
 
 	*e++ = 55;		/* Parameter Request List */
 	cnt = e++;		/* Pointer to count of requested items */
@@ -446,6 +448,7 @@ static char *global_dhcp_bootfile;
 static char *global_dhcp_oftree_file;
 static char *global_dhcp_rootpath;
 static char *global_dhcp_tftp_server_name;
+static char *global_dhcp_option224;
 
 static void set_res(char **var, const char *res)
 {
@@ -478,6 +481,8 @@ int dhcp_request(struct eth_device *edev, const struct dhcp_req_param *param,
 		dhcp_param.client_uuid = global_dhcp_client_uuid;
 	if (!dhcp_param.client_id)
 		dhcp_param.client_id = global_dhcp_client_id;
+	if (!dhcp_param.option224)
+		dhcp_param.option224 = global_dhcp_option224;
 	if (!dhcp_param.retries)
 		dhcp_param.retries = DHCP_DEFAULT_RETRY;
 
@@ -624,6 +629,7 @@ static int dhcp_global_init(void)
 	globalvar_add_simple_string("dhcp.user_class", &global_dhcp_user_class);
 	globalvar_add_simple_string("dhcp.oftree_file", &global_dhcp_oftree_file);
 	globalvar_add_simple_string("dhcp.tftp_server_name", &global_dhcp_tftp_server_name);
+	globalvar_add_simple_string("dhcp.option224", &global_dhcp_option224);
 
 	return 0;
 }
@@ -639,3 +645,4 @@ BAREBOX_MAGICVAR_NAMED(global_dhcp_user_class, global.dhcp.user_class, "user cla
 BAREBOX_MAGICVAR_NAMED(global_dhcp_tftp_server_name, global.dhcp.tftp_server_name, "TFTP server Name returned from DHCP request");
 BAREBOX_MAGICVAR_NAMED(global_dhcp_oftree_file, global.dhcp.oftree_file, "OF tree returned from DHCP request (option 224)");
 BAREBOX_MAGICVAR_NAMED(global_dhcp_retries, global.dhcp.retries, "retry limit");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_option224, global.dhcp.option224, "private data to send to the DHCP server (option 224)");
-- 
2.7.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] commands: dhcp: add parameter for private data
  2018-08-31  9:01 [PATCH 0/3] extend dhcp functionality Oleg.Karfich
@ 2018-08-31  9:01 ` Oleg.Karfich
  2018-08-31  9:01 ` [PATCH 1/3] net: dhcp: use private extension 224 also in discover requests Oleg.Karfich
  2018-08-31  9:01 ` [PATCH 3/3] net: dhcp: add global variable for retries Oleg.Karfich
  2 siblings, 0 replies; 6+ messages in thread
From: Oleg.Karfich @ 2018-08-31  9:01 UTC (permalink / raw)
  To: barebox; +Cc: Oleg.Karfich

Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
---
 commands/Kconfig |  5 +++--
 commands/dhcp.c  | 10 +++++++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 951a869..675bd1c 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1127,7 +1127,7 @@ config CMD_DHCP
 	help
 	  DHCP client to obtain IP or boot params
 
-	  Usage: dhcp [-HvcuUr]
+	  Usage: dhcp [-HvcuUro]
 
 	  Options:
 	          -H HOSTNAME     hostname to send to the DHCP server
@@ -1135,7 +1135,8 @@ config CMD_DHCP
 	          -c ID           DHCP Client ID (code 61) submitted in DHCP requests
 	          -u UUID         DHCP Client UUID (code 97) submitted in DHCP requests
 	          -U CLASS        DHCP User class (code 77) submitted in DHCP requests
-	          -r RETRY        retry limit (default 20)#
+	          -r RETRY        retry limit (default 20)
+		  -o PRIVATE DATA private data (code 224) submitted in DHCP requests
 
 config CMD_HOST
 	tristate
diff --git a/commands/dhcp.c b/commands/dhcp.c
index 1f07b2f..d9e844b 100644
--- a/commands/dhcp.c
+++ b/commands/dhcp.c
@@ -24,7 +24,7 @@ static int do_dhcp(int argc, char *argv[])
 	struct eth_device *edev;
 	const char *edevname;
 
-	while ((opt = getopt(argc, argv, "H:v:c:u:U:r:")) > 0) {
+	while ((opt = getopt(argc, argv, "H:v:c:u:U:r:o:")) > 0) {
 		switch (opt) {
 		case 'H':
 			dhcp_param.hostname = optarg;
@@ -44,6 +44,9 @@ static int do_dhcp(int argc, char *argv[])
 		case 'r':
 			dhcp_param.retries = simple_strtoul(optarg, NULL, 10);
 			break;
+		case 'o':
+			dhcp_param.option224 = optarg;
+			break;
 		default:
 			return COMMAND_ERROR_USAGE;
 		}
@@ -72,13 +75,14 @@ BAREBOX_CMD_HELP_OPT("-v ID\t", "DHCP Vendor ID (code 60) submitted in DHCP requ
 BAREBOX_CMD_HELP_OPT("-c ID\t", "DHCP Client ID (code 61) submitted in DHCP requests")
 BAREBOX_CMD_HELP_OPT("-u UUID\t", "DHCP Client UUID (code 97) submitted in DHCP requests")
 BAREBOX_CMD_HELP_OPT("-U CLASS", "DHCP User class (code 77) submitted in DHCP requests")
-BAREBOX_CMD_HELP_OPT("-r RETRY", "retry limit (default 20)");
+BAREBOX_CMD_HELP_OPT("-r RETRY", "retry limit (default 20)")
+BAREBOX_CMD_HELP_OPT("-o PRIVATE DATA", "private data (code 224) submitted in DHCP requests");
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(dhcp)
 	.cmd		= do_dhcp,
 	BAREBOX_CMD_DESC("DHCP client to obtain IP or boot params")
-	BAREBOX_CMD_OPTS("[-HvcuUr] [device]")
+	BAREBOX_CMD_OPTS("[-HvcuUro] [device]")
 	BAREBOX_CMD_GROUP(CMD_GRP_NET)
 	BAREBOX_CMD_HELP(cmd_dhcp_help)
 	BAREBOX_CMD_COMPLETE(eth_complete)
-- 
2.7.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] net: dhcp: add global variable for retries
  2018-08-31  9:01 [PATCH 0/3] extend dhcp functionality Oleg.Karfich
  2018-08-31  9:01 ` [PATCH 2/3] commands: dhcp: add parameter for private data Oleg.Karfich
  2018-08-31  9:01 ` [PATCH 1/3] net: dhcp: use private extension 224 also in discover requests Oleg.Karfich
@ 2018-08-31  9:01 ` Oleg.Karfich
  2018-09-04  6:12   ` Sascha Hauer
  2 siblings, 1 reply; 6+ messages in thread
From: Oleg.Karfich @ 2018-08-31  9:01 UTC (permalink / raw)
  To: barebox; +Cc: Oleg.Karfich

Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
---
 net/dhcp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/dhcp.c b/net/dhcp.c
index 6394397..92e0501 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -448,6 +448,7 @@ static char *global_dhcp_bootfile;
 static char *global_dhcp_oftree_file;
 static char *global_dhcp_rootpath;
 static char *global_dhcp_tftp_server_name;
+static char *global_dhcp_retries;
 static char *global_dhcp_option224;
 
 static void set_res(char **var, const char *res)
@@ -629,6 +630,7 @@ static int dhcp_global_init(void)
 	globalvar_add_simple_string("dhcp.user_class", &global_dhcp_user_class);
 	globalvar_add_simple_string("dhcp.oftree_file", &global_dhcp_oftree_file);
 	globalvar_add_simple_string("dhcp.tftp_server_name", &global_dhcp_tftp_server_name);
+	globalvar_add_simple_string("dhcp.retries", &global_dhcp_retries);
 	globalvar_add_simple_string("dhcp.option224", &global_dhcp_option224);
 
 	return 0;
-- 
2.7.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] net: dhcp: add global variable for retries
  2018-08-31  9:01 ` [PATCH 3/3] net: dhcp: add global variable for retries Oleg.Karfich
@ 2018-09-04  6:12   ` Sascha Hauer
  2018-09-04  7:02     ` Oleg.Karfich
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2018-09-04  6:12 UTC (permalink / raw)
  To: Oleg.Karfich; +Cc: barebox

Hi Oleg,

On Fri, Aug 31, 2018 at 09:01:32AM +0000, Oleg.Karfich@wago.com wrote:
> Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
> ---
>  net/dhcp.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/dhcp.c b/net/dhcp.c
> index 6394397..92e0501 100644
> --- a/net/dhcp.c
> +++ b/net/dhcp.c
> @@ -448,6 +448,7 @@ static char *global_dhcp_bootfile;
>  static char *global_dhcp_oftree_file;
>  static char *global_dhcp_rootpath;
>  static char *global_dhcp_tftp_server_name;
> +static char *global_dhcp_retries;
>  static char *global_dhcp_option224;
>  
>  static void set_res(char **var, const char *res)
> @@ -629,6 +630,7 @@ static int dhcp_global_init(void)
>  	globalvar_add_simple_string("dhcp.user_class", &global_dhcp_user_class);
>  	globalvar_add_simple_string("dhcp.oftree_file", &global_dhcp_oftree_file);
>  	globalvar_add_simple_string("dhcp.tftp_server_name", &global_dhcp_tftp_server_name);
> +	globalvar_add_simple_string("dhcp.retries", &global_dhcp_retries);

This adds a global variable, but it is not used, so this still has no
effect. Turn this into globalvar_add_simple_int(). The int * you pass
should then be used instead of DHCP_DEFAULT_RETRY to initialize
dhcp_param.retries in dhcp_request().

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] net: dhcp: add global variable for retries
  2018-09-04  6:12   ` Sascha Hauer
@ 2018-09-04  7:02     ` Oleg.Karfich
  0 siblings, 0 replies; 6+ messages in thread
From: Oleg.Karfich @ 2018-09-04  7:02 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

On 04.09.2018 08:12, Sascha Hauer wrote:
> Hi Oleg,

Hi Sascha,

> 
> On Fri, Aug 31, 2018 at 09:01:32AM +0000, Oleg.Karfich@wago.com wrote:
>> Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
>> ---
>>  net/dhcp.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/net/dhcp.c b/net/dhcp.c
>> index 6394397..92e0501 100644
>> --- a/net/dhcp.c
>> +++ b/net/dhcp.c
>> @@ -448,6 +448,7 @@ static char *global_dhcp_bootfile;
>>  static char *global_dhcp_oftree_file;
>>  static char *global_dhcp_rootpath;
>>  static char *global_dhcp_tftp_server_name;
>> +static char *global_dhcp_retries;
>>  static char *global_dhcp_option224;
>>  
>>  static void set_res(char **var, const char *res)
>> @@ -629,6 +630,7 @@ static int dhcp_global_init(void)
>>  	globalvar_add_simple_string("dhcp.user_class", &global_dhcp_user_class);
>>  	globalvar_add_simple_string("dhcp.oftree_file", &global_dhcp_oftree_file);
>>  	globalvar_add_simple_string("dhcp.tftp_server_name", &global_dhcp_tftp_server_name);
>> +	globalvar_add_simple_string("dhcp.retries", &global_dhcp_retries);
> 
> This adds a global variable, but it is not used, so this still has no
> effect. Turn this into globalvar_add_simple_int(). The int * you pass
> should then be used instead of DHCP_DEFAULT_RETRY to initialize
> dhcp_param.retries in dhcp_request().


Oh...there went something totaly wrong. Sorry for that...V2 is coming

> 
> Sascha
> 

Regard
Oleg
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-04  7:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31  9:01 [PATCH 0/3] extend dhcp functionality Oleg.Karfich
2018-08-31  9:01 ` [PATCH 2/3] commands: dhcp: add parameter for private data Oleg.Karfich
2018-08-31  9:01 ` [PATCH 1/3] net: dhcp: use private extension 224 also in discover requests Oleg.Karfich
2018-08-31  9:01 ` [PATCH 3/3] net: dhcp: add global variable for retries Oleg.Karfich
2018-09-04  6:12   ` Sascha Hauer
2018-09-04  7:02     ` Oleg.Karfich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox