summaryrefslogtreecommitdiff
path: root/sbin/dhclient/parse.c
AgeCommit message (Collapse)Author
2018-01-04parse_lease_time() is an unnecessary abstraction. Just useKenneth R Westerback
parse_number('L') since it is parsing unsigned 32bit integers.
2018-01-04We only parse decimal numbers, so parse_decimal() -> parse_number() toKenneth R Westerback
match grammar comments and improve euphony.
2017-11-09Use lease 'epoch' (time lease was acquired) to calculate timers forKenneth R Westerback
renew/rebind/expiry. Treat renew/rebind/expiry statements in leases as comments for human consumption.
2017-11-06Add format 't' to parse_decimal() for signed 64-bitKenneth R Westerback
integers.
2017-10-23Use same parse_warn() verbiage in parse_lease_time() as thatKenneth R Westerback
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.
2017-10-19Nuke special case for '\n' in skip_to_semi() andKenneth R Westerback
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().
2017-10-14Refactor parsing of hex sequences. Rename parse_X()Kenneth R Westerback
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.
2017-10-12Make parse_string() toe the new line by returningKenneth R Westerback
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.
2017-10-11Works better when both files in a diff areKenneth R Westerback
committed.
2017-10-11Tweak parse_date() again, this time to factorKenneth R Westerback
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.
2017-10-11Tweak parse_decimal() and its invocations to emit aKenneth R Westerback
single error message ("expecting integer between x and y") and to properly handle ';' in error cases.
2017-10-10Tweak parse_boolean() to be more like its friends.Kenneth R Westerback
i.e. handle ';' better, and issue error message ("expecting boolean.") itself.
2017-10-10Tweak parse_cidr() to be more like its friends.Kenneth R Westerback
i.e. handle ';' better, and issue only one error message ("expecting IPv4 CIDR block"). One gratuitous whitespace tweak tossed in.
2017-10-09Tweak parse_lease_time() to emit a single message onKenneth R Westerback
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.
2017-10-09Tweak parse_ip_addr() to emit a single message onKenneth R Westerback
failure ("expecting IPv4 address") and to properly handle the terminating ';' in error situations.
2017-10-08Simply parse_date() by trusting strptime() more and omittingKenneth R Westerback
pointlessly precise error messages in favour of 'expecting UTC time'.
2017-09-17Oops. Missed a file.Kenneth R Westerback
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.
2017-09-14Strive to rationalize fatal[x]() usage andKenneth R Westerback
verbiage.
2017-07-24Tweak some commentsKenneth R Westerback
2017-07-14Replace remaining "!var" expressions withKenneth R Westerback
"<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.
2017-07-14Replace remaining "!<pointer>" expressions withKenneth R Westerback
"<pointer> == NULL". And of course "<pointer>" expressions with "<pointer> != NULL".
2017-07-10Use a modern spacious idiom on all function local variableKenneth R Westerback
declarations.
2017-07-09Be consistent. "return (e);" -> "return e;"Kenneth R Westerback
2017-07-09Some parsing code cleanup: add parse_boolean(); pass literal formatKenneth R Westerback
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.
2017-07-08Always use uintNN_t instead of sometimes u_intNN_tKenneth R Westerback
and sometimes uintNN_t.
2017-06-29Nuke undocumented long-deprecated and/or unsupported leaseKenneth R Westerback
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.
2017-06-22Drop support for old (>4yr) timestamp formats in leasesKenneth R Westerback
files. ok tb@ millert@
2017-06-19Various KNF nits.Kenneth R Westerback
2017-06-10Nuke unused global warnings_occurred.Kenneth R Westerback
2017-04-09Seven casts, a couple of tweaks and CFLAGS+=-Wsign-compare for theKenneth R Westerback
win. No intentional functional change.
2017-04-08Reduce the overburden of signed vs unsigned comparisons by sprinklingKenneth R Westerback
'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.
2017-04-03Change parse_string() to take an optional integer pointer that canKenneth R Westerback
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.
2017-04-03Simplify read_string() to just read the characters between the '"'s.Kenneth R Westerback
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.
2017-04-03Tweak parse_string() to not consume the ';'. Simplifies/shortensKenneth R Westerback
some logic.
2017-04-03Tweak 'expecting' parse_warn() messages to be more consistent.Kenneth R Westerback
2017-04-02Change parse_string() warning from "filename must be a string" toKenneth R Westerback
"expecting a string". Things other than filenames are parsed here.
2017-02-15Use new log.[ch] functions in parse_warn().Kenneth R Westerback
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.
2017-02-12Switch from 'legacy' errwarn.c to standard daemon logging functions.Kenneth R Westerback
No objections heard. Feedback from millert@ guenther@
2017-02-11Move parse_warning() into parse.c to prepare to replace errwarn.cKenneth R Westerback
with standard daemon log.[ch]. ok mpi@
2016-02-06Eliminate #include inside *.h files and include only needed headers inKenneth R Westerback
each *.c file. Inspired by mention of header silliness by Edgar Pettijohn and mmcc@ on tech@.
2015-05-18Tweak parsing so that hostnames starting with 0-9 are accepted.Kenneth R Westerback
Reported long ago by matthieu@. Also Jacob Berkman via the lists. Tests and suggestions from Jacob and Matthieu.
2014-05-05Zap trailing whitespace. Started by pointed comments from andre@.Kenneth R Westerback
2014-01-21Add parsing for options 121 (classless-static-routes) and 249Kenneth R Westerback
(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!
2014-01-19We don't have any (and I can't find elsewhere) signed 16 bit orKenneth R Westerback
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.
2014-01-19Redo the parsing of numbers to improve the error messages andKenneth R Westerback
make the code more readable. And prepare for some new things that will need to be parsed. ok dlg@
2014-01-19Rename parse_hardware_param() to parse_ethernet() to reflect whatKenneth R Westerback
it actually does.
2014-01-18Make parse_warn() messages consistantly use 'expecting' ratherKenneth R Westerback
than occasionally 'expected'. End all with a '.'.
2014-01-18Never silently consume the following statement when unexpectedlyKenneth R Westerback
encountering a ';'. I.e. when checking the token type, 'skip_to_semi()' after 'parse_warn()' only when the parsed token wasn't a ';'.
2014-01-13peek_token() a bit more to replace a bunch of manual checks withKenneth R Westerback
the perfectly adequate parse_semi(). And some blocks didn't even need to peek.
2014-01-13Don't eat two tokens when encountering a non-terminal '}'. AvoidsKenneth R Westerback
possibly ignoring entire rest of dhclient.conf or dhclient.leases.if looking for a mistakenly consumed '}'.