/*
    Sample code to show how to get the IP and MAC address of
    the desktop machine connected via Ethernet to CESH
*/
#include <windows.h>
#include "ethdbg.h"
#include "halether.h"


int WINAPI WinMain (HINSTANCE hInstance, 
                    HINSTANCE hPrevInstance,
                    LPWSTR lpCmdLine, 
                    int nCmdShow)
{
    IP_INFO IpInfo;
    DWORD dwAddrType;
    DWORD dwLen = 0;

    dwAddrType = IPINFO_DOWNLOAD;
    memset(&IpInfo, 0, sizeof(IpInfo));
    if (KernelIoControl(IOCTL_HAL_GET_IP_ADDR, 
                        &dwAddrType, sizeof(dwAddrType),
                        &IpInfo, sizeof(IpInfo), &dwLen))
    {
        if ( IpInfo.dwIP == 0 )
        {
            NKDbgPrintfW(L"No peer address information available.  "
                          "Probably connected over a parallel port "
                          "link\n");
        }
        else
        {
            NKDbgPrintfW(L"CESH peer address info: IP:%hs, "
                          "MAC:0x%02X:%02X:%02X:%02X:%02X:%02X\n",
                         inet_ntoa(IpInfo.dwIP),IpInfo.MAC[0],
                         IpInfo.MAC[1],IpInfo.MAC[2], IpInfo.MAC[3],
                         IpInfo.MAC[4],IpInfo.MAC[5]);
        }
    }
    else
        NKDbgPrintfW(L"Error getting peer address info: %u\n",
                     GetLastError());

    return 0;
}
