From 9275b10557d7d5632c8f00bf5aabb0d6836465e8 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 19 Feb 2020 18:14:28 +0000 Subject: [PATCH] DHCP: Add support for the Microsoft User Class option Along with advice on how to set correctly the Vendor Class ID. Also note this is not RFC compliant. --- src/dhcpcd.conf.5.in | 13 +++++++++++-- src/if-options.c | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/dhcpcd.conf.5.in b/src/dhcpcd.conf.5.in index e7988304..71c70499 100644 --- a/src/dhcpcd.conf.5.in +++ b/src/dhcpcd.conf.5.in @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 22, 2020 +.Dd February 19, 2020 .Dt DHCPCD.CONF 5 .Os .Sh NAME @@ -690,8 +690,17 @@ If using IPv4LL then start the IPv4LL process after the timeout and then wait a little longer before really timing out. .It Ic userclass Ar string -Tag the DHCPv4 messages with the userclass. +Tag the DHCPv4 message with the userclass. You can specify more than one. +.It Ic msuserclass Ar string +Tag the DHCPv4 mesasge with the Microsoft userclass. +Unlike the +.Ic userclass +option, this one can only be added once. +It should only be used for Microsoft DHCP servers and the +.Ic vendorclassid +should be set to "MSFT 98" or "MSFT 5.0". +This option is not RFC compliant. .It Ic vendor Ar code , Ns Ar value Add an encapsulated vendor option. .Ar code diff --git a/src/if-options.c b/src/if-options.c index b3026491..2358abb5 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -106,6 +106,7 @@ #define O_LASTLEASE_EXTEND O_BASE + 46 #define O_INACTIVE O_BASE + 47 #define O_MUDURL O_BASE + 48 +#define O_MSUSERCLASS O_BASE + 49 const struct option cf_options[] = { {"background", no_argument, NULL, 'b'}, @@ -129,6 +130,9 @@ const struct option cf_options[] = { {"inform6", optional_argument, NULL, O_INFORM6}, {"timeout", required_argument, NULL, 't'}, {"userclass", required_argument, NULL, 'u'}, +#ifndef SMALL + {"msuserclass", required_argument, NULL, O_MSUSERCLASS}, +#endif {"vendor", required_argument, NULL, 'v'}, {"waitip", optional_argument, NULL, 'w'}, {"exit", no_argument, NULL, 'x'}, @@ -894,6 +898,19 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, ifo->userclass[0] = (uint8_t)(ifo->userclass[0] + s +1); } break; +#ifndef SMALL + case O_MSUSERCLASS: + /* Some Microsoft DHCP servers expect userclass to be an + * opaque blob. This is not RFC 3004 compliant. */ + s = parse_string((char *)ifo->userclass + 1, + sizeof(ifo->userclass) - 1, arg); + if (s == -1) { + logerr("msuserclass"); + return -1; + } + ifo->userclass[0] = (uint8_t)s; + break; +#endif case 'v': ARG_REQUIRED; p = strchr(arg, ','); -- 2.47.3