ndisuio question

From: Boyd D. Mills (BMills_at_VCIControls.ca)
Date: 10/28/04


Date: Thu, 28 Oct 2004 11:16:54 -0400

The following is the bulk of a sample task used to access ndisuio in Windows
CE 4.1 CEPC platform.
I thought it odd that ndisuio by default uses Ethernet frame 0x8001 - odd in
that this is not a "well known" frame type. I change it to 0x800 instead -
ip frames for the purpose of testing.
Everything reports success except the task never returns from the ReadFile.
There is plenty ip traffic on the network!
If I pass a bogus NIC name to IOCTL_NDISUIO_OPEN_DEVICE I do get an error
message.
Am I missing something? Does something else have to be set before issuing a
ReadFile?

/Boyd
============
USHORT usNewType = 0x800;
HANDLE hLAN = CreateFile( L"UIO1:", GENERIC_READ|GENERIC_WRITE,
      FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
  INVALID_HANDLE_VALUE );
 if ( hLAN != INVALID_HANDLE_VALUE )
 {

   DeviceIoControl( hLAN, IOCTL_NDISUIO_QUERY_BINDING,
     pQueryBinding, sizeof(NDISUIO_QUERY_BINDING),
     NULL, 1024, &dwReturnedBytes, NULL);

   memcpy(tcDevName, &Buf[pQueryBinding->DeviceNameOffset ],
pQueryBinding->DeviceNameLength );
   if ( ! DeviceIoControl( hLAN, IOCTL_NDISUIO_OPEN_DEVICE,
    tcDevName, wcslen(tcDevName) * sizeof(TCHAR),
                NULL, 0, &dwReturnedBytes, NULL) )
   {
    printf( "deviceiocontrol failed OPEN_DEVICE %d\n", GetLastError());
   }
   else if ( ! DeviceIoControl( hLAN, IOCTL_NDISUIO_SET_ETHER_TYPE,
             &usNewType, sizeof(usNewType), NULL, 0, &dwReturnedBytes,
NULL) )
   {
    printf( "deviceiocontrol failed SET_ETHER_TYPE %d\n", GetLastError());
   }
   else
   {
    while ( icount++ < 12 )
    {
     if ( ReadFile( hLAN, t, 2048, &dwIn, NULL ) && dwIn )
     {
      printf( "0x%x ", t[0] );
     }
     else Sleep( 5000 );
    }
    printf("\n" );
   }
  CloseHandle( hLAN );
 }