DHCP_END
};
+/**
+ * Name a DHCP packet type
+ *
+ * @v msgtype DHCP message type
+ * @ret string DHCP mesasge type name
+ */
+static inline const char * dhcp_message_type_name ( unsigned int msgtype ) {
+ switch ( msgtype ) {
+ case DHCPDISCOVER: return "DHCPDISCOVER";
+ case DHCPOFFER: return "DHCPOFFER";
+ case DHCPREQUEST: return "DHCPREQUEST";
+ case DHCPDECLINE: return "DHCPDECLINE";
+ case DHCPACK: return "DHCPACK";
+ case DHCPNAK: return "DHCPNAK";
+ case DHCPRELEASE: return "DHCPRELEASE";
+ case DHCPINFORM: return "DHCPINFORM";
+ default: return "DHCP<invalid>";
+ }
+}
+
/** Options common to all DHCP requests */
static struct dhcp_option_block dhcp_request_options = {
.data = dhcp_request_options_data,
struct dhcp_packet dhcppkt;
int rc;
+ DBG ( "Transmitting %s\n", dhcp_message_type_name ( dhcp->state ) );
+
assert ( ( dhcp->state == DHCPDISCOVER ) ||
( dhcp->state == DHCPREQUEST ) );
/* Check for matching transaction ID */
if ( dhcphdr->xid != dhcp->xid ) {
- DBG ( "DHCP wrong transaction ID (wanted %08x, got %08x)\n",
+ DBG ( "DHCP wrong transaction ID (wanted %08lx, got %08lx)\n",
ntohl ( dhcphdr->xid ), ntohl ( dhcp->xid ) );
return;
};
return;
}
+ DBG ( "Received %s\n",
+ dhcp_message_type_name ( find_dhcp_num_option ( options,
+ DHCP_MESSAGE_TYPE ) ) );
+
/* Proof of concept: just dump out the parsed options */
hex_dump ( options->data, options->len );
free_dhcp_options ( options );