| Summary: | Specifying a binary option in udhcpc is not possible | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Nikos Mavrogianopoulos <nmav> |
| Component: | Networking | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | 1.15.x | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: | DHCP binary options patch | ||
|
Description
Nikos Mavrogianopoulos
2009-11-23 12:17:36 UTC
Forgot to attach the patch? Created attachment 773 [details]
DHCP binary options patch
I don't know what happened. Those patches were there last time I checked. Anyway reattaching.
Simply special-casing "Ox" is not a clean implementation - now hostname "0xcart" is suddenly invalid (!).
Moreover, it acts only on -h, -c and -V.
I added support for adding any DHCP options, not just selected few (like -h,-c,-V,-F we had before) but any one using -x optname:optval syntax.
This code reuses the same machinery which is employed by dhcp server to parse options from config file.
Because of this, best way to add binary option is to add a bit of code in networking/udhcp/common.c, udhcp_str2optset() function. Currently, its start looks like this:
opt = strtok(str, " \t=");
if (!opt)
return 0;
option = &dhcp_options[udhcp_option_idx(opt)];
The last line parses "optname".
If we'd insert a code
if (optname is a number) {
val = strtok(NULL, ", \t");
opt,length = parse_optval_as_a_hex_string(val);
attach_option(opt_list, opt, length);
return;
}
directly before it, both dhcp client and server would be able to use it: via -x "23:deadface" and "option 23 deadface" respectively.
Fixed in git, please test. The idea looks good! |