/* IPv4 header */ typedef struct ip_header{ u_char ver_ihl; // Version (4 bits) + Internet header length (4 bits) u_char tos; // Type of service u_short tlen; // Total length u_short identification; // Identification u_short flags_fo; // Flags (3 bits) + Fragment offset (13 bits) u_char ttl; // Time to live u_char proto; // Protocol u_short crc; // Header checksum ip_address saddr; // Source address ip_address daddr; // Destination address u_int op_pad; // Option + Padding }ip_header; //Packet message unsigned char * sPacketMessage; ////////////////////////// /*--------------------------------------------------------------------------------------- getPacket: Récupère les packets ---------------------------------------------------------------------------------------*/ int getPacket(unsigned char ** packet) { int ret; struct pcap_pkthdr *header; ret = pcap_next_ex(adhandle, &header, packet); if(ret == -1) { printf("Packet capture error!\n"); return -1; } if((ret 1) && (header->caplen header->len)) return header->caplen; return 0; } fonction main() { int packet; ... //Récupération du packet packet_size = getPacket((unsigned char **)&sPacketMessage); modifPacket(); } fonction modifPacket() { //Struct ip_header ip_header *ih; /* retrieve the position of the ip header */ ih = (ip_header *) (sPacketMessage + 14); //length of ethernet header ... //Défini le checksum (crc) a null avt calcul ih->crc = 0x0000; //Calcul du checksum ih->crc = checksum((unsigned short *)&ih, sizeof(struct ip_header)); //Fonction cité dans post précédent }