¿Podriais decirme porque no me crea bien el checksum?
Código
/* Tama~o del paquete TCP */ unsigned int buffer_size = sizeof(struct iphdr) + sizeof(struct tcphdr); /* Buffer de tama~o suficiente para un paquete TCP */ unsigned char buffer[buffer_size]; /* Cabecera IP */ struct iphdr *ip = (struct iphdr *)buffer; /* Cabecera TCP */ struct tcphdr *tcp = (struct tcphdr *)(buffer + sizeof(struct iphdr)); /* Aqui relleno la cabecera TCP y la de IP */ unsigned short CheckSum(unsigned short *buffer, int size) { unsigned long cksum=0; while(size >1) { cksum+=*buffer++; size -=sizeof(unsigned short); } if(size) cksum += *(unsigned char*)buffer; cksum = (cksum >> 16) + (cksum & 0xffff); cksum += (cksum >>16); return (unsigned short)(~cksum); } tcp->check=CheckSum((unsigned short int*)buffer,buffer_size);
Gracias, un saludo.