[U-Boot] [PATCH v3 6/8] net/bootp: add VCI support for BOOTP also

Joe Hershberger joe.hershberger at gmail.com
Wed Jul 25 01:29:46 CEST 2012


Hi Ilya,

On Tue, Jul 24, 2012 at 5:22 PM, Ilya Yanok
<ilya.yanok at cogentembedded.com> wrote:
> Vendor Class Identifier option is common to BOOTP and DHCP and
> can be useful without PXE. So send VCI in both BOOTP and DHCP
> requests if CONFIG_BOOTP_VCI_STRING is defined.
>
> Signed-off-by: Ilya Yanok <ilya.yanok at cogentembedded.com>
> ---
>
>  net/bootp.c |   20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/net/bootp.c b/net/bootp.c
> index 0f0867b..a68f914 100644
> --- a/net/bootp.c
> +++ b/net/bootp.c
> @@ -339,6 +339,14 @@ BootpTimeout(void)
>         }
>  }
>
> +#define put_vci(e, str)                                \
> +       do {                                    \
> +               *e++ = 60;                      \

Please keep the comment on the magic number.

> +               *e++ = sizeof(str);             \

Did you mean to change this from strlen() to sizeof()?  These are not
the same thing.

> +               memcpy(e, str, sizeof(str));    \
> +               e += sizeof(str);               \
> +       } while (0)
> +
>  /*
>   *     Initialize BOOTP extension fields in the request.
>   */
> @@ -435,12 +443,10 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID,
>                         printf("Invalid pxeuuid: %s\n", uuid);
>                 }
>         }
> +#endif
>
> -       *e++ = 60;      /* Vendor Class Identifier */
> -       vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING);

If you aren't using this anymore, then you should remove size_t
vci_strlen; from the top of the file.

> -       *e++ = vci_strlen;
> -       memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen);
> -       e += vci_strlen;
> +#ifdef CONFIG_BOOTP_VCI_STRING
> +       put_vci(e, CONFIG_VCI_STRING);
>  #endif
>
>  #if defined(CONFIG_BOOTP_VENDOREX)
> @@ -527,6 +533,10 @@ static int BootpExtended(u8 *e)
>         *e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff;
>  #endif
>
> +#ifdef CONFIG_BOOTP_VCI_STRING
> +       put_vci(e, CONFIG_VCI_STRING);
> +#endif
> +
>  #if defined(CONFIG_BOOTP_SUBNETMASK)
>         *e++ = 1;               /* Subnet mask request */
>         *e++ = 4;
> --
> 1.7.9.5

-Joe


More information about the U-Boot mailing list