]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow an un-encapsulated vendor option.
authorRoy Marples <roy@marples.name>
Wed, 2 Sep 2009 20:16:07 +0000 (20:16 +0000)
committerRoy Marples <roy@marples.name>
Wed, 2 Sep 2009 20:16:07 +0000 (20:16 +0000)
dhcpcd.8.in
dhcpcd.conf.5.in
if-options.c
if-options.h

index d0743b0e8398d08b20e5418ecada0d29ba78c769..50a26a54ddb91b001a6489292d12754b87200c26 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd July 26, 2009
+.Dd September 1, 2009
 .Dt DHCPCD 8 SMM
 .Os
 .Sh NAME
@@ -324,14 +324,19 @@ default, without having to know things like hardware address or hostname.
 Add an enscapulated vendor option.
 .Ar code
 should be between 1 and 254 inclusive.
+To add a raw vendor string, omit
+.Ar code
+but keep the comma.
 Examples.
 .Pp
 Set the vendor option 01 with an IP address.
 .D1 dhcpcd \-v 01,192.168.0.2 eth0
 Set the vendor option 02 with a hex code.
 .D1 dhcpcd \-v 02,01:02:03:04:05 eth0
-Do the above and set a third option with a string and not an IP address.
-.D1 dhcpcd \-v 01,192.168.0.2 \-v 02,01:02:03:04:05 \-v 03,\e"192.168.0.2\e" eth0
+Set the vendor option 03 with an IP address as a string.
+.D1 dhcpcd \-v 03,\e"192.168.0.2\e" eth0
+Set un-encapulated vendor option to hello world.
+.D1 dhcpcd \-v ,\e"hello world\e" eth0
 .It Fl x , -exit
 This will signal an existing
 .Nm
index 05b299277516111a8ae1ce70dc4390762dfd64d4..904eb29f96ea7d85a29330f9b083581cbd2673a5 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd July 26, 2009
+.Dd September 1, 2009
 .Dt DHCPCD.CONF 5 SMM
 .Os
 .Sh NAME
@@ -256,6 +256,9 @@ You can specify more than one.
 Add an enscapulated vendor option.
 .Ar code
 should be between 1 and 254 inclusive.
+To add a raw vendor string, omit
+.Ar code
+but keep the comma.
 Examples.
 .Pp
 Set the vendor option 01 with an IP address.
@@ -264,6 +267,8 @@ Set the vendor option 02 with a hex code.
 .D1 vendor 02,01:02:03:04:05
 Set the vendor option 03 with an IP address as a string.
 .D1 vendor 03,\e"192.168.0.2\e"
+Set un-encapulated vendor option to hello world.
+.D1 vendor ,\e"hello world\e"
 .It Ic vendorclassid Ar string
 Change the default vendorclassid sent from dhcpcd-version.
 If not set then none is sent.
index 65e8b5db1f4bd55d14d51df51d08941d7a31494c..959fcba84cf3629c328c9275946b239ed9c59743 100644 (file)
@@ -454,6 +454,27 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                        syslog(LOG_ERR, "invalid vendor format");
                        return -1;
                }
+
+               /* If vendor starts with , then it is not encapsulated */
+               if (p == arg) {
+                       arg++;
+                       s = parse_string((char *)ifo->vendor + 1,
+                           VENDOR_MAX_LEN, arg);
+                       if (s == -1) {
+                               syslog(LOG_ERR, "vendor: %m");
+                               return -1;
+                       }
+                       ifo->vendor[0] = (uint8_t)s;
+                       ifo->options |= DHCPCD_VENDORRAW;
+                       break;
+               }
+
+               /* Encapsulated vendor options */
+               if (ifo->options & DHCPCD_VENDORRAW) {
+                       ifo->options &= ~DHCPCD_VENDORRAW;
+                       ifo->vendor[0] = 0;
+               }
+
                *p = '\0';
                i = atoint(arg);
                arg = p + 1;
@@ -814,7 +835,7 @@ read_config(const char *file,
        }
 
        /* Terminate the encapsulated options */
-       if (ifo && ifo->vendor[0]) {
+       if (ifo && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) {
                ifo->vendor[0]++;
                ifo->vendor[ifo->vendor[0]] = DHO_END;
        }
@@ -834,7 +855,7 @@ add_options(struct if_options *ifo, int argc, char **argv)
                        break;
        }
        /* Terminate the encapsulated options */
-       if (r == 1 && ifo->vendor[0]) {
+       if (r == 1 && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) {
                ifo->vendor[0]++;
                ifo->vendor[ifo->vendor[0]] = DHO_END;
        }
index 46534ea74398ff08fa125d9b5838389b44839e49..0c2818fd81a14c24c0bef88836c895b3b1a410c8 100644 (file)
@@ -69,6 +69,7 @@
 #define DHCPCD_LINK            (1 << 20)
 #define DHCPCD_QUIET           (1 << 21) 
 #define DHCPCD_BACKGROUND      (1 << 22)
+#define DHCPCD_VENDORRAW       (1 << 23)
 
 extern const struct option cf_options[];