From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/8] net: dhcp: add support of tftp server ip or Etherboot file (option 150)
Date: Fri, 30 Mar 2012 11:21:44 +0200 [thread overview]
Message-ID: <20120330092144.GY3852@pengutronix.de> (raw)
In-Reply-To: <1333081913-19168-3-git-send-email-plagnioj@jcrosoft.com>
On Fri, Mar 30, 2012 at 06:31:48AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> if tftp server ip
> Use the tftp server name only if this option is not set.
> Export it also via env tftp_server_ip.
> else
> Export it via end etherboot_file
>
> E.g. the ISC dhcp server can be configured with
>
> | option option-150 code 150 = ip-address;
> | option option-150-etherboot-file code 150 = string;
> |
> | class "at91sam9x5ek" {
> | match if substring (option vendor-class-identifier,0,20) = "barebox-at91sam9x5ek";
> |
> | filename "/tftpboot/atmel/at91sam9x5/sam9x5ek/zImage";
> | option tftp-server-name "192.168.200.98";
> | option option-150 192.168.200.98;
> | next-server 192.168.200.98;
> | option root-path "192.168.200.98:/opt/work/buildroot/build/sam9x5/target";
> | if substring (option dhcp-client-identifier,0,7) = "ser2net" {
> | filename "/tftpboot/atmel/at91sam9x5/sam9x5ek/zImage-ser2net";
> | ption option-150-etherboot-file "/tftpboot/test.sh";
> | }
> | }
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> net/dhcp.c | 21 ++++++++++++++++++++-
> 1 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git a/net/dhcp.c b/net/dhcp.c
> index 6728717..adfb4a0 100644
> --- a/net/dhcp.c
> +++ b/net/dhcp.c
> @@ -195,6 +195,8 @@ static int dhcp_extended (u8 *e, int message_type, IPaddr_t ServerID,
> *cnt += 1;
> *e++ = 66; /* TFTP server name */
> *cnt += 1;
> + *e++ = 150; /* TFTP server ip */
> + *cnt += 1;
> *e++ = 255; /* End of the list */
>
> /* Pad to minimal length */
> @@ -255,6 +257,7 @@ static void dhcp_options_process(unsigned char *popt, struct bootp *bp)
> IPaddr_t ip;
> char str[256];
> char tftpname[256];
> + bool is_tftpserverip = false;
>
> while (popt < end && *popt != 0xff) {
> oplen = *(popt + 1);
> @@ -327,6 +330,18 @@ static void dhcp_options_process(unsigned char *popt, struct bootp *bp)
> setenv("bootfile", str);
> }
> break;
> + case 150: /* TFTP server ip or Etherboot*/
> + if (oplen == sizeof(IPaddr_t)) {
> + is_tftpserverip = true;
> + ip = net_read_ip(popt + 2);
> + net_set_serverip(ip);
> + setenv_ip("tftp_server_ip", ip);
> + } else {
> + memcpy(str, popt + 2, oplen);
> + str[oplen] = 0;
> + setenv("etherboot_file", str);
> + }
This seems fragile. What if the etherboot filename has a length of 4?
Sascha
> + break;
> default:
> #ifdef CONFIG_BOOTP_VENDOREX
> if (dhcp_vendorex_proc (popt))
> @@ -338,7 +353,7 @@ static void dhcp_options_process(unsigned char *popt, struct bootp *bp)
> popt += oplen + 2; /* Process next option */
> }
>
> - if (tftpname[0] != 0)
> + if (!is_tftpserverip && tftpname[0] != 0)
> net_set_serverip(resolv(tftpname));
> }
>
> @@ -468,6 +483,8 @@ static int do_dhcp(int argc, char *argv[])
> setenv("domainname","");
> setenv("rootpath","");
> setenv("tftp_server_name","");
> + setenv("tftp_server_ip","");
> + setenv("etherboot_file","");
>
> while((opt = getopt(argc, argv, "v:")) > 0) {
> switch(opt) {
> @@ -537,3 +554,5 @@ BAREBOX_MAGICVAR(domainname, "domainname returned from DHCP request");
> BAREBOX_MAGICVAR(rootpath, "rootpath returned from DHCP request");
> BAREBOX_MAGICVAR(dhcp_vendor_id, "vendor id to send to the DHCP server");
> BAREBOX_MAGICVAR(tftp_server_name, "TFTP server Name returned from DHCP request");
> +BAREBOX_MAGICVAR(tftp_server_ip, "TFTP server IP returned from DHCP request");
> +BAREBOX_MAGICVAR(etherboot_file, "Etherboot File returned from DHCP request");
> --
> 1.7.9.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
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
next prev parent reply other threads:[~2012-03-30 9:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 4:27 [PATCH 0/8] Network update DHCP/BOOTP Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 1/8] net: dhcp: reset env variable before do a dhcp request Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 2/8] net: dhcp: add support of tftp name server Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 3/8] net: dhcp: add support of tftp server ip or Etherboot file (option 150) Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 9:21 ` Sascha Hauer [this message]
2012-03-30 10:14 ` Jean-Christophe PLAGNIOL-VILLARD
2012-04-02 10:49 ` Sascha Hauer
2012-04-02 11:18 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 4/8] net: dhcp: allow to set transmitted client id Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 5/8] net: dhcp: allow to set transmitted client uuid Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 6/8] net: dhcp: allow to set transmitted user class Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 7/8] net: dns: export resolved ip to var resolved_ip Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 9:12 ` Sascha Hauer
2012-03-30 10:16 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 8/8] defaultenv: add support of etherboot_file Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 10:39 ` [PATCH 7/8 v2] net: env: getenv_ip use resolv Jean-Christophe PLAGNIOL-VILLARD
2012-04-02 11:17 ` [PATCH 0/8] Network update DHCP/BOOTP Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120330092144.GY3852@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=plagnioj@jcrosoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox