Problems with DHCP configuration

  • To configure our boards to use DHCP to acquire an IP address we change the value EnableDHCP inside the registry under HKLM\Comm\ETHNETA1\Parms\TcpIp. Then we simply execute ndisconfig adapter rebind ETHNETA1 which works as expected. If we want to use a static address we simply set EnableDHCP=0 add an additional entry for the static IP and rebind again which works, too.
    But after turning DHCP off and on again via the registry the device doesn't get a valid IP address anymore. I already checked with wireshark and can see that the device ist not sending a DHCP request.

    With an older image we were able to switch this setting on and off as often as needed and the device always got a valid address when DHCP was enabled.

  • Hello,

    can you please tell me the driver version which is working/not working and if the problem is related to efusA9/efusA)R2 or both.

    Thanks.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • The problem occurs with both versions of the efus(r1 and r2).
    The debug output logs show:

    [working]

    ENET: Version 1.3, ActiveKey = Comm\ETHNETA

    ETHMAN: Version 1.1, ActiveKey = Drivers\Active\32


    [problems with DHCP]

    ENET: Version 1.7, ActiveKey = Comm\ETHNETA

    ENET: PHY_PWRDOWN=FALSE MII_REG_CR=0x3100

    ETHMAN: Version 1.2, ActiveKey = Drivers\Active\32

  • Sorry, no i did not test it.

    Hope I can spend some time next week. At the time we are bound on other projects.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello fstendike,


    does the problem still persit on your side?

    Or you found any workaround? This would be interesting for me too.

    I test the kernel V3.4 with Ethernet driver V1.3 this does not change the behavior. But we can exclude Ethernet driver cause the issue.


    If I use the control panel's applet "Network" to assign DHCP Ip <-> static IP the issue does not occur! I test it ten times.


    But I must admit when I use following (pseudo code) it does not work reliable when I do not wait for some time at * (in my case I wait 6s). After additional 4s -15s I retreive a valid and useable "CurrentIpAddress" by GetAdatersInfo() :


    do{

    RegistrySet/ClearDHCP

    *

    IOCTL_NDIS_UNBIND_ADAPTER

    IOCTL_NDIS_BIND_ADAPTER

    Poll GetAdaptersInfo();

    }while(true)


    So I assume to use the Registry to enable DHCP is not the correct way because of a timing issue. As far as I know you use PB to create your image so maybe you can figure out how the control panel enabels DHCP;).


    Hope this helps.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello Mr. Zutter,

    unfortunately your workaround doesn't solve the problem on our side. It seems to me that the setting in which the device bootet is the one that works (DHCP or static address) and the other option always results in a self assigned ip address. Waiting for several seconds doesn't change the outcome, too.

    However we found a workaround which seems to resolve the issue on our side. With the following sequence the settings are always applied correctly:


    ndisconfig.exe power set ETHNETA1 D4

    RegistrySet/ClearDHCP

    ndisconfig.exe power set ETHNETA1 D0

    ndisconfig.exe adapter rebind ETHNETA1 TCPIP


    So it seems to me that we have to disable the adapter first (set power state to D4) then apply the reg settings and enable the adapter afterwards followed by a rebind of it.

    This would be an acceptable solution for us but we don't want to have the console output of calling ndisconfig.exe in our user app (C#). Maybe you can help us with finding out the DeviceIOControl Codes for these commands? Is the source code of ndisconfig available (I know it's "just" a wrapper program to call the appropriate DeviceIOControl commands)?

  • Hello fstendike,


    thanks for this information. But it is strange. On my side my suggestion works for several hours without any issues!


    About your desire above, don't think you need the ndisconfig source.

    Try DLL import similar according the functions below:


    Samples for DLL import of "CreateFile", "CloseFile" and "DeviceIoControl" (note, may be overloaded in different ways) will be available here: PWM sample. Also assume all const. will be found in ndis.h.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

    Edited once, last by fs-support_ZU ().

  • We already had the suitable prototypes to call the DeviceIoControl function in our code because we needed it for other use cases.

    What I wanted to know where the numbers of the function value and the correct parameters to set the power state. The header ndis.h doesn't contain any constants for the DeviceIoControl function values. I was able to look it up by myself because the SDK contained the source of ndisconfig (I thought that this was an F&S tool and not part of the OS).
    Just for reference:
    IOCTL_NDIS_REBIND_ADAPTER = 11 (defined in ntddndis.h)
    The power state can either be set with a PInvoke to SetDevicePower in coredll.dll (which is what we did) or with an appropriate call of DeviceIoControl with
    IOCTL_POWER_SET = 0x402 (defined in header pm.h)