[Winpcap-users] RE: Winpcap-users Digest, Vol 32, Issue 16

Egas António Silva Pacheco Gomes Fino egas.fino at empordef-ti.pt
Wed Nov 28 21:53:19 GMT 2007


wert


De: winpcap-users-request at winpcap.org
Enviada: qua 28-11-2007 21:29
Para: winpcap-users at winpcap.org
Assunto: Winpcap-users Digest, Vol 32, Issue 16


Send Winpcap-users mailing list submissions to
	winpcap-users at winpcap.org

To subscribe or unsubscribe via the World Wide Web, visit
	https://www.winpcap.org/mailman/listinfo/winpcap-users
or, via email, send a message with subject or body 'help' to
	winpcap-users-request at winpcap.org

You can reach the person managing the list at
	winpcap-users-owner at winpcap.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Winpcap-users digest..."


Today's Topics:

   1. Re: unexpected warning (Gianluca Varenni)
   2. Re: Trying a example (Gianluca Varenni)
   3. Re: Trying a example (john mcnicholas)


----------------------------------------------------------------------

Message: 1
Date: Wed, 28 Nov 2007 09:37:28 -0800
From: "Gianluca Varenni" <gianluca.varenni at cacetech.com>
Subject: Re: [Winpcap-users] unexpected warning
To: <winpcap-users at winpcap.org>
Message-ID: <009601c831e5$59199620$1a4da8c0 at NELSON2>
Content-Type: text/plain; charset="utf-8"

That line doesn't have anything to do with WinPcap (that file is part of either the Microsoft Platform SDK or the Builder C++ header files). I'm actually quite surprised that a system include file spits out such a warning.

Regarding the issue of the application opening and closing immediately, have you debugged it? If you read the code, it needs a trace file name as first command line parameter. And then the sample reads the packets from the trace file and prints the length and timestamp of each packet in the file.

Have a nice day
GV

  ----- Original Message ----- 
  From: Ziara . 
  To: winpcap-users at winpcap.org 
  Sent: Monday, November 26, 2007 6:56 AM
  Subject: RE: [Winpcap-users] unexpected warning


  Hi again! yes, I read the winpcap FAQ and in this says that I have to convert wpcap.lib and packet.lib from coff format to omf format to use in Builder c++, and I think I obtain this.
   
  But when I compile a example, It appear this warning, and the content of line 786 in wspiapi.h is:
   
  if ((iFlags & NI_NOFQDN) && (pc = strchr(pszNode, '.')))
   
  With this warning I can build the .exe file I don't know very well what's the meaning of the example, because when a run this .exe file, a ms-dos windows is opened and in a second it's closed, and I don't know what's is happened.
   
  this is the example:
   
  void dispatcher_handler(u_char *, const struct pcap_pkthdr *, const u_char *);
  main(int argc, char **argv)
  {
   pcap_t *fp;
   char errbuf[PCAP_ERRBUF_SIZE];
   
   if(argc != 2)
   {
    printf("usage: %s filename", argv[0]);
    return -1;
   }
   
   /* Open the capture file */
   if ((fp = pcap_open_offline(argv[1],   // name of the device
         errbuf     // error buffer
         )) == NULL)
   {
    fprintf(stderr,"\nUnable to open the file %s.\n", argv[1]);
    return -1;
   }
   /* read and dispatch packets until EOF is reached */
   pcap_loop(fp, 0, dispatcher_handler, NULL);
   pcap_close(fp);
    system("pause");

   return 0;
  }
   
  void dispatcher_handler(u_char *temp1,
        const struct pcap_pkthdr *header,
        const u_char *pkt_data)
  {
   u_int i=0;
   /* print pkt timestamp and pkt len */
   printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len);
   /* Print the packet */
   for (i=1; (i < header->caplen + 1 ) ; i++)
   {
    printf("%.2x ", pkt_data[i-1]);
    if ( (i % LINE_LEN) == 0) printf("\n");
   }
   printf("\n\n");
  }
   
   


   


----------------------------------------------------------------------------
    From: gianluca.varenni at cacetech.com
    To: winpcap-users at winpcap.org
    Subject: Re: RE:[Winpcap-users] unexpected warning
    Date: Fri, 23 Nov 2007 09:00:57 -0800


    The WinPcap developer's pack doesn't official support the Borland C++ environment, so I'm just trying to guess what's going on.

    What's the content of line 786 in wspiapi.h? That header file is a system include file (i.e. it doesn't come with WinPcap), so it's quite weird that the compiler spits out a warning on that file.

    Have a nice day
    GV


      ----- Original Message ----- 
      From: nechoe_cn at sina.com 
      To: winpcap-users at winpcap.org 
      Sent: Thursday, November 22, 2007 4:34 PM
      Subject: RE:[Winpcap-users] unexpected warning



      ----- Original Message -----
      From:Ziara . 
      To:
      Subject:[Winpcap-users] unexpected warning
      Date:07-11-23 02:15:39

      Hello, I'm now in this.. I'm using winpcap with builder c++ and when I build one example, it appear one warning said: 
       
      (C++ Warning) wspiapi.h(786): W8060 Possibly incorrect assignment
       
      and, I don't know why??
       
       


--------------------------------------------------------------------------
      Express yourself instantly with MSN Messenger! MSN Messenger _______________________________________________ Winpcap-users mailing list Winpcap-users at winpcap.org https://www.winpcap.org/mailman/listinfo/winpcap-users 

       
      sorry,i did not study builder c++~


      -------------------------------------------------------------------
      ????? ??????? 25???( http://d1.sina.com.cn/sina/limeng3/mail_zhuiyu/2007/mail_zhuiyu_20071112.html )

      ===================================================================
      ???????,???????,?????????!( http://bar.sina.com.cn/channel.php?chid=1 ) 


--------------------------------------------------------------------------


      _______________________________________________
      Winpcap-users mailing list
      Winpcap-users at winpcap.org
      https://www.winpcap.org/mailman/listinfo/winpcap-users




------------------------------------------------------------------------------
  Tecnología, moda, motor, viajes,.suscríbete a nuestros boletines para estar a la última MSN Newsletters 


------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20071128/78b58c84/attachment-0001.htm

------------------------------

Message: 2
Date: Wed, 28 Nov 2007 09:40:28 -0800
From: "Gianluca Varenni" <gianluca.varenni at cacetech.com>
Subject: Re: [Winpcap-users] Trying a example
To: <winpcap-users at winpcap.org>
Message-ID: <00c501c831e5$c40b3600$1a4da8c0 at NELSON2>
Content-Type: text/plain; charset="windows-1252"

I suggest you to take out of the samples from the winpcap developer's pack.

You are using pcap_lookupdev, which is obsolete (and on Windows it doesn't have the same semantics of pcap_lookupdev undex Unix).

Please use pcap_findalldevs to get the list of adapters.

Have a nice day
GV

  ----- Original Message ----- 
  From: Ziara . 
  To: winpcap 
  Sent: Tuesday, November 27, 2007 1:49 PM
  Subject: [Winpcap-users] Trying a example


  Hi! I'm trying other example in Builder c++, someone can tell me why this code doesn't work? what is it wrong?
   
  int main(int argc, char **argv)
  {
  char *net; // direccion de red
  char *mask; // mascara de subred
  char *dev; // nombre del dispositivo de red
  int ret; // codigo de retorno
  char errbuf[PCAP_ERRBUF_SIZE]; // buffer para mensajes de error
  bpf_u_int32 netp; // direcion de red en modo raw
  bpf_u_int32 maskp; // mascara de red en modo raw
  struct in_addr addr;
  if ((dev = pcap_lookupdev(errbuf))== NULL) //conseguimos la primera interfaz libre
  {
          printf("ERROR %s\n",errbuf);
          exit(-1);
  }
  printf("Nombre del dispositivo: %s\n",dev); //mostramos el nombre del dispositivo
  if ((ret = pcap_lookupnet(dev,&netp,&maskp,errbuf))==-1) //consultamos las direccion de red y las mascara
  {
          printf("ERROR %s\n",errbuf);
          exit(-1);
  }
  addr.s_addr = netp; //Traducimos la direccion de red a algo legible
  if ((net = inet_ntoa(addr))==NULL)
  {
          perror("inet_ntoa");
          exit(-1);
  }
  printf("Direccion de Red: %s\n",net);
  addr.s_addr = maskp; //Idem para la mascara de subred
  mask = inet_ntoa(addr);
  if ((net=inet_ntoa(addr))==NULL)
  {
          perror("inet_ntoa");
          exit(-1);
  }
  printf("Mascara de Red: %s\n",mask);
  return 0;
  }
   
  when and build and run the .exe, only appear:
   
  Nombre del dispostivo: /
  Direccion de Red: 0.0.0.0
  Mascara de Red: 0.0.0.0
   
  thanks


------------------------------------------------------------------------------
  Tecnologa, moda, motor, viajes,suscrbete a nuestros boletines para estar a la ltima MSN Newsletters 


------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20071128/2417042b/attachment-0001.htm

------------------------------

Message: 3
Date: Wed, 28 Nov 2007 15:52:38 -0500
From: "john mcnicholas" <jomcn1 at gmail.com>
Subject: Re: [Winpcap-users] Trying a example
To: winpcap-users at winpcap.org
Message-ID:
	<4bf540cf0711281252i30b0ed9doc1cf322ef72fdefe at mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

Ziara,

Couple of points/suggs:

- I'd follow GV's advice and look at the samples

- I believe the obsolete api you used returned a unicode string ; i.e. every
other byte was 0
  hence, the single character for the name.  Plus there is a good chance it
might return
  "Generic Dialup Adapter" which wouldn't have been much use;
   In short, pcap_findalldevs is a better way to go.

- Note: you were also  using a WinSock api and although it wasn't necessary
for this
  app/api, it is probably a good idea to initialize WinSock via WSAStartup()
and WSACleanup.

good luck.

John

On Nov 28, 2007 12:40 PM, Gianluca Varenni <gianluca.varenni at cacetech.com>
wrote:

>  I suggest you to take out of the samples from the winpcap developer's
> pack.
>
> You are using pcap_lookupdev, which is obsolete (and on Windows it doesn't
> have the same semantics of pcap_lookupdev undex Unix).
>
> Please use pcap_findalldevs to get the list of adapters.
>
> Have a nice day
> GV
>
>
> ----- Original Message -----
> *From:* Ziara . <essence_z at hotmail.com>
> *To:* winpcap <winpcap-users at winpcap.org>
> *Sent:* Tuesday, November 27, 2007 1:49 PM
> *Subject:* [Winpcap-users] Trying a example
>
> Hi! I'm trying other example in Builder c++, someone can tell me why this
> code doesn't work? what is it wrong?
>
> int main(int argc, char **argv)
> {
> char *net; // direccion de red
> char *mask; // mascara de subred
> char *dev; // nombre del dispositivo de red
> int ret; // codigo de retorno
> char errbuf[PCAP_ERRBUF_SIZE]; // buffer para mensajes de error
> bpf_u_int32 netp; // direcion de red en modo raw
> bpf_u_int32 maskp; // mascara de red en modo raw
> struct in_addr addr;
> if ((dev = pcap_lookupdev(errbuf))== NULL) //conseguimos la primera
> interfaz libre
> {
>         printf("ERROR %s\n",errbuf);
>         exit(-1);
> }
> printf("Nombre del dispositivo: %s\n",dev); //mostramos el nombre del
> dispositivo
> if ((ret = pcap_lookupnet(dev,&netp,&maskp,errbuf))==-1) //consultamos las
> direccion de red y las mascara
> {
>         printf("ERROR %s\n",errbuf);
>         exit(-1);
> }
> addr.s_addr = netp; //Traducimos la direccion de red a algo legible
> if ((net = inet_ntoa(addr))==NULL)
> {
>         perror("inet_ntoa");
>         exit(-1);
> }
> printf("Direccion de Red: %s\n",net);
> addr.s_addr = maskp; //Idem para la mascara de subred
> mask = inet_ntoa(addr);
> if ((net=inet_ntoa(addr))==NULL)
> {
>         perror("inet_ntoa");
>         exit(-1);
> }
> printf("Mascara de Red: %s\n",mask);
> return 0;
> }
>
> when and build and run the .exe, only appear:
>
> Nombre del dispostivo: /
> Direccion de Red: 0.0.0.0
> Mascara de Red: 0.0.0.0
>
> thanks
>
> ------------------------------
> Tecnologa, moda, motor, viajes,suscrbete a nuestros boletines para
> estar a la ltima MSN Newsletters<http://newsletters.msn.com/hm/maintenanceeses.asp?L=ES&C=ES&P=WCMaintenance&Brand=WL&RU=http%3a%2f%2fmail.live.com>
>
> ------------------------------
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20071128/440f7000/attachment.htm

------------------------------

_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users


End of Winpcap-users Digest, Vol 32, Issue 16
*********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20071128/4812b2d6/attachment-0001.htm


More information about the Winpcap-users mailing list