dhcpcd-discuss

Re: Userclass option the Microsoft way

Roy Marples

Wed Feb 19 11:24:19 2020

I pushed the non msuserclass changes up, so this new patch is smaller, but only applies to the latest master branch changes.

Roy

On 18/02/2020 22:18, Roy Marples wrote:
Hi Jonas

On 17/02/2020 17:44, Jonas Ramstrand wrote:
I don't get the userclass to work towards Microsoft dhcp-server... Would it be possible to get a patch with - - msuserclass?
Using dhcpcd 8.1.2

Try the attached patch.
It will likely only apply to the dhcpcd master branch.

Roy
diff --git a/src/if-options.c b/src/if-options.c
index b3026491..a1bd6950 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,7 @@ const struct option cf_options[] = {
 	{"inform6",         optional_argument, NULL, O_INFORM6},
 	{"timeout",         required_argument, NULL, 't'},
 	{"userclass",       required_argument, NULL, 'u'},
+	{"msuserclass",     required_argument, NULL, O_MSUSERCLASS},
 	{"vendor",          required_argument, NULL, 'v'},
 	{"waitip",          optional_argument, NULL, 'w'},
 	{"exit",            no_argument,       NULL, 'x'},
@@ -894,6 +896,17 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
 			ifo->userclass[0] = (uint8_t)(ifo->userclass[0] + s +1);
 		}
 		break;
+	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;
 	case 'v':
 		ARG_REQUIRED;
 		p = strchr(arg, ',');

References:
Userclass option the Microsoft wayJonas Ramstrand
Re: Userclass option the Microsoft wayRoy Marples
Re: Userclass option the Microsoft wayJonas Ramstrand
Re: Userclass option the Microsoft wayJonas Ramstrand
Re: Userclass option the Microsoft wayRoy Marples
Archive administrator: postmaster@marples.name