]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Add support for the Microsoft User Class option
authorRoy Marples <roy@marples.name>
Wed, 19 Feb 2020 18:14:28 +0000 (18:14 +0000)
committerRoy Marples <roy@marples.name>
Wed, 19 Feb 2020 18:14:28 +0000 (18:14 +0000)
Along with advice on how to set correctly the Vendor Class ID.
Also note this is not RFC compliant.

src/dhcpcd.conf.5.in
src/if-options.c

index e7988304676874d16a167cee10004d003992374b..71c704994727c53aacd2376abcf4e301cc9405dd 100644 (file)
@@ -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
index b30264912af1c608fdf0c149e8db6063cb50ac63..2358abb5d70639fd12a7690f5539cd65641c36d9 100644 (file)
 #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, ',');