--- tcpnice.c.orig 2009-09-08 23:51:45.000000000 +0200
+++ tcpnice.c 2009-09-09 00:02:31.000000000 +0200
-send_tcp_window_advertisement(int sock, struct libnet_ip_hdr *ip,
+send_tcp_window_advertisement(libnet_t *l, struct libnet_ipv4_hdr *ip,
struct libnet_tcp_hdr *tcp)
- ip->ip_len = htons(IP_H + TCP_H);
- ip->ip_id = libnet_get_prand(PRu16);
- memcpy(buf, (u_char *)ip, IP_H);
+ ip->ip_len = htons(LIBNET_IPV4_H + LIBNET_TCP_H);
+ ip->ip_id = libnet_get_prand(LIBNET_PRu16);
+ memcpy(buf, (u_char *)ip, LIBNET_IPV4_H);
tcp->th_win = htons(MIN_WIN);
- memcpy(buf + IP_H, (u_char *)tcp, TCP_H);
+ memcpy(buf + LIBNET_IPV4_H, (u_char *)tcp, LIBNET_TCP_H);
- libnet_do_checksum(buf, IPPROTO_TCP, TCP_H);
+ libnet_do_checksum(l, buf, IPPROTO_TCP, LIBNET_TCP_H);
+ len = LIBNET_IPV4_H + LIBNET_TCP_H;
- if (libnet_write_ip(sock, buf, len) != len)
+ if (libnet_write_raw_ipv4(l, buf, len) != len)
fprintf(stderr, "%s:%d > %s:%d: . ack %lu win %d\n",
- libnet_host_lookup(ip->ip_src.s_addr, 0), ntohs(tcp->th_sport),
- libnet_host_lookup(ip->ip_dst.s_addr, 0), ntohs(tcp->th_dport),
+ libnet_addr2name4(ip->ip_src.s_addr, 0), ntohs(tcp->th_sport),
+ libnet_addr2name4(ip->ip_dst.s_addr, 0), ntohs(tcp->th_dport),
-send_icmp_source_quench(int sock, struct libnet_ip_hdr *ip)
+send_icmp_source_quench(libnet_t *l, struct libnet_ipv4_hdr *ip)
- struct libnet_icmp_hdr *icmp;
+ struct libnet_icmpv4_hdr *icmp;
len = (ip->ip_hl * 4) + 8;
- libnet_build_ip(ICMP_ECHO_H + len, 0, libnet_get_prand(PRu16),
- 0, 64, IPPROTO_ICMP, ip->ip_dst.s_addr,
- ip->ip_src.s_addr, NULL, 0, buf);
- icmp = (struct libnet_icmp_hdr *)(buf + IP_H);
+ icmp = (struct libnet_icmpv4_hdr *)(buf + LIBNET_IPV4_H);
icmp->icmp_type = ICMP_SOURCEQUENCH;
- memcpy((u_char *)icmp + ICMP_ECHO_H, (u_char *)ip, len);
+ memcpy((u_char *)icmp + LIBNET_ICMPV4_ECHO_H, (u_char *)ip, len);