[Winpcap-users] Detecting TCP/IP for a NIC

Peter Hegel peter.hegel at doli.de
Wed Jan 30 12:36:00 GMT 2008


Thank you very much!
The IP helper API seems realy to help. The code snippet attached solved my problem.

static bool hasTCPIP( char *pAdapterName )
{
  PIP_ADAPTER_INFO pAdapterInfo = NULL;
  PIP_ADAPTER_INFO pAdapter = NULL;
  DWORD dwRc;
  bool bRc = false;

  // drop adapter name prefix ("\device\NPF_")
  while( pAdapterName )
    if( *pAdapterName != '{' )
      pAdapterName++;
    else
      break;

  // get the necessary size into the ulOutBufLen variable
  ULONG ulOutBufLen = 0;
  dwRc = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen );
  assert( dwRc == ERROR_BUFFER_OVERFLOW );

  // read adapter info
  pAdapterInfo = (IP_ADAPTER_INFO *)GlobalAlloc( GPTR, ulOutBufLen );
  assert( pAdapterInfo != NULL );
  dwRc = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen );
  assert( dwRc == NO_ERROR );

  // scan adapter list
  for( pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next )
    if( strcmp( pAdapterName, pAdapter->AdapterName ) == 0 ) {
      bRc = true;
      break;
    }

  GlobalFree( pAdapterInfo );
  return bRc;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20080130/f1593425/attachment.htm


More information about the Winpcap-users mailing list