On Tue, Mar 06, 2012 at 06:36:15PM +0100, Enrico Scholz wrote: > For net boot setups it is useful to submit boot params like server or > bootfile over dhcp. To distinguish barebox from e.g. pxe machines, a > custom vendor id can be sent in dhcp discover/request messages. > > E.g. the ISC dhcp server can be configured with > > | if substring(option vendor-class-identifier,0,8) = "barebox:" { > | next-server 192.168.3.24; > | server-name "192.168.3.24"; > | option tftp-server-name "192.168.3.24"; > | option root-path = concat("/srv/sysroots/by-mac/", > | binary-to-ascii (16, 8, "-", substring (hardware, 1, 6))); > | } > > to sent boot params which are valid for barebox hosts only. I like this one aswell. The string shouldn't be hardcoded though. It could be a command line option to dhcp. Sascha > > Signed-off-by: Enrico Scholz <enrico.scholz@xxxxxxxxxxxxxxxxx> > --- > net/Kconfig | 13 +++++++++++++ > net/dhcp.c | 12 ++++++++++++ > 2 files changed, 25 insertions(+), 0 deletions(-) > > diff --git a/net/Kconfig b/net/Kconfig > index 3169d20..56d6ee8 100644 > --- a/net/Kconfig > +++ b/net/Kconfig > @@ -7,6 +7,19 @@ config NET_DHCP > bool > prompt "dhcp support" > > +config NET_DHCP_VENDOR_ID > + string > + prompt "dhcp vendor id" > + depends on NET_DHCP > + default "barebox:default" > + help > + DHCP Vendor ID (code 60) submitted in DHCP requests. It can > + be used in the DHCP server's configuration to select options > + (e.g. bootfile or server) which are valid for barebox clients > + only. > + > + An empty string will suppress generation of such requests. > + > config NET_NFS > bool > prompt "nfs support" > diff --git a/net/dhcp.c b/net/dhcp.c > index 2ce9090..65f2614 100644 > --- a/net/dhcp.c > +++ b/net/dhcp.c > @@ -129,6 +129,7 @@ static void bootp_copy_net_params(struct bootp *bp) > */ > static int dhcp_extended (u8 *e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP) > { > + size_t vendor_id_len = sizeof CONFIG_NET_DHCP_VENDOR_ID - 1; > u8 *start = e; > u8 *cnt; > > @@ -168,6 +169,17 @@ static int dhcp_extended (u8 *e, int message_type, IPaddr_t ServerID, IPaddr_t R > *e++ = tmp & 0xff; > } > > + /* 64 is some arbitrary value to prevent generation of too > + * large dhcp requests. */ > + BUILD_BUG_ON(sizeof CONFIG_NET_DHCP_VENDOR_ID > 64); > + > + if (vendor_id_len > 0) { > + *e++ = 60; > + *e++ = vendor_id_len; > + memcpy(e, CONFIG_NET_DHCP_VENDOR_ID, vendor_id_len); > + e += vendor_id_len; > + } > + > *e++ = 55; /* Parameter Request List */ > cnt = e++; /* Pointer to count of requested items */ > *cnt = 0; > -- > 1.7.7.6 > > > _______________________________________________ > barebox mailing list > barebox@xxxxxxxxxxxxxxxxxxx > 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@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox