summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient/parse.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup/simplify parse_number():krw2019-07-221-36/+5
| | | | | | | | | | | | | | 1) Restructure to explicitly set a long long result and take the desired low/high constraints for strtonum(). 2) No need to use a temporary variable when setting long long (a.k.a. time_t) fields. 3) Fewer magic numbers when processing integer valued option data. Less memcpy()'ing where a cast or two is sufficient to make integer assignment work. No intentional functional change.
* Restructure parse_semi() so it resembles the other parse_*krw2019-07-211-7/+8
| | | | functions.
* Replace malloc()/memcpy() with strdup() in parse_string(). Nuke 'len' parameterkrw2019-07-211-7/+4
| | | | | to parse_string() in favour of taking strlen() of resulting string in the few cases that it is of interest.
* Parsing error messages display only the first 80 characters of thekrw2019-03-191-2/+2
| | | | | offending line. It is fruitless to try to position the "^" at a character more than 80 characters from the start of the line.
* parse_lease_time() is an unnecessary abstraction. Just usekrw2018-01-041-26/+1
| | | | parse_number('L') since it is parsing unsigned 32bit integers.
* We only parse decimal numbers, so parse_decimal() -> parse_number() tokrw2018-01-041-2/+2
| | | | match grammar comments and improve euphony.
* Use lease 'epoch' (time lease was acquired) to calculate timers forkrw2017-11-091-60/+1
| | | | | renew/rebind/expiry. Treat renew/rebind/expiry statements in leases as comments for human consumption.
* Add format 't' to parse_decimal() for signed 64-bitkrw2017-11-061-1/+6
| | | | integers.
* Use same parse_warn() verbiage in parse_lease_time() as thatkrw2017-10-231-2/+2
| | | | | | emitted when other unsigned 32-bit values are parsed. i.e. "expecting integer between 0 and 4294967295". No need to make people google what "unsigned 32-bit decimal value" means.
* Nuke special case for '\n' in skip_to_semi() andkrw2017-10-191-10/+1
| | | | | | | | associated weird comment about parsing resolv.conf. dhclient.conf and dhclient.leases.<if> are semi-colon oriented and not line oriented. '\n' is never returned by get_token().
* Refactor parsing of hex sequences. Rename parse_X()krw2017-10-141-22/+1
| | | | | | | | | | | to parse_hex_octets() and have it return 0/1 to indicate success, to not touch existing data on error paths, to handle ';' better, emit single error message ("expecting colon delimited list of hex octets."). Fold parse_hex() into parse_hex_octets(). Simplify logic in parse_option_decl() to eliminate duplicate overflow error checking and error messages as a result.
* Make parse_string() toe the new line by returningkrw2017-10-121-22/+21
| | | | | | | | | | 0 for failure, 1 for success, emitting a single error message ("expecting string.") and handling ';' better. Don't leak memory when encountering pathological config or lease files containing repeated instances of an option or command with string data.
* Works better when both files in a diff arekrw2017-10-111-2/+4
| | | | committed.
* Tweak parse_date() again, this time to factorkrw2017-10-111-14/+17
| | | | | | | code in the same way as the other parse_*() functions. Whitespace fix in comment while passing. Also conform to idiom that original data is not changed in the error path.
* Tweak parse_decimal() and its invocations to emit akrw2017-10-111-8/+18
| | | | | single error message ("expecting integer between x and y") and to properly handle ';' in error cases.
* Tweak parse_boolean() to be more like its friends.krw2017-10-101-1/+5
| | | | | i.e. handle ';' better, and issue error message ("expecting boolean.") itself.
* Tweak parse_cidr() to be more like its friends.krw2017-10-101-25/+30
| | | | | | | i.e. handle ';' better, and issue only one error message ("expecting IPv4 CIDR block"). One gratuitous whitespace tweak tossed in.
* Tweak parse_lease_time() to emit a single message onkrw2017-10-091-9/+15
| | | | | | | | | | | | failure ("expecting unsigned 32-bit decimal value") and to properly handle the terminating ';' in error situations. Make parse_lease_time() return an int to indicate success or failure as its friends do. Also avoid swapping endianess twice. Use == 1 vs != 0 when checking parse_ip_addr() return value.
* Tweak parse_ip_addr() to emit a single message onkrw2017-10-091-21/+24
| | | | | failure ("expecting IPv4 address") and to properly handle the terminating ';' in error situations.
* Simply parse_date() by trusting strptime() more and omittingkrw2017-10-081-32/+22
| | | | | pointlessly precise error messages in favour of 'expecting UTC time'.
* Oops. Missed a file.krw2017-09-171-4/+4
| | | | | | | Create global 'log_procname' and set it to '<ifname>' or '<ifname> [priv]' as appropriate for the process doing the setting. Use it as the prefix in all log_*() output. Makes tracking messages for an interface or a process much easier.
* Strive to rationalize fatal[x]() usage andkrw2017-09-141-2/+2
| | | | verbiage.
* Tweak some commentskrw2017-07-241-3/+4
|
* Replace remaining "!var" expressions withkrw2017-07-141-11/+11
| | | | | | | | | | "<var> == 0", "!(<var> & FLAG)" with "(<var> & FLAG) == 0", "!<func()>" with "<func()> == 0" and "!<define>" with "<define> == 0". And the positive cases as well. A few stray == NULL and != NULL as well.
* Replace remaining "!<pointer>" expressions withkrw2017-07-141-2/+2
| | | | | "<pointer> == NULL". And of course "<pointer>" expressions with "<pointer> != NULL".
* Use a modern spacious idiom on all function local variablekrw2017-07-101-24/+24
| | | | declarations.
* Be consistent. "return (e);" -> "return e;"krw2017-07-091-26/+26
|
* Some parsing code cleanup: add parse_boolean(); pass literal formatkrw2017-07-091-1/+24
| | | | | | chars to parse_decimal() instead of less obvious *fmt; refactor to eliminate need for the 'alloc:' and 'bad_flag:' labels and the invidious backwards goto's to them.
* Always use uintNN_t instead of sometimes u_intNN_tkrw2017-07-081-2/+2
| | | | and sometimes uintNN_t.
* Nuke undocumented long-deprecated and/or unsupported leasekrw2017-06-291-38/+1
| | | | | | | | | fields 'hardware', 'alias', 'media', 'medium', 'ethernet'. Also remove now-unused parse_ethernet(). Making these parsing failures will smoke out anybody with leases or conf files from the last century.
* Drop support for old (>4yr) timestamp formats in leaseskrw2017-06-221-9/+3
| | | | | | files. ok tb@ millert@
* Various KNF nits.krw2017-06-191-2/+2
|
* Nuke unused global warnings_occurred.krw2017-06-101-5/+1
|
* Seven casts, a couple of tweaks and CFLAGS+=-Wsign-compare for thekrw2017-04-091-3/+3
| | | | | | win. No intentional functional change.
* Reduce the overburden of signed vs unsigned comparisons by sprinklingkrw2017-04-081-3/+3
| | | | | | | | | 'int' -> 'unsigned int' (and visa versa) where obvious. Steal a couple of 'unsigned' -> u_int32_t from reyk@'s dhcrelay tweaks. No intentional functional change.
* Change parse_string() to take an optional integer pointer that cankrw2017-04-031-2/+4
| | | | | | be used to return the final size of the parsed (i.e. un-vis'ed) string. Use same, plus memcpy() to ensure entire final string is copied to intended destination even if there are embedded NULs.
* Simplify read_string() to just read the characters between the '"'s.krw2017-04-031-3/+12
| | | | | | | Push the un-vising up to parse_string(). This allows both the actual string and the un-vised version to be available as desired. Use memcpy() instead of strdup() to copy un-vised string since it may legitimately contain NUL.
* Tweak parse_string() to not consume the ';'. Simplifies/shortenskrw2017-04-031-8/+1
| | | | some logic.
* Tweak 'expecting' parse_warn() messages to be more consistent.krw2017-04-031-6/+6
|
* Change parse_string() warning from "filename must be a string" tokrw2017-04-021-2/+2
| | | | "expecting a string". Things other than filenames are parsed here.
* Use new log.[ch] functions in parse_warn().krw2017-02-151-36/+12
| | | | | | | | Simplify the "^" placing logic and make it apply to log entries as well as terminal output. Since dhclient(8) can be re-exec'd for various reasons after going daemon, make sure we don't try to log to stderr if it isn't a TTY.
* Switch from 'legacy' errwarn.c to standard daemon logging functions.krw2017-02-121-3/+6
| | | | No objections heard. Feedback from millert@ guenther@
* Move parse_warning() into parse.c to prepare to replace errwarn.ckrw2017-02-111-1/+49
| | | | | | with standard daemon log.[ch]. ok mpi@
* Eliminate #include inside *.h files and include only needed headers inkrw2016-02-061-1/+16
| | | | | | | each *.c file. Inspired by mention of header silliness by Edgar Pettijohn and mmcc@ on tech@.
* Tweak parsing so that hostnames starting with 0-9 are accepted.krw2015-05-181-1/+2
| | | | | | Reported long ago by matthieu@. Also Jacob Berkman via the lists. Tests and suggestions from Jacob and Matthieu.
* Zap trailing whitespace. Started by pointed comments from andre@.krw2014-05-051-6/+6
|
* Add parsing for options 121 (classless-static-routes) and 249krw2014-01-211-1/+40
| | | | | | | | (classless-ms-static-routes). dhcpd can now specify and serve these options and dhclient can recognize and use supersede, etc. statements on them. Based on a diff from Stefan Rinke. Thanks!
* We don't have any (and I can't find elsewhere) signed 16 bit orkrw2014-01-191-11/+1
| | | | | | signed 8 bit dhcp option types. So nuke getShort() and all 's' and 'b' format support. While here use '%u'/'%lu' and not '%d'/'%ld' to snprintf() unsigned values.
* Redo the parsing of numbers to improve the error messages andkrw2014-01-191-142/+112
| | | | | | | make the code more readable. And prepare for some new things that will need to be parsed. ok dlg@
* Rename parse_hardware_param() to parse_ethernet() to reflect whatkrw2014-01-191-4/+3
| | | | it actually does.