ref: c58df62d069d2a90714fc46be4a7c44ddfffba51
parent: ad6e6444f9c1bf3a2d65c67ab8f4f48ac6468104
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jan 23 15:57:20 EST 2019
ip/dhcpd: send vendor ndb attribute if available (thanks k0ga) At this moment plan9 is using vendorinfo to communicate some specific plan9 parameters, but there are some boards that use this attribute to set specific values. This patch allows netbooting of these boards using ndb attributes instead of hard coded solutions in dhcpd(1). Vendor attribute is used for that purpose because it is also used for the same purpose in bootp.
--- a/sys/src/cmd/ip/dhcpd/dhcpd.c
+++ b/sys/src/cmd/ip/dhcpd/dhcpd.c
@@ -1276,9 +1276,7 @@
break;
}
- /* add plan9 specific options */
- if(strncmp((char*)rp->vendorclass, "plan9_", 6) == 0
- || strncmp((char*)rp->vendorclass, "p9-", 3) == 0){
+ if (*rp->vendorclass != '\0') {
/* point to temporary area */
op = rp->p;
omax = rp->max;
@@ -1286,15 +1284,22 @@
rp->p = vopts;
rp->max = vopts + sizeof(vopts) - 1;
- /* emit old v4 addresses first to make sure that they fit */
- addrsopt(rp, OP9fsv4, addrs, lookupserver("fs", addrs, nelem(addrs), t));
- addrsopt(rp, OP9authv4, addrs, lookupserver("auth", addrs, nelem(addrs), t));
+ if (*rp->ii.vendor != '\0')
+ stringopt(rp, OBvendorinfo, rp->ii.vendor);
- p9addrsopt(rp, OP9fs, addrs, lookupserver("fs", addrs, nelem(addrs), t));
- p9addrsopt(rp, OP9auth, addrs, lookupserver("auth", addrs, nelem(addrs), t));
- p9addrsopt(rp, OP9ipaddr, addrs, lookupserver("ip", addrs, nelem(addrs), t));
- p9addrsopt(rp, OP9ipmask, addrs, lookupserver("ipmask", addrs, nelem(addrs), t));
- p9addrsopt(rp, OP9ipgw, addrs, lookupserver("ipgw", addrs, nelem(addrs), t));
+ /* add plan9 specific options */
+ if (strncmp((char*)rp->vendorclass, "p9-", 3) == 0
+ || strncmp((char*)rp->vendorclass, "plan9_", 6) == 0){
+ /* emit old v4 addresses first to make sure that they fit */
+ addrsopt(rp, OP9fsv4, addrs, lookupserver("fs", addrs, nelem(addrs), t));
+ addrsopt(rp, OP9authv4, addrs, lookupserver("auth", addrs, nelem(addrs), t));
+
+ p9addrsopt(rp, OP9fs, addrs, lookupserver("fs", addrs, nelem(addrs), t));
+ p9addrsopt(rp, OP9auth, addrs, lookupserver("auth", addrs, nelem(addrs), t));
+ p9addrsopt(rp, OP9ipaddr, addrs, lookupserver("ip", addrs, nelem(addrs), t));
+ p9addrsopt(rp, OP9ipmask, addrs, lookupserver("ipmask", addrs, nelem(addrs), t));
+ p9addrsopt(rp, OP9ipgw, addrs, lookupserver("ipgw", addrs, nelem(addrs), t));
+ }
/* point back to packet, encapsulate vopts into packet */
j = rp->p - vopts;