HACK HiSPANO
Volver Atras   HACK HiSPANO > PROGRAMACION > PROGRAMACION DESKTOP
Actualizar esta página #include <netinet/udp.h> Donde estas ¿?

Respuesta
 
LinkBack Herramientas Modos de Vista
  (#1) Antiguo
Avanzado
 
Posts: 374
Fecha de Ingreso: Oct 2010
Unhappy #include <netinet/udp.h> Donde estas ¿? - 16-04-2011, 00:20


Código:
printf(" %i :%g",iphead->saddr,udphead->sport);
printf("%i  %g\n", iphead->daddr,udphead->dport);

Código:
/root/C/sniffer.c:50: error: 'struct udphdr' has no member named 'sport'
/root/C/sniffer.c:51: error: 'struct udphdr' has no member named 'dport'
Segun el copilador la estructura no contiene nada, vamos que me los esta tocando pero bien, a ver si me podeis echar una manita .


A las librerias:

#include <linux/if_ether.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <netinet/ip.h>
#include <netinet/udp.h>


Bendo mi cuelpo, xicaz interezadaz mnanden priBado, no ravoz ni zorpesas.
Responder con Cita
  (#2) Antiguo
Avanzado
 
Posts: 442
Fecha de Ingreso: Feb 2011
16-04-2011, 00:28


Código:
struct udphdr {
        __be16  source;
        __be16  dest;
        __be16  len;
        __sum16 check;
};


Ezine HH mas de 5.000.000.000 descargas!!!!!!!!!
Responder con Cita
  (#3) Antiguo
Avanzado
 
Posts: 374
Fecha de Ingreso: Oct 2010
16-04-2011, 18:46


Cita:
#include <netinet/in.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>

#define MAX 4025




main(){


int pid;

pid=fork();

if(pid==0){

char buffer[MAX];
int sock;
int bytes_read;

sock = socket(PF_INET,SOCK_RAW,IPPROTO_UDP);

struct iphdr *iph;
struct udphdr *udph;


iph = (struct iphdr *)buffer;

do{

bytes_read=recv(sock,buffer,MAX, 0);


if(iph->protocol==IPPROTO_UDP){

udph=(struct udphdr*)(buffer+sizeof(struct iphdr));

printf("Origen UDP %s :%d\n",inet_ntoa(iph->saddr),ntohs(udph->source));
printf("Destino UDP %s :%d\n", inet_ntoa(iph->daddr),ntohs(udph->dest));

udph==NULL;

iph==NULL;

buffer==NULL;
}

}
while (bytes_read >0);

}
else
{


//fcntl(sock,F_SETFL,O_NONBLOCK);
//memset( &address, 0, sizeof( address ) );
//address.sa_family = AF_INET;
//strncpy( address.sa_data, "wlan0", sizeof(address.sa_data) );
char buffer2[MAX];
int sock2;
int bytes_read2;

sock2 = socket(PF_INET,SOCK_RAW,IPPROTO_TCP);

struct iphdr *iph2;
struct tcphdr *tcph;

iph2 = (struct iphdr *)buffer2;


do{

bytes_read2=recv(sock2,buffer2,MAX,0);

if(iph2->protocol==IPPROTO_TCP){

tcph=(struct tcphdr*)(buffer2+sizeof(struct iphdr));

printf("Origen TCP %s :%d\n",inet_ntoa(iph2->saddr), ntohs(tcph->source));
printf("Numero de secuencia: %d ACK: %i\n ",ntohs(tcph->seq),ntohs(tcph->ack_seq));
printf("Destino TCP %s :%d\n", inet_ntoa(iph2->daddr), ntohs(tcph->dest));

tcph==NULL;

iph2==NULL;

buffer2==NULL;




}
}
while (bytes_read2> 0);

}

}
Ok gracias, parace que al referencia que yo tenia no era la correcta xd.


Bendo mi cuelpo, xicaz interezadaz mnanden priBado, no ravoz ni zorpesas.
Responder con Cita
  (#4) Antiguo
Avanzado
 
Posts: 442
Fecha de Ingreso: Feb 2011
16-04-2011, 18:53


La próxima vez que te pase algo así no haces nada mejor que comprobar el .h para quitarte de dudas


Ezine HH mas de 5.000.000.000 descargas!!!!!!!!!
Responder con Cita
  (#5) Antiguo
Avanzado
 
Posts: 374
Fecha de Ingreso: Oct 2010
16-04-2011, 19:03


Cita:
La próxima vez que te pase algo así no haces nada mejor que comprobar el .h para quitarte de dudas
ok ok ok,es que muchas veces me ciego xd.


Bendo mi cuelpo, xicaz interezadaz mnanden priBado, no ravoz ni zorpesas.
Responder con Cita
Respuesta

Bookmarks

Herramientas
Modos de Vista

Normas
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies son On
[IMG] código esta On
Código HTML esta Off
Trackbacks are On
Pingbacks are On
Refbacks are On




Alojado en Hacheté Diseños Web

Powered by vB 3
Copyright © 1999-2013 HACK HiSPANO