79172599

Date: 2024-11-09 11:09:31
Score: 0.5
Natty:
Report link

    // Fill in IP header
    iph->ip_v = 4; // IPv4
    iph->ip_hl = IP_HEADER_SIZE / 4; // Header length in 32-bit words
    iph->ip_tos = 0; // Default Type of Service
    iph->ip_len = htons(IP_HEADER_SIZE + TCP_HEADER_SIZE); // Total length of the packet
    iph->ip_id = 0; // Identification (random value or 0)
    iph->ip_off = 0; // Fragment offset
    iph->ip_ttl = 255; // Time to Live
    iph->ip_p = IPPROTO_TCP; // Protocol (TCP)
    iph->ip_src.s_addr = src.sin_addr.s_addr; // Source IP address
    iph->ip_dst.s_addr = dst.sin_addr.s_addr; // Destination IP address

    // Calculate IP header checksum
    calculate_ip_checksum(iph);

that's how i build the IP headers.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: נהוראי יפרח