summaryrefslogtreecommitdiff
path: root/networking/udhcp/options.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-06-17 13:24:03 +0200
committerDenys Vlasenko2009-06-17 13:24:03 +0200
commit6947d2c7e194e3be31eed1c75260e15fca1a2568 (patch)
treeff4d67b49e0e7e02e29ecc090db619a39b24498d /networking/udhcp/options.c
parent2b0e95780863da44f6a9244699ece8620a599e19 (diff)
downloadbusybox-6947d2c7e194e3be31eed1c75260e15fca1a2568.zip
busybox-6947d2c7e194e3be31eed1c75260e15fca1a2568.tar.gz
udhcp: logging improvements, field and variable renames
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r--networking/udhcp/options.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index b86b313..0f17feb 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -119,6 +119,20 @@ const uint8_t dhcp_option_lengths[] ALIGN1 = {
};
+#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
+static void log_option(const char *pfx, const uint8_t *opt)
+{
+ if (dhcp_verbose >= 2) {
+ char buf[256 * 2 + 2];
+ *bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0';
+ bb_info_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
+ }
+}
+#else
+# define log_option(pfx, opt) ((void)0)
+#endif
+
+
/* get an option with bounds checking (warning, result is not aligned). */
uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code)
{
@@ -167,11 +181,7 @@ uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code)
continue; /* complain and return NULL */
if (optionptr[OPT_CODE] == code) {
-#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
- char buf[256 * 2 + 2];
- *bin2hex(buf, (void*) (optionptr + OPT_DATA), optionptr[OPT_LEN]) = '\0';
- log2("Option 0x%02x found: %s", code, buf);
-#endif
+ log_option("Option found", optionptr);
return optionptr + OPT_DATA;
}
@@ -214,7 +224,7 @@ int FAST_FUNC add_option_string(uint8_t *optionptr, uint8_t *string)
string[OPT_CODE]);
return 0;
}
- log1("Adding option 0x%02x", string[OPT_CODE]);
+ log_option("Adding option", string);
memcpy(optionptr + end, string, string[OPT_LEN] + 2);
optionptr[end + string[OPT_LEN] + 2] = DHCP_END;
return string[OPT_LEN] + 2;