<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1515" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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);".</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>When I go back to v3.0 I get the previous
condition.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thank you for any help you can give.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Here is the relevant code:-</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>/////////////////////////////////////////////////////////////////////////////<BR>//
pfx is defined in the class header file</FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2>
<DIV>pcap_if_t
*d;<BR>char
mac[6];<BR>unsigned char
*packet;
// this is the
pointer<BR>char
apacket[MAXBYTES];
// this is the actual
packet<BR>int
NewCardPending;<BR>char
errbuf[PCAP_ERRBUF_SIZE+1];<BR>char
MACaddr[6];<BR><BR>int
pfx/**/MainProgram(void)
// from the start button to here<BR>{ <BR>
pcap_if_t *alldevs;<BR>
char
*mac_ptr;
// Pointer to returned MAC address<BR>
char mac2[6];<BR>
ADAPTER *adap;<BR>
BOOL bummer;<BR>
FILE *fp;<BR>
char check[128];</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> /* Ethernet Initialization */<BR> fp = fopen("MACADDR.INI",
"r");</DIV>
<DIV> </DIV>
<DIV> if (fp == NULL)<BR> {<BR>
m_Message.SetWindowText(CString("No MAC File"));<BR> return
-1;<BR> }</DIV>
<DIV> </DIV>
<DIV> fscanf(fp, "%s %x %x %x %x %x
%x",<BR>
check,<BR>
&mac[0],
// mac address of
adapter<BR>
&mac[1],
// get from
file<BR>
&mac[2],<BR>
&mac[3],<BR>
&mac[4],<BR>
&mac[5]);</DIV>
<DIV> </DIV>
<DIV> if ((check[0] != '*') || (check[1] != 'M') || (check[4] !=
'*'))<BR> {<BR> m_Message.SetWindowText(CString("Bad MAC
File"));<BR> return -1;<BR> }</DIV>
<DIV> </DIV>
<DIV> fclose(fp);</DIV>
<DIV> </DIV>
<DIV> /* Retrieve the ethernet interfaces list */<BR> if
(pcap_findalldevs(&alldevs, errbuf) == -1)<BR> {<BR>
m_Message.SetWindowText(CString("Cannot find Ethernet
Adapters"));<BR>
pcap_freealldevs(alldevs);<BR> return -1;<BR> }</DIV>
<DIV> </DIV>
<DIV> /* Scan the retrieved list */<BR> for(d = alldevs; d != 0; d =
d->next)<BR> {<BR> adap =
PacketOpenAdapter(d->name); // Initialize the pointer</DIV>
<DIV> </DIV>
<DIV> mac_ptr = get_mac_addr(adap);</DIV>
<DIV> </DIV>
<DIV> if (mac_ptr == NULL)<BR>
{<BR> m_Message.SetWindowText(CString("NULL Mac
pointer"));<BR>
pcap_freealldevs(alldevs);<BR> return
-1;<BR> }</DIV>
<DIV> </DIV>
<DIV> memcpy(mac2, mac_ptr, 6);</DIV>
<DIV> </DIV>
<DIV> bummer = false;</DIV>
<DIV> </DIV>
<DIV> for (int i = 0; i < 6;
i++)<BR> if (mac[i] !=
mac2[i])<BR> bummer = true;</DIV>
<DIV> </DIV>
<DIV> if (bummer == false)<BR>
{<BR> m_Message.SetWindowText(CString("Found
Ethernet
Adapter"));<BR> <BR>
pfx/**/DoMainLoop(); //
never return<BR> } <BR>
}
// try next device</DIV>
<DIV> </DIV>
<DIV> pcap_freealldevs(alldevs);<BR>
m_Message.SetWindowText(CString("No Matching Ethernet Adapter"));</DIV>
<DIV> </DIV>
<DIV> return 1;<BR>}<BR></FONT></DIV></BODY></HTML>