I found one more way to get MAC and IP addresses.  I
used this method to get IP amd MAC.  A correspondence
between pcap devices is there because both(pcap lib
and the method below) output devices in the same
order.

http://codeguru.earthweb.com/network/ViewNIC.html

Nitesh

--- Nitesh Gupta <[EMAIL PROTECTED]> wrote:
> Thanks to all who helped me.  I will arrange SDK.
> 
> Nitesh
> 
> --- Gordon Tyler <[EMAIL PROTECTED]> wrote:
> > Specifically, the Microsoft Platform SDK.
> Installing
> > Visual Studio is not
> > sufficient, you must install the MS Platform SDK
> as
> > well.
> > 
> > ----- Original Message -----
> > From: "Murugappan Viswanath"
> > <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, August 19, 2002 12:17 AM
> > Subject: RE: [WinPcap-users] no one 2 help: MAC
> and
> > IP
> > 
> > 
> > > its there as a part of Microsoft SDK
> > >
> > > M.Viswanath
> > > i labs
> > > 0606 & 0608, Tidel Park, Chennai 600 113.
> > > * 2540220 Ext.2006
> > > * MOBILE : 9840066012
> > > http://www.i-labs.ws
> > >
> > >
> > > -----Original Message-----
> > > From: Nitesh Gupta [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, August 19, 2002 9:40 AM
> > > To: [EMAIL PROTECTED];
> > [EMAIL PROTECTED]
> > > Subject: Re: [WinPcap-users] no one 2 help: MAC
> > and IP
> > >
> > >
> > > where can I find IPHlpApi.h and DLL
> > >
> > > Thanks,
> > > Nitesh
> > >
> > > --- nergim <[EMAIL PROTECTED]> wrote:
> > > > Ok, good luck
> > > >
> > > >  #include <Packet32.h>
> > > >  #include <IPHlpApi.h>
> > > >
> > > >  typedef struct {
> > > >   char AdapterName[MAX_ADAPTER_NAME_LENGTH +
> 4];
> > > >   char
> > Description[MAX_ADAPTER_DESCRIPTION_LENGTH +
> > > > 4];
> > > >   char Mac[15];
> > > >   char ip_addr[17];
> > > >   char protocol[32];
> > > >   IP_ADDR_STRING addresses;
> > > >   LPADAPTER LPA;
> > > >   NetType nett;
> > > >   struct bpf_stat stats;
> > > >   char *buffer; // Packet buffer
> > > >   LPPACKET lpp;
> > > >   HANDLE hthread;
> > > >   int processed;
> > > >   int terminate;
> > > >   int fragc;
> > > >  } e_adapter;
> > > >  typedef struct {
> > > >   int AdapterCount;
> > > >   e_adapter adapters[1];
> > > >  } e_adapters;
> > > > e_adapters *GetAdapters(void) {
> > > >  int     i;
> > > >  ULONG    ulOutBufLen;
> > > >  DWORD    dwRetVal;
> > > >  int     AdapterCount = 0;
> > > >  e_adapters   *adapters = NULL;
> > > >  FIXED_INFO   *FixedInfo;
> > > >  PIP_ADAPTER_INFO pip, pIPAda;
> > > >  PIP_ADDR_STRING  adr, adr2;
> > > >  FixedInfo = (FIXED_INFO *) GlobalAlloc( GPTR,
> > > > sizeof( FIXED_INFO ) );
> > > >  ulOutBufLen = sizeof( FIXED_INFO );
> > > >
> > > >  if( ERROR_BUFFER_OVERFLOW ==
> GetNetworkParams(
> > > > FixedInfo, &ulOutBufLen ) )
> > > > {
> > > >   GlobalFree( FixedInfo );
> > > >   FixedInfo = GlobalAlloc( GPTR, ulOutBufLen
> );
> > > >  }
> > > >  if ( dwRetVal = GetNetworkParams( FixedInfo,
> > > > &ulOutBufLen ) ) {
> > > >   GlobalFree( FixedInfo );
> > > >   return NULL;
> > > >  }
> > > >  if (GetAdaptersInfo(NULL, &ulOutBufLen) !=
> > > > ERROR_BUFFER_OVERFLOW) {
> > > >   GlobalFree( FixedInfo );
> > > >   return NULL;
> > > >  }
> > > >  pIPAda = calloc(1, ulOutBufLen);
> > > >  if (GetAdaptersInfo(pIPAda, &ulOutBufLen) !=
> > > > ERROR_SUCCESS) {
> > > >   GlobalFree( FixedInfo );
> > > >   free(pIPAda);
> > > >   return NULL;
> > > >  }
> > > >  AdapterCount = 0;
> > > >  for (pip = pIPAda; pip; pip = pip->Next)
> > > >   AdapterCount++;
> > > >
> > > >  adapters = calloc(1,
> > > >   sizeof(e_adapters)
> > > >   +(AdapterCount-1)*sizeof(e_adapter)
> > > >  );
> > > >  if (!adapters)
> > > >   return NULL;
> > > >  adapters->AdapterCount = AdapterCount;
> > > >  for (pip = pIPAda, i=0; i < AdapterCount;
> i++,
> > > > pip=pip->Next) {
> > > >   LPADAPTER LPA;
> > > >   sprintf(
> > > >    adapters->adapters[i].AdapterName,
> > > >    "\\Device\\Packet_%s",
> > > >    pip->AdapterName
> > > >   );
> > > >   adapters->adapters[i].addresses =
> > > > pip->IpAddressList;
> > > >   for (adr = &adapters->adapters[i].addresses;
> > adr;
> > > > ) {
> > > >    if (adr2 = adr->Next) {
> > > >     adr->Next = calloc(sizeof(*adr), 1);
> > > >     memcpy(adr->Next, adr2, sizeof(*adr));
> > > >     adr = adr->Next;
> > > >    } else
> > > >     break;
> > > >   }
> > > >   sprintf(
> > > >    adapters->adapters[i].ip_addr,
> > > >    "%s",
> > > >    pip->IpAddressList.IpAddress.String
> > > >   );
> > > >
> > > >   strcpy(adapters->adapters[i].Description,
> > > > pip->Description);
> > > >   prmacaddr(adapters->adapters[i].Mac,
> > > > pip->Address);
> > > >   LPA = adapters->adapters[i].LPA =
> > > >
> > >
> >
>
PacketOpenAdapter(adapters->adapters[i].AdapterName);
> > > >   if (!LPA || (LPA->hFile ==
> > INVALID_HANDLE_VALUE))
> > > > {
> > > >    adapters->adapters[i].LPA = NULL;
> > > >   }
> > > >   else {
> > > >    PacketSetHwFilter(LPA,
> > > >     NDIS_PACKET_TYPE_PROMISCUOUS
> > > >    );
> > > >    PacketGetNetType(LPA,
> > > > &adapters->adapters[i].nett);
> > > >    strcpy(adapters->adapters[i].protocol,
> > > >     
> > nettypes[adapters->adapters[i].nett.LinkType]);
> > > >   }
> > > >  }
> > > >  GlobalFree( FixedInfo );
> > > >  free(pIPAda);
> > > >  return adapters;
> > > > }
> > > >
> > > >
> > >
> > >
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > HotJobs - Search Thousands of New Jobs
> > > http://www.hotjobs.com
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> HotJobs - Search Thousands of New Jobs
> http://www.hotjobs.com


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

Reply via email to