Problem with using internal dhcp with ethernet

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

I want to use two  BCM943907WCD2  devices and one is server(or gateway) ,the other is client.

The AP fails to start DHCP service at wiced_start_dhcp_server() because I define the interface as WICED_ETHERNET_INTERFACE .

How can I get the right configuration to run a BCM943907WCD2  platform as an ethernet server with DHCP function?

Could anyone help?

0 Likes
1 Solution
AndrewY_86
Employee
Employee
25 sign-ins 25 replies posted 10 replies posted

Try adding this:

wiced_ip_setting_t ip_settings =

{

  INITIALISER_IPV4_ADDRESS( .ip_address, MAKE_IPV4_ADDRESS( 192,168, 0, 1 ) ),

  INITIALISER_IPV4_ADDRESS( .netmask, MAKE_IPV4_ADDRESS( 255,255,255, 0 ) ),

  INITIALISER_IPV4_ADDRESS( .gateway, MAKE_IPV4_ADDRESS( 192,168, 0, 1 ) ),

};

wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_INTERNAL_DHCP_SERVER, &ip_settings );

If building for debug, comment the following line for testing

/* DHCP_CHECK_PARAMS( (server == NULL) || ( (interface != WICED_STA_INTERFACE) && (interface != WICED_AP_INTERFACE) && (interface != WICED_P2P_INTERFACE) && (interface != WICED_CONFIG_INTERFACE) ), WICED_BADARG ); */

View solution in original post

11 Replies
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

You can use wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_INTERNAL_DHCP_SERVER, NULL ); for this. The WICED_USE_INTERNAL_DHCP_SERVER would allow WICED to start DHCP server.

Anonymous
Not applicable

Hi grsr,

It is stuck in wiced_start_dhcp_server() since the parameter is not allowed. When use the WICED_USE_INTERNAL_DHCP_SERVER option,  wiced_start_dhcp_server() will sentence the WICED_ETHERNET_INTERFACE to be WICED_BADARG as the following shows at line.153 in dhcp_server.c.

DHCP_CHECK_PARAMS( (server == NULL) || ( (interface != WICED_STA_INTERFACE) && (interface != WICED_AP_INTERFACE) && (interface != WICED_P2P_INTERFACE) && (interface != WICED_CONFIG_INTERFACE) ), WICED_BADARG );

0 Likes

Does it work if you comment out the DHCP_CHECK_PARAMS line?

0 Likes
Anonymous
Not applicable

The result is "Unable to obtain IP address via DHCP"

0 Likes

joeccmou_2842441 wrote:

The result is "Unable to obtain IP address via DHCP"

grsr

Any comment about this?

0 Likes
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

Please ignore my last response. Ethernet interface cannot be used as DHCP server. The WICED_USE_INTERNAL_DHCP_SERVER is only valid for softAP interface.

0 Likes

Why ethernet interface cannot be used as DHCP server?

Take a look at libraries/daemons/DHCP_server, there is no such limitation at all.

0 Likes
Anonymous
Not applicable

Thank you for your reply, but why the ethernet interface cannot be used as DHCP server?

0 Likes
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

To start DHCP server, the WICED_USE_INTERNAL_DHCP_SERVER is required in wiced_network_up(). However, in the documentation API.html, WICED_USE_INTERNAL_DHCP_SERVER  has been described as "softAP interface: use the internal DHCP server". The interfaces are configured as shown in the struct below:

static wiced_network_config_t wiced_config_cache[ WICED_INTERFACE_MAX ] =

{

    [WICED_STA_INTERFACE]      = WICED_USE_EXTERNAL_DHCP_SERVER,

    [WICED_AP_INTERFACE]       = WICED_USE_INTERNAL_DHCP_SERVER,

    [WICED_P2P_INTERFACE]      = WICED_USE_EXTERNAL_DHCP_SERVER,

    [WICED_ETHERNET_INTERFACE] = WICED_USE_EXTERNAL_DHCP_SERVER,

};

I think you can try:

1. Change

   [WICED_ETHERNET_INTERFACE] = WICED_USE_EXTERNAL_DHCP_SERVER,

   to

   [WICED_ETHERNET_INTERFACE] = WICED_USE_INTERNAL_DHCP_SERVER,

   Above change depends on the network stack you use:

   WICED/network/LwIP/WICED/wiced_network.c

   WICED/network/NetX/WICED/wiced_network.c

   WICED/network/NetX_Duo/WICED/wiced_network.c

2. Comment out the line checking interface in dhcp_server.

AndrewY_86
Employee
Employee
25 sign-ins 25 replies posted 10 replies posted

Try adding this:

wiced_ip_setting_t ip_settings =

{

  INITIALISER_IPV4_ADDRESS( .ip_address, MAKE_IPV4_ADDRESS( 192,168, 0, 1 ) ),

  INITIALISER_IPV4_ADDRESS( .netmask, MAKE_IPV4_ADDRESS( 255,255,255, 0 ) ),

  INITIALISER_IPV4_ADDRESS( .gateway, MAKE_IPV4_ADDRESS( 192,168, 0, 1 ) ),

};

wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_INTERNAL_DHCP_SERVER, &ip_settings );

If building for debug, comment the following line for testing

/* DHCP_CHECK_PARAMS( (server == NULL) || ( (interface != WICED_STA_INTERFACE) && (interface != WICED_AP_INTERFACE) && (interface != WICED_P2P_INTERFACE) && (interface != WICED_CONFIG_INTERFACE) ), WICED_BADARG ); */