[Winpcap-users] Missing directed packets in VC++6

Ewan MacPherson ewan.macpherson at frontiernet.net
Mon Aug 29 02:25:02 GMT 2005


I am using VC++ 6.0 to create an app. which uses Winpcap. If I use the app on the computer which contains the VC++ IDE etc. the app works fine. I have win2000.

If, however, I install the app. on another (almost identical) computer on which I installed winpcap, the app. only responds to broadcast packets and not those directed to its MAC address. Yes, I changed the MAC address when installing in the new PC.

All this is using Winpcap v3.0. When I uninstall v3.0 and install v3.1 a different strange thing occurs. In both the PC which "works" and the one which "doesn't work" I get a NULL pointer in "mac_ptr = get_mac_addr(adap);".

When I go back to v3.0 I get the previous condition.

Thank you for any help you can give.

Here is the relevant code:-

/////////////////////////////////////////////////////////////////////////////
// pfx is defined in the class header file

pcap_if_t     *d;
char          mac[6];
unsigned char *packet;                      // this is the pointer
char          apacket[MAXBYTES];            // this is the actual packet
int           NewCardPending;
char          errbuf[PCAP_ERRBUF_SIZE+1];
char          MACaddr[6];

int pfx/**/MainProgram(void)             // from the start button to here
{    
  pcap_if_t     *alldevs;
  char          *mac_ptr;                 // Pointer to returned MAC address
  char          mac2[6];
  ADAPTER       *adap;
  BOOL          bummer;
  FILE          *fp;
  char          check[128];

 
  /* Ethernet Initialization */
  fp = fopen("MACADDR.INI", "r");

  if (fp == NULL)
  {
    m_Message.SetWindowText(CString("No MAC File"));
    return -1;
  }

  fscanf(fp, "%s %x %x %x %x %x %x",
              check,
              &mac[0],                    // mac address of adapter
              &mac[1],                    // get from file
              &mac[2],
              &mac[3],
              &mac[4],
              &mac[5]);

  if ((check[0] != '*') || (check[1] != 'M') || (check[4] != '*'))
  {
    m_Message.SetWindowText(CString("Bad MAC File"));
    return -1;
  }

  fclose(fp);

  /* Retrieve the ethernet interfaces list */
  if (pcap_findalldevs(&alldevs, errbuf) == -1)
  {
    m_Message.SetWindowText(CString("Cannot find Ethernet Adapters"));
    pcap_freealldevs(alldevs);
    return -1;
  }

  /* Scan the retrieved list */
  for(d = alldevs; d != 0; d = d->next)
  {
    adap = PacketOpenAdapter(d->name);    // Initialize the pointer

    mac_ptr = get_mac_addr(adap);

    if (mac_ptr == NULL)
    {
      m_Message.SetWindowText(CString("NULL Mac pointer"));
      pcap_freealldevs(alldevs);
      return -1;
    }

    memcpy(mac2, mac_ptr, 6);

    bummer = false;

    for (int i = 0; i < 6; i++)
      if (mac[i] != mac2[i])
        bummer = true;

    if (bummer == false)
    {
      m_Message.SetWindowText(CString("Found Ethernet Adapter"));
                                        
      pfx/**/DoMainLoop();          // never return
    }  
  }                                 // try next device

  pcap_freealldevs(alldevs);
  m_Message.SetWindowText(CString("No Matching Ethernet Adapter"));

  return 1;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20050828/07d9f4e8/attachment.htm


More information about the Winpcap-users mailing list