aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/options.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-17 13:24:03 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-17 13:24:03 +0200
commit6947d2c7e194e3be31eed1c75260e15fca1a2568 (patch)
treeff4d67b49e0e7e02e29ecc090db619a39b24498d /networking/udhcp/options.c
parent2b0e95780863da44f6a9244699ece8620a599e19 (diff)
downloadbusybox-w32-6947d2c7e194e3be31eed1c75260e15fca1a2568.tar.gz
busybox-w32-6947d2c7e194e3be31eed1c75260e15fca1a2568.tar.bz2
busybox-w32-6947d2c7e194e3be31eed1c75260e15fca1a2568.zip
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 b86b3135d..0f17feb2a 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -119,6 +119,20 @@ const uint8_t dhcp_option_lengths[] ALIGN1 = {
119}; 119};
120 120
121 121
122#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
123static void log_option(const char *pfx, const uint8_t *opt)
124{
125 if (dhcp_verbose >= 2) {
126 char buf[256 * 2 + 2];
127 *bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0';
128 bb_info_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
129 }
130}
131#else
132# define log_option(pfx, opt) ((void)0)
133#endif
134
135
122/* get an option with bounds checking (warning, result is not aligned). */ 136/* get an option with bounds checking (warning, result is not aligned). */
123uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code) 137uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code)
124{ 138{
@@ -167,11 +181,7 @@ uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code)
167 continue; /* complain and return NULL */ 181 continue; /* complain and return NULL */
168 182
169 if (optionptr[OPT_CODE] == code) { 183 if (optionptr[OPT_CODE] == code) {
170#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2 184 log_option("Option found", optionptr);
171 char buf[256 * 2 + 2];
172 *bin2hex(buf, (void*) (optionptr + OPT_DATA), optionptr[OPT_LEN]) = '\0';
173 log2("Option 0x%02x found: %s", code, buf);
174#endif
175 return optionptr + OPT_DATA; 185 return optionptr + OPT_DATA;
176 } 186 }
177 187
@@ -214,7 +224,7 @@ int FAST_FUNC add_option_string(uint8_t *optionptr, uint8_t *string)
214 string[OPT_CODE]); 224 string[OPT_CODE]);
215 return 0; 225 return 0;
216 } 226 }
217 log1("Adding option 0x%02x", string[OPT_CODE]); 227 log_option("Adding option", string);
218 memcpy(optionptr + end, string, string[OPT_LEN] + 2); 228 memcpy(optionptr + end, string, string[OPT_LEN] + 2);
219 optionptr[end + string[OPT_LEN] + 2] = DHCP_END; 229 optionptr[end + string[OPT_LEN] + 2] = DHCP_END;
220 return string[OPT_LEN] + 2; 230 return string[OPT_LEN] + 2;