Missing DHCP Client Name

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
Missing DHCP Client Name

Display DHCP client name 

When MRF24W is a client in the infrastructure network, MRF24W client name appears as empty field in the AP/router's DHCP client table . See figure below. 

 

 

To have MRF24W display a DHCP client name, incorporate the following changes into DHCP.c 

 

Add new code below. 

#define DHCP_HOSTNAME_SIZE 18 

char Dhcp_HostName[DHCP_HOSTNAME_SIZE + 1]; 

/***************************************************************************** 

Function: 

static void DHCPSetHostName(char *HostName) 

Description: 

Set the Host Name. 

Precondition: 

None. 

Parameters: 

HostName = Pointer to zero terminated host name 

Returns: 

None 

***************************************************************************/ 

void DHCPSetHostName(char *HostName) 

strncpy(Dhcp_HostName, HostName, DHCP_HOSTNAME_SIZE); 

Dhcp_HostName[DHCP_HOSTNAME_SIZE] = 0; 

 

Modify existing DHCPSend() as below. 

static void _DHCPSend(BYTE messageType, BOOL bRenewing) 

................................................... 

// Load our interested parameters 

// This is hardcoded list. If any new parameters are desired, 

// new lines must be added here. 

UDPPut(DHCP_PARAM_REQUEST_LIST); 

UDPPut(DHCP_PARAM_REQUEST_LIST_LEN - 1); 

UDPPut(DHCP_SUBNET_MASK); 

UDPPut(DHCP_ROUTER); 

UDPPut(DHCP_DNS); 

 

// Add requested IP address to DHCP Request Message 

if( ((messageType == DHCP_REQUEST_MESSAGE) && !bRenewing) || 

((messageType == DHCP_DISCOVER_MESSAGE) && DHCPClient.tempIPAddress.Val)) 

UDPPut(DHCP_PARAM_REQUEST_IP_ADDRESS); 

UDPPut(DHCP_PARAM_REQUEST_IP_ADDRESS_LEN); 

UDPPutArray((BYTE*)&DHCPClient.tempIPAddress, DHCP_PARAM_REQUEST_IP_ADDRESS_LEN); 

// Add any new parameter request here. 

UDPPut(DHCP_HOST_NAME); 

sprintf((char *)Dhcp_HostName,"%s_%02x%02x", MY_DEFAULT_HOST_NAME, AppConfig.MyMACAddr.v[4], AppConfig.MyMACAddr.v[5]); 

UDPPut(strlen(Dhcp_HostName)); 

UDPPutArray((BYTE*)Dhcp_HostName, strlen(Dhcp_HostName)); 

........................ 

With these modifications, MRF24W has a valid client name now. See figure below. 

 

Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.