"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pcap/logpkt.c" between
ssldump-1.4.tar.gz and ssldump-1.5.tar.gz

About: ssldump is an SSLv3/TLS network protocol analyzer.

logpkt.c  (ssldump-1.4):logpkt.c  (ssldump-1.5)
skipping to change at line 222 skipping to change at line 222
* to zero bytes and a new PCAP header is written. * to zero bytes and a new PCAP header is written.
* On a return value of 0, the caller can continue to write PCAP records to the * On a return value of 0, the caller can continue to write PCAP records to the
* file descriptor. On error, -1 is returned and the file descriptor is in an * file descriptor. On error, -1 is returned and the file descriptor is in an
* undefined but still open state. * undefined but still open state.
*/ */
int int
logpkt_pcap_open_fd(int fd) { logpkt_pcap_open_fd(int fd) {
pcap_file_hdr_t hdr; pcap_file_hdr_t hdr;
off_t sz; off_t sz;
ssize_t n; ssize_t n;
struct stat st;
sz = lseek(fd, 0, SEEK_END); if(fstat(fd, &st))
if (sz == -1)
return -1; return -1;
if (sz > 0) { if(!S_ISFIFO(st.st_mode)) {
if (lseek(fd, 0, SEEK_SET) == -1) sz = lseek(fd, 0, SEEK_END);
if (sz == -1)
return -1; return -1;
n = read(fd, &hdr, sizeof(pcap_file_hdr_t));
if (n != sizeof(pcap_file_hdr_t))
return -1;
if (hdr.magic_number == PCAP_MAGIC)
return lseek(fd, 0, SEEK_END) == -1 ? -1 : 0;
if (lseek(fd, 0, SEEK_SET) == -1)
return -1;
if (ftruncate(fd, 0) == -1)
return -1;
}
if (sz > 0) {
if (lseek(fd, 0, SEEK_SET) == -1)
return -1;
n = read(fd, &hdr, sizeof(pcap_file_hdr_t));
if (n != sizeof(pcap_file_hdr_t))
return -1;
if (hdr.magic_number == PCAP_MAGIC)
return lseek(fd, 0, SEEK_END) == -1 ? -1 : 0;
if (lseek(fd, 0, SEEK_SET) == -1)
return -1;
if (ftruncate(fd, 0) == -1)
return -1;
}
}
return logpkt_write_global_pcap_hdr(fd); return logpkt_write_global_pcap_hdr(fd);
} }
/* /*
* Initialize the per-connection packet crafting context. For mirroring, * Initialize the per-connection packet crafting context. For mirroring,
* *libnet* must be an initialized libnet instance and *mtu* must be the * *libnet* must be an initialized libnet instance and *mtu* must be the
* target interface MTU greater than 0. For PCAP writing, *libnet* must be * target interface MTU greater than 0. For PCAP writing, *libnet* must be
* NULL and *mtu* must be 0. The ether and sockaddr addresses are used as the * NULL and *mtu* must be 0. The ether and sockaddr addresses are used as the
* layer 2 and layer 3 addresses respectively. For mirroring, the ethers must * layer 2 and layer 3 addresses respectively. For mirroring, the ethers must
* match the actual link layer addresses to be used when sending traffic, not * match the actual link layer addresses to be used when sending traffic, not
 End of changes. 5 change blocks. 
14 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)