[Winpcap-users] Trying a example

Ziara . essence_z at hotmail.com
Tue Nov 27 21:49:50 GMT 2007


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 redchar *mask; // mascara de subredchar *dev; // nombre del dispositivo de redint ret; // codigo de retornochar errbuf[PCAP_ERRBUF_SIZE]; // buffer para mensajes de errorbpf_u_int32 netp; // direcion de red en modo rawbpf_u_int32 maskp; // mascara de red en modo rawstruct 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 subredmask = 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
_________________________________________________________________
Tecnología, moda, motor, viajes,…suscríbete a nuestros boletines para estar a la última
http://newsletters.msn.com/hm/maintenanceeses.asp?L=ES&C=ES&P=WCMaintenance&Brand=WL&RU=http%3a%2f%2fmail.live.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20071127/74cb90f5/attachment.htm


More information about the Winpcap-users mailing list