All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gray Remlin <g_remlin@rocketmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Support sending DHCP client options
Date: Fri, 15 Oct 2010 15:56:07 +0100	[thread overview]
Message-ID: <4CB86B87.5040902@rocketmail.com> (raw)

 Signed-off-by: Gray Remlin <g_remlin@rocketmail.com>

---
 common/cmd_nvedit.c |    3 ++
 net/bootp.c         |   52
+++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 3d30c32..2094e8e 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -224,6 +224,9 @@ int _do_env_set (int flag, int argc, char * const
argv[])
        if (ep) {               /* variable exists */
 #ifndef CONFIG_ENV_OVERWRITE
                if ((strcmp (name, "serial#") == 0) ||
+#if defined(CONFIG_BOOTP_OPTIONS)
+                   (strcmp(name, "dhcp_vendor-class-identifier") == 0) ||
+#endif /* CONFIG_BOOTP_OPTIONS */
                    ((strcmp (name, "ethaddr") == 0)
 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
                     && (strcmp (ep->data,MK_STR(CONFIG_ETHADDR)) != 0)
diff --git a/net/bootp.c b/net/bootp.c
index 1289e3b..9e687b0 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -68,6 +68,54 @@ extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e
after add own opts. */
 extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL  */
 #endif

+#if defined(CONFIG_BOOTP_OPTIONS) /* check environment for dhcp client
options */
+
+/*
+ *     The vendor-specifiable options should not be changeable
+ *     unless CONFIG_ENV_OVERWRITE has been defined, however
+ *     user-specifiable options should be changeable regardless
+ */
+u8 dhcp_options_prep(u8 **ep)
+{
+       u8 *e = *ep;
+       char *ptr;
+
+       debug("DHCP Client options start\n");
+
+       /* vendor-specifiable identification string */
+       if ((ptr = getenv("dhcp_vendor-class-identifier"))) {
+               debug("dhcp_vendor-class-identifier=%s\n",ptr);
+               *e++ = 60;
+               *e++ = strlen(ptr);
+               while (*ptr)
+                       *e++ = *ptr++;
+       }
+
+       /* user-specifiable identification string */
+       if ((ptr = getenv("dhcp_dhcp-client-identifier"))) {
+               debug("dhcp_dhcp-client-identifier=%s\n",ptr);
+               *e++ = 61;
+               *e++ = strlen(ptr);
+               while (*ptr)
+                       *e++ = *ptr++;
+       }
+
+       /* user-specifiable identification string */
+       if ((ptr = getenv("dhcp_user-class"))) {
+               debug("dhcp_user-class=%s\n",ptr);
+               *e++ = 77;
+               *e++ = strlen(ptr);
+               while (*ptr)
+                       *e++ = *ptr++;
+       }
+
+       debug("DHCP Client options end\n");
+       *ep = e;
+       return e;
+}
+
+#endif /* CONFIG_BOOTP_OPTIONS */
+
 #endif

 static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src,
unsigned len)
@@ -412,6 +460,10 @@ static int DhcpExtended (u8 * e, int message_type,
IPaddr_t ServerID, IPaddr_t R
        }
 #endif

+#if defined(CONFIG_BOOTP_OPTIONS)
+       dhcp_options_prep (&e);
+#endif
+
 #if defined(CONFIG_BOOTP_VENDOREX)
        if ((x = dhcp_vendorex_prep (e)))
                return x - start;
--

                 reply	other threads:[~2010-10-15 14:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4CB86B87.5040902@rocketmail.com \
    --to=g_remlin@rocketmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.