void set_ip_header(void *ip_header, int address_family, u16 ip_bytes, enum direction_t direction, enum ip_ecn_t ecn, u8 protocol) { if (address_family == AF_INET) set_ipv4_header(ip_header, ip_bytes, direction, ecn, protocol); else if (address_family == AF_INET6) set_ipv6_header(ip_header, ip_bytes, direction, ecn, protocol); else assert(!"bad ip_version in config"); }
void set_packet_ip_header(struct packet *packet, int address_family, u16 ip_bytes, enum direction_t direction, enum ip_ecn_t ecn, u8 protocol) { if (address_family == AF_INET) { struct ipv4 *ipv4 = (struct ipv4 *) packet->buffer; packet->ipv4 = ipv4; assert(packet->ipv6 == NULL); set_ipv4_header(ipv4, ip_bytes, direction, ecn, protocol); } else if (address_family == AF_INET6) { struct ipv6 *ipv6 = (struct ipv6 *) packet->buffer; packet->ipv6 = ipv6; assert(packet->ipv4 == NULL); set_ipv6_header(ipv6, ip_bytes, direction, ecn, protocol); } else { assert(!"bad ip_version in config"); } }
static bool build_raw(t_thread_handler *thread_handler, int port, int raw_len, char *host, char *scan, int id) { ft_memset(thread_handler->buffer_raw, 0, raw_len); return (set_ipv4_header(thread_handler, raw_len, host, IPPROTO_TCP) && set_tcp_header(thread_handler, port, raw_len, scan, id)); }