Deleted Added
full compact
resend.c (31183) resend.c (53024)
1/*
1/*
2 * resend.c (C) 1995-1997 Darren Reed
2 * resend.c (C) 1995-1998 Darren Reed
3 *
4 * This was written to test what size TCP fragments would get through
5 * various TCP/IP packet filters, as used in IP firewalls. In certain
6 * conditions, enough of the TCP header is missing for unpredictable
7 * results unless the filter is aware that this can happen.
8 *
9 * Redistribution and use in source and binary forms are permitted
10 * provided that this notice is preserved and due credit is given
11 * to the original author and the contributors.
12 */
13#if !defined(lint)
14static const char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed";
3 *
4 * This was written to test what size TCP fragments would get through
5 * various TCP/IP packet filters, as used in IP firewalls. In certain
6 * conditions, enough of the TCP header is missing for unpredictable
7 * results unless the filter is aware that this can happen.
8 *
9 * Redistribution and use in source and binary forms are permitted
10 * provided that this notice is preserved and due credit is given
11 * to the original author and the contributors.
12 */
13#if !defined(lint)
14static const char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed";
15static const char rcsid[] = "@(#)$Id: resend.c,v 2.0.2.12 1997/10/23 11:42:46 darrenr Exp $";
15static const char rcsid[] = "@(#)$Id: resend.c,v 2.1 1999/08/04 17:31:12 darrenr Exp $";
16#endif
17#include <stdio.h>
18#include <netdb.h>
19#include <string.h>
20#include <stdlib.h>
21#include <unistd.h>
22#include <sys/types.h>
23#include <sys/time.h>

--- 12 unchanged lines hidden (view full) ---

36# if __FreeBSD_version >= 300000
37# include <net/if_var.h>
38# endif
39#endif
40#include "ipsend.h"
41
42extern int opts;
43
16#endif
17#include <stdio.h>
18#include <netdb.h>
19#include <string.h>
20#include <stdlib.h>
21#include <unistd.h>
22#include <sys/types.h>
23#include <sys/time.h>

--- 12 unchanged lines hidden (view full) ---

36# if __FreeBSD_version >= 300000
37# include <net/if_var.h>
38# endif
39#endif
40#include "ipsend.h"
41
42extern int opts;
43
44static u_char buf[65536]; /* 1 big packet */
44static u_char pbuf[65536]; /* 1 big packet */
45void printpacket __P((ip_t *));
46
47
48void printpacket(ip)
49ip_t *ip;
50{
51 tcphdr_t *t;
52 int i, j;

--- 37 unchanged lines hidden (view full) ---

90 if (datain)
91 fd = (*r->r_open)(datain);
92 else
93 fd = (*r->r_open)("-");
94
95 if (fd < 0)
96 exit(-1);
97
45void printpacket __P((ip_t *));
46
47
48void printpacket(ip)
49ip_t *ip;
50{
51 tcphdr_t *t;
52 int i, j;

--- 37 unchanged lines hidden (view full) ---

90 if (datain)
91 fd = (*r->r_open)(datain);
92 else
93 fd = (*r->r_open)("-");
94
95 if (fd < 0)
96 exit(-1);
97
98 ip = (struct ip *)buf;
98 ip = (struct ip *)pbuf;
99 eh = (ether_header_t *)malloc(sizeof(*eh));
100
101 bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost));
102 if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1))
103 {
104 perror("arp");
105 return -2;
106 }
107
99 eh = (ether_header_t *)malloc(sizeof(*eh));
100
101 bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost));
102 if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1))
103 {
104 perror("arp");
105 return -2;
106 }
107
108 while ((i = (*r->r_readip)(buf, sizeof(buf), NULL, NULL)) > 0)
108 while ((i = (*r->r_readip)((char *)pbuf, sizeof(pbuf), NULL, NULL)) > 0)
109 {
110 if (!(opts & OPT_RAW)) {
111 len = ntohs(ip->ip_len);
112 eh = (ether_header_t *)realloc((char *)eh, sizeof(*eh) + len);
113 eh->ether_type = htons((u_short)ETHERTYPE_IP);
114 if (!gwip.s_addr) {
115 if (arp((char *)&gwip,
116 (char *)A_A eh->ether_dhost) == -1) {

--- 5 unchanged lines hidden (view full) ---

122 sizeof(dhost));
123 if (!ip->ip_sum)
124 ip->ip_sum = chksum((u_short *)ip,
125 ip->ip_hl << 2);
126 bcopy(ip, (char *)(eh + 1), len);
127 len += sizeof(*eh);
128 printpacket(ip);
129 } else {
109 {
110 if (!(opts & OPT_RAW)) {
111 len = ntohs(ip->ip_len);
112 eh = (ether_header_t *)realloc((char *)eh, sizeof(*eh) + len);
113 eh->ether_type = htons((u_short)ETHERTYPE_IP);
114 if (!gwip.s_addr) {
115 if (arp((char *)&gwip,
116 (char *)A_A eh->ether_dhost) == -1) {

--- 5 unchanged lines hidden (view full) ---

122 sizeof(dhost));
123 if (!ip->ip_sum)
124 ip->ip_sum = chksum((u_short *)ip,
125 ip->ip_hl << 2);
126 bcopy(ip, (char *)(eh + 1), len);
127 len += sizeof(*eh);
128 printpacket(ip);
129 } else {
130 eh = (ether_header_t *)buf;
130 eh = (ether_header_t *)pbuf;
131 len = i;
132 }
133
134 if (sendip(wfd, (char *)eh, len) == -1)
135 {
136 perror("send_packet");
137 break;
138 }
139 }
140 (*r->r_close)();
141 return 0;
142}
131 len = i;
132 }
133
134 if (sendip(wfd, (char *)eh, len) == -1)
135 {
136 perror("send_packet");
137 break;
138 }
139 }
140 (*r->r_close)();
141 return 0;
142}