|
@@ -58,6 +58,26 @@ static uint8_t dhcp_request_options_data[] = {
|
58
|
58
|
DHCP_END
|
59
|
59
|
};
|
60
|
60
|
|
|
61
|
+/**
|
|
62
|
+ * Name a DHCP packet type
|
|
63
|
+ *
|
|
64
|
+ * @v msgtype DHCP message type
|
|
65
|
+ * @ret string DHCP mesasge type name
|
|
66
|
+ */
|
|
67
|
+static inline const char * dhcp_message_type_name ( unsigned int msgtype ) {
|
|
68
|
+ switch ( msgtype ) {
|
|
69
|
+ case DHCPDISCOVER: return "DHCPDISCOVER";
|
|
70
|
+ case DHCPOFFER: return "DHCPOFFER";
|
|
71
|
+ case DHCPREQUEST: return "DHCPREQUEST";
|
|
72
|
+ case DHCPDECLINE: return "DHCPDECLINE";
|
|
73
|
+ case DHCPACK: return "DHCPACK";
|
|
74
|
+ case DHCPNAK: return "DHCPNAK";
|
|
75
|
+ case DHCPRELEASE: return "DHCPRELEASE";
|
|
76
|
+ case DHCPINFORM: return "DHCPINFORM";
|
|
77
|
+ default: return "DHCP<invalid>";
|
|
78
|
+ }
|
|
79
|
+}
|
|
80
|
+
|
61
|
81
|
/** Options common to all DHCP requests */
|
62
|
82
|
static struct dhcp_option_block dhcp_request_options = {
|
63
|
83
|
.data = dhcp_request_options_data,
|
|
@@ -419,6 +439,8 @@ static void dhcp_senddata ( struct udp_connection *conn,
|
419
|
439
|
struct dhcp_packet dhcppkt;
|
420
|
440
|
int rc;
|
421
|
441
|
|
|
442
|
+ DBG ( "Transmitting %s\n", dhcp_message_type_name ( dhcp->state ) );
|
|
443
|
+
|
422
|
444
|
assert ( ( dhcp->state == DHCPDISCOVER ) ||
|
423
|
445
|
( dhcp->state == DHCPREQUEST ) );
|
424
|
446
|
|
|
@@ -455,7 +477,7 @@ static void dhcp_newdata ( struct udp_connection *conn,
|
455
|
477
|
|
456
|
478
|
/* Check for matching transaction ID */
|
457
|
479
|
if ( dhcphdr->xid != dhcp->xid ) {
|
458
|
|
- DBG ( "DHCP wrong transaction ID (wanted %08x, got %08x)\n",
|
|
480
|
+ DBG ( "DHCP wrong transaction ID (wanted %08lx, got %08lx)\n",
|
459
|
481
|
ntohl ( dhcphdr->xid ), ntohl ( dhcp->xid ) );
|
460
|
482
|
return;
|
461
|
483
|
};
|
|
@@ -467,6 +489,10 @@ static void dhcp_newdata ( struct udp_connection *conn,
|
467
|
489
|
return;
|
468
|
490
|
}
|
469
|
491
|
|
|
492
|
+ DBG ( "Received %s\n",
|
|
493
|
+ dhcp_message_type_name ( find_dhcp_num_option ( options,
|
|
494
|
+ DHCP_MESSAGE_TYPE ) ) );
|
|
495
|
+
|
470
|
496
|
/* Proof of concept: just dump out the parsed options */
|
471
|
497
|
hex_dump ( options->data, options->len );
|
472
|
498
|
free_dhcp_options ( options );
|