resend.c (153881) | resend.c (161357) |
---|---|
1/* $FreeBSD: head/contrib/ipfilter/ipsend/resend.c 153881 2005-12-30 11:52:26Z guido $ */ | 1/* $FreeBSD: head/contrib/ipfilter/ipsend/resend.c 161357 2006-08-16 12:23:02Z guido $ */ |
2 3/* 4 * resend.c (C) 1995-1998 Darren Reed 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 */ 9#if !defined(lint) 10static const char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed"; | 2 3/* 4 * resend.c (C) 1995-1998 Darren Reed 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 */ 9#if !defined(lint) 10static const char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed"; |
11static const char rcsid[] = "@(#)$Id: resend.c,v 2.8 2004/01/08 13:34:31 darrenr Exp $"; | 11static const char rcsid[] = "@(#)$Id: resend.c,v 2.8.2.2 2006/03/17 13:45:34 darrenr Exp $"; |
12#endif 13#include <sys/param.h> 14#include <sys/types.h> 15#include <sys/time.h> 16#include <sys/socket.h> 17#include <net/if.h> 18#include <netinet/in.h> 19#include <arpa/inet.h> --- 56 unchanged lines hidden (view full) --- 76struct ipread *r; 77char *datain; 78{ 79 ether_header_t *eh; 80 char dhost[6]; 81 ip_t *ip; 82 int fd, wfd = initdevice(dev, 5), len, i; 83 | 12#endif 13#include <sys/param.h> 14#include <sys/types.h> 15#include <sys/time.h> 16#include <sys/socket.h> 17#include <net/if.h> 18#include <netinet/in.h> 19#include <arpa/inet.h> --- 56 unchanged lines hidden (view full) --- 76struct ipread *r; 77char *datain; 78{ 79 ether_header_t *eh; 80 char dhost[6]; 81 ip_t *ip; 82 int fd, wfd = initdevice(dev, 5), len, i; 83 |
84 if (wfd == -1) 85 return -1; 86 |
|
84 if (datain) 85 fd = (*r->r_open)(datain); 86 else 87 fd = (*r->r_open)("-"); 88 89 if (fd < 0) 90 exit(-1); 91 --- 4 unchanged lines hidden (view full) --- 96 perror("malloc failed"); 97 return -2; 98 } 99 100 bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost)); 101 if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1)) 102 { 103 perror("arp"); | 87 if (datain) 88 fd = (*r->r_open)(datain); 89 else 90 fd = (*r->r_open)("-"); 91 92 if (fd < 0) 93 exit(-1); 94 --- 4 unchanged lines hidden (view full) --- 99 perror("malloc failed"); 100 return -2; 101 } 102 103 bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost)); 104 if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1)) 105 { 106 perror("arp"); |
107 free(eh); |
|
104 return -2; 105 } 106 107 while ((i = (*r->r_readip)((char *)pbuf, sizeof(pbuf), NULL, NULL)) > 0) 108 { 109 if (!(opts & OPT_RAW)) { 110 len = ntohs(ip->ip_len); 111 eh = (ether_header_t *)realloc((char *)eh, sizeof(*eh) + len); --- 20 unchanged lines hidden (view full) --- 132 133 if (sendip(wfd, (char *)eh, len) == -1) 134 { 135 perror("send_packet"); 136 break; 137 } 138 } 139 (*r->r_close)(); | 108 return -2; 109 } 110 111 while ((i = (*r->r_readip)((char *)pbuf, sizeof(pbuf), NULL, NULL)) > 0) 112 { 113 if (!(opts & OPT_RAW)) { 114 len = ntohs(ip->ip_len); 115 eh = (ether_header_t *)realloc((char *)eh, sizeof(*eh) + len); --- 20 unchanged lines hidden (view full) --- 136 137 if (sendip(wfd, (char *)eh, len) == -1) 138 { 139 perror("send_packet"); 140 break; 141 } 142 } 143 (*r->r_close)(); |
144 free(eh); |
|
140 return 0; 141} | 145 return 0; 146} |