Mercurial > hg > dhcpcd
changeset 1400:93b21640a4eb draft
Allow an un-encapsulated vendor option.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Tue, 01 Sep 2009 20:38:01 +0000 |
| parents | 1b2b2711c1a8 |
| children | 1776f76011b6 |
| files | dhcpcd.8.in dhcpcd.conf.5.in if-options.c if-options.h |
| diffstat | 4 files changed, 38 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/dhcpcd.8.in Tue Sep 01 20:37:34 2009 +0000 +++ b/dhcpcd.8.in Tue Sep 01 20:38:01 2009 +0000 @@ -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 @@ 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
--- a/dhcpcd.conf.5.in Tue Sep 01 20:37:34 2009 +0000 +++ b/dhcpcd.conf.5.in Tue Sep 01 20:38:01 2009 +0000 @@ -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 @@ 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 @@ .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.
--- a/if-options.c Tue Sep 01 20:37:34 2009 +0000 +++ b/if-options.c Tue Sep 01 20:38:01 2009 +0000 @@ -454,6 +454,27 @@ 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 @@ } /* 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 @@ 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; }
