From d4a3339ee0407cbcb5011092efa77422dfa52be7 Mon Sep 17 00:00:00 2001 From: luigi Date: Wed, 13 Mar 2002 09:23:11 +0000 Subject: Add a readonly sysctl variable of type string, kern.bootp_cookie, which is initialized with whatever string a dhcp/bootp server passes as vendor tag 134. There is no standard tag that I know with this information, and no vendor-defined tag that applies to FreeBSD that I could find doing the same thing. The intended use is to pass information to userland for run-time configuration of a diskless client without having to run a bootp/dhcp client for the third time (after the one in pxeboot/etherboot, and the one in the kernel bootp), also because these clients generally screwup the interface configuration, which is not exactly what you want when you have your disks nfs-mounted. Manpage update to follow soon. MFC-after: 3 days --- sys/nfsclient/bootp_subr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sys/nfsclient/bootp_subr.c') diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c index 27a5877..5de53ef 100644 --- a/sys/nfsclient/bootp_subr.c +++ b/sys/nfsclient/bootp_subr.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -197,6 +198,7 @@ struct bootpc_globalcontext { #define TAG_SWAPSIZE 129 #define TAG_ROOTOPTS 130 #define TAG_SWAPOPTS 131 +#define TAG_COOKIE 134 /* ascii info for userland, via sysctl */ #define TAG_DHCP_MSGTYPE 53 #define TAG_DHCP_REQ_ADDR 50 @@ -209,6 +211,10 @@ struct bootpc_globalcontext { #define DHCP_REQUEST 3 #define DHCP_ACK 5 +static char bootp_cookie[128]; +SYSCTL_STRING(_kern, OID_AUTO, bootp_cookie, CTLFLAG_RD, + bootp_cookie, 0, "Cookie (T134) supplied by bootp server"); + /* mountd RPC */ static int md_mount(struct sockaddr_in *mdsin, char *path, u_char *fhp, int *fhsizep, struct nfs_args *args, struct thread *td); @@ -1607,6 +1613,15 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, gctx->sethostname = ifctx; } } + p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, + TAG_COOKIE); + if (p != NULL) { /* store in a sysctl variable */ + int i, l = sizeof(bootp_cookie) - 1; + for (i = 0; i < l && p[i] != '\0'; i++) + bootp_cookie[i] = p[i]; + p[i] = '\0'; + } + printf("\n"); -- cgit v1.1