From: Olivier J. <oja...@us...> - 2005-12-21 12:10:33
|
Update of /cvsroot/sipp/sipp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9313 Modified Files: Tag: cumulus send_packets.c Log Message: pcapplay: use of libnet structures for better portability. Index: send_packets.c =================================================================== RCS file: /cvsroot/sipp/sipp/Attic/send_packets.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** send_packets.c 20 Dec 2005 16:56:52 -0000 1.1.2.1 --- send_packets.c 21 Dec 2005 12:10:14 -0000 1.1.2.2 *************** *** 111,116 **** u_char errbuf[PCAP_ERRBUF_SIZE]; libnet_ptag_t ip = 0, l4 = 0; ! struct iphdr *ip_hdr = NULL; ! struct udphdr *udp_hdr = NULL; char *payload; int payload_s; --- 111,116 ---- u_char errbuf[PCAP_ERRBUF_SIZE]; libnet_ptag_t ip = 0, l4 = 0; ! struct libnet_ipv4_hdr *ip_hdr = NULL; ! struct libnet_udp_hdr *udp_hdr = NULL; char *payload; int payload_s; *************** *** 138,150 **** pktlen = (u_long) pkthdr->len; ! ip_hdr = (struct iphdr *) (pktdata + LIBNET_ETH_H); ! ip_len = 4 * ip_hdr->ihl; ! if (ip_hdr->protocol == IPPROTO_UDP) { ! udp_hdr = (struct udphdr *) (pktdata + LIBNET_ETH_H + ip_len); payload = ((char *) udp_hdr + sizeof (*udp_hdr)); payload_s = pktlen - ip_len - sizeof (*udp_hdr) - LIBNET_ETH_H; ! port_diff = ntohs (udp_hdr->dest) - play_args->base; l4 = libnet_build_udp (play_args->from.sin_port + port_diff, --- 138,150 ---- pktlen = (u_long) pkthdr->len; ! ip_hdr = (struct libnet_ipv4_hdr *) (pktdata + LIBNET_ETH_H); ! ip_len = 4 * ip_hdr->ip_hl; ! if (ip_hdr->ip_p == IPPROTO_UDP) { ! udp_hdr = (struct libnet_udp_hdr *) (pktdata + LIBNET_ETH_H + ip_len); payload = ((char *) udp_hdr + sizeof (*udp_hdr)); payload_s = pktlen - ip_len - sizeof (*udp_hdr) - LIBNET_ETH_H; ! port_diff = ntohs (udp_hdr->uh_dport) - play_args->base; l4 = libnet_build_udp (play_args->from.sin_port + port_diff, *************** *** 160,164 **** assert (ip != -1); } ! else if (ip_hdr->protocol == IPPROTO_TCP) { } --- 160,164 ---- assert (ip != -1); } ! else if (ip_hdr->ip_p == IPPROTO_TCP) { } |