diff options
Diffstat (limited to 'networking/udhcp/common.h')
| -rw-r--r-- | networking/udhcp/common.h | 58 |
1 files changed, 25 insertions, 33 deletions
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 9d1f71aae..bba3d6037 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
| @@ -40,7 +40,7 @@ struct dhcp_packet { | |||
| 40 | uint32_t yiaddr; /* 'your' (client) IP address */ | 40 | uint32_t yiaddr; /* 'your' (client) IP address */ |
| 41 | /* IP address of next server to use in bootstrap, returned in DHCPOFFER, DHCPACK by server */ | 41 | /* IP address of next server to use in bootstrap, returned in DHCPOFFER, DHCPACK by server */ |
| 42 | uint32_t siaddr_nip; | 42 | uint32_t siaddr_nip; |
| 43 | uint32_t gateway_nip; /* relay agent IP address */ | 43 | uint32_t gateway_nip; /* aka 'giaddr': relay agent IP address */ |
| 44 | uint8_t chaddr[16]; /* link-layer client hardware address (MAC) */ | 44 | uint8_t chaddr[16]; /* link-layer client hardware address (MAC) */ |
| 45 | uint8_t sname[64]; /* server host name (ASCIZ) */ | 45 | uint8_t sname[64]; /* server host name (ASCIZ) */ |
| 46 | uint8_t file[128]; /* boot file name (ASCIZ) */ | 46 | uint8_t file[128]; /* boot file name (ASCIZ) */ |
| @@ -222,10 +222,9 @@ uint8_t *dname_enc(const uint8_t *cstr, int clen, const char *src, int *retlen) | |||
| 222 | #endif | 222 | #endif |
| 223 | struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC; | 223 | struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC; |
| 224 | 224 | ||
| 225 | |||
| 226 | // RFC 2131 Table 5: Fields and options used by DHCP clients | 225 | // RFC 2131 Table 5: Fields and options used by DHCP clients |
| 227 | // | 226 | // |
| 228 | // Fields 'hops', 'yiaddr', 'siaddr', 'giaddr' are always zero | 227 | // Fields 'hops', 'yiaddr', 'siaddr', 'giaddr' are always zero, 'chaddr' is always client's MAC |
| 229 | // | 228 | // |
| 230 | // Field DHCPDISCOVER DHCPINFORM DHCPREQUEST DHCPDECLINE DHCPRELEASE | 229 | // Field DHCPDISCOVER DHCPINFORM DHCPREQUEST DHCPDECLINE DHCPRELEASE |
| 231 | // ----- ------------ ------------ ----------- ----------- ----------- | 230 | // ----- ------------ ------------ ----------- ----------- ----------- |
| @@ -234,56 +233,49 @@ struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) | |||
| 234 | // 'secs' 0 or seconds since 0 or seconds since 0 or seconds since 0 0 | 233 | // 'secs' 0 or seconds since 0 or seconds since 0 or seconds since 0 0 |
| 235 | // DHCP process started DHCP process started DHCP process started | 234 | // DHCP process started DHCP process started DHCP process started |
| 236 | // 'flags' Set 'BROADCAST' Set 'BROADCAST' Set 'BROADCAST' 0 0 | 235 | // 'flags' Set 'BROADCAST' Set 'BROADCAST' Set 'BROADCAST' 0 0 |
| 237 | // flag if client flag if client flag if client | 236 | // flag if client needs flag if client needs flag if client needs |
| 238 | // requires broadcast requires broadcast requires broadcast | 237 | // broadcast reply broadcast reply broadcast reply |
| 239 | // reply reply reply | ||
| 240 | // 'ciaddr' 0 client's IP 0 or client's IP 0 client's IP | 238 | // 'ciaddr' 0 client's IP 0 or client's IP 0 client's IP |
| 241 | // (BOUND/RENEW/REBIND) | 239 | // (BOUND/RENEW/REBIND) |
| 242 | // 'chaddr' client's MAC client's MAC client's MAC client's MAC client's MAC | ||
| 243 | // 'sname' options or sname options or sname options or sname (unused) (unused) | 240 | // 'sname' options or sname options or sname options or sname (unused) (unused) |
| 244 | // 'file' options or file options or file options or file (unused) (unused) | 241 | // 'file' options or file options or file options or file (unused) (unused) |
| 245 | // 'options' options options options message type opt message type opt | 242 | // 'options' options options options message type opt message type opt |
| 246 | // | 243 | // |
| 247 | // Option DHCPDISCOVER DHCPINFORM DHCPREQUEST DHCPDECLINE DHCPRELEASE | 244 | // Option DHCPDISCOVER DHCPINFORM DHCPREQUEST DHCPDECLINE DHCPRELEASE |
| 248 | // ------ ------------ ---------- ----------- ----------- ----------- | 245 | // ------ ------------ ---------- ----------- ----------- ----------- |
| 249 | // Requested IP address MAY MUST NOT MUST (in MUST MUST NOT | 246 | // Requested IP address MAY MUST NOT MUST (in SELECTING MUST MUST NOT |
| 250 | // SELECTING or | 247 | // or INIT-REBOOT) |
| 251 | // INIT-REBOOT) | 248 | // MUST NOT (in BOUND |
| 252 | // MUST NOT (in | 249 | // or RENEWING) |
| 253 | // BOUND or | 250 | // IP address lease time MAY MUST NOT MAY MUST NOT MUST NOT |
| 254 | // RENEWING) | 251 | // Use 'file'/'sname' fields MAY MAY MAY MAY MAY |
| 255 | // IP address lease time MAY MUST NOT MAY MUST NOT MUST NOT | 252 | // Client identifier MAY MAY MAY MAY MAY |
| 256 | // Use 'file'/'sname' fields MAY MAY MAY MAY MAY | 253 | // Vendor class identifier MAY MAY MAY MUST NOT MUST NOT |
| 257 | // Client identifier MAY MAY MAY MAY MAY | 254 | // Server identifier MUST NOT MUST NOT MUST (after SELECTING) MUST MUST |
| 258 | // Vendor class identifier MAY MAY MAY MUST NOT MUST NOT | ||
| 259 | // Server identifier MUST NOT MUST NOT MUST (after MUST MUST | ||
| 260 | // SELECTING) | ||
| 261 | // MUST NOT (after | 255 | // MUST NOT (after |
| 262 | // INIT-REBOOT, | 256 | // INIT-REBOOT, BOUND, |
| 263 | // BOUND, RENEWING | 257 | // RENEWING or REBINDING) |
| 264 | // or REBINDING) | 258 | // Parameter request list MAY MAY MAY MUST NOT MUST NOT |
| 265 | // Parameter request list MAY MAY MAY MUST NOT MUST NOT | 259 | // Maximum message size MAY MAY MAY MUST NOT MUST NOT |
| 266 | // Maximum message size MAY MAY MAY MUST NOT MUST NOT | 260 | // Message SHOULD NOT SHOULD NOT SHOULD NOT SHOULD SHOULD |
| 267 | // Message SHOULD NOT SHOULD NOT SHOULD NOT SHOULD SHOULD | 261 | // Site-specific MAY MAY MAY MUST NOT MUST NOT |
| 268 | // Site-specific MAY MAY MAY MUST NOT MUST NOT | 262 | // All others MAY MAY MAY MUST NOT MUST NOT |
| 269 | // All others MAY MAY MAY MUST NOT MUST NOT | ||
| 270 | |||
| 271 | 263 | ||
| 272 | /*** Logging ***/ | 264 | /*** Logging ***/ |
| 273 | 265 | ||
| 274 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 | 266 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 |
| 275 | # define IF_UDHCP_VERBOSE(...) __VA_ARGS__ | 267 | # define IF_UDHCP_VERBOSE(...) __VA_ARGS__ |
| 276 | extern unsigned dhcp_verbose; | 268 | extern unsigned dhcp_verbose; |
| 277 | # define log1(...) do { if (dhcp_verbose >= 1) bb_error_msg(__VA_ARGS__); } while (0) | 269 | # define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0) |
| 278 | # if CONFIG_UDHCP_DEBUG >= 2 | 270 | # if CONFIG_UDHCP_DEBUG >= 2 |
| 279 | void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC; | 271 | void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC; |
| 280 | # define log2(...) do { if (dhcp_verbose >= 2) bb_error_msg(__VA_ARGS__); } while (0) | 272 | # define log2(...) do { if (dhcp_verbose >= 2) bb_info_msg(__VA_ARGS__); } while (0) |
| 281 | # else | 273 | # else |
| 282 | # define udhcp_dump_packet(...) ((void)0) | 274 | # define udhcp_dump_packet(...) ((void)0) |
| 283 | # define log2(...) ((void)0) | 275 | # define log2(...) ((void)0) |
| 284 | # endif | 276 | # endif |
| 285 | # if CONFIG_UDHCP_DEBUG >= 3 | 277 | # if CONFIG_UDHCP_DEBUG >= 3 |
| 286 | # define log3(...) do { if (dhcp_verbose >= 3) bb_error_msg(__VA_ARGS__); } while (0) | 278 | # define log3(...) do { if (dhcp_verbose >= 3) bb_info_msg(__VA_ARGS__); } while (0) |
| 287 | # else | 279 | # else |
| 288 | # define log3(...) ((void)0) | 280 | # define log3(...) ((void)0) |
| 289 | # endif | 281 | # endif |
