diff -Bbur kismet-devel/packetracker.cc kismet310/packetracker.cc --- kismet-devel/packetracker.cc 2003-08-24 10:39:30.000000000 -0400 +++ kismet310/packetracker.cc 2003-10-24 12:28:52.000000000 -0400 @@ -942,18 +942,20 @@ } } +#include int Packetracker::WriteNetworks(string in_fname) { string fname_temp = in_fname + ".temp"; - FILE *netfile; + gzFile netfile; + FILE *tnetfile; - if ((netfile = fopen(in_fname.c_str(), "w+")) == NULL) { + if ((tnetfile = fopen(in_fname.c_str(), "w+")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing: %s", in_fname.c_str(), strerror(errno)); return -1; } - fclose(netfile); + fclose(tnetfile); if (unlink(fname_temp.c_str()) == -1) { if (errno != ENOENT) { @@ -963,7 +965,7 @@ } } - if ((netfile = fopen(fname_temp.c_str(), "w")) == NULL) { + if ((netfile = gzopen(fname_temp.c_str(), "wb9")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing even though we could unlink it: %s", fname_temp.c_str(), strerror(errno)); return -1; @@ -1025,7 +1027,7 @@ else snprintf(carrier, 15, "unknown"); - fprintf(netfile, "Network %d: \"%s\" BSSID: \"%s\"\n" + gzprintf(netfile, "Network %d: \"%s\" BSSID: \"%s\"\n" " Type : %s\n" " Carrier : %s\n" " Info : \"%s\"\n" @@ -1050,7 +1052,7 @@ ft, lt); if (net->gps_fixed != -1) - fprintf(netfile, + gzprintf(netfile, " Min Loc: Lat %f Lon %f Alt %f Spd %f\n" " Max Loc: Lat %f Lon %f Alt %f Spd %f\n", net->min_lat, net->min_lon, @@ -1061,27 +1063,27 @@ metric ? net->max_spd * 1.6093 : net->max_spd); if (net->ipdata.atype == address_dhcp) - fprintf(netfile, " Address found via DHCP %d.%d.%d.%d \n", + gzprintf(netfile, " Address found via DHCP %d.%d.%d.%d \n", net->ipdata.range_ip[0], net->ipdata.range_ip[1], net->ipdata.range_ip[2], net->ipdata.range_ip[3] ); else if (net->ipdata.atype == address_arp) - fprintf(netfile, " Address found via ARP %d.%d.%d.%d\n", + gzprintf(netfile, " Address found via ARP %d.%d.%d.%d\n", net->ipdata.range_ip[0], net->ipdata.range_ip[1], net->ipdata.range_ip[2], net->ipdata.range_ip[3]); else if (net->ipdata.atype == address_udp) - fprintf(netfile, " Address found via UDP %d.%d.%d.%d\n", + gzprintf(netfile, " Address found via UDP %d.%d.%d.%d\n", net->ipdata.range_ip[0], net->ipdata.range_ip[1], net->ipdata.range_ip[2], net->ipdata.range_ip[3]); else if (net->ipdata.atype == address_tcp) - fprintf(netfile, " Address found via TCP %d.%d.%d.%d\n", + gzprintf(netfile, " Address found via TCP %d.%d.%d.%d\n", net->ipdata.range_ip[0], net->ipdata.range_ip[1], net->ipdata.range_ip[2], net->ipdata.range_ip[3]); - fprintf(netfile, "\n"); + gzprintf(netfile, "\n"); netnum++; } - fclose(netfile); + gzclose(netfile); if (unlink(in_fname.c_str()) == -1) { if (errno != ENOENT) { @@ -1104,15 +1106,16 @@ int Packetracker::WriteCisco(string in_fname) { string fname_temp = in_fname + ".temp"; - FILE *netfile; + gzFile netfile; + FILE *tnetfile; - if ((netfile = fopen(in_fname.c_str(), "w+")) == NULL) { + if ((tnetfile = fopen(in_fname.c_str(), "w+")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing: %s", in_fname.c_str(), strerror(errno)); return -1; } - fclose(netfile); + fclose(tnetfile); if (unlink(fname_temp.c_str()) == -1) { if (errno != ENOENT) { @@ -1122,18 +1125,13 @@ } } - if ((netfile = fopen(fname_temp.c_str(), "w")) == NULL) { + if ((netfile = gzopen(fname_temp.c_str(), "wb9")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing even though we could unlink it: %s", fname_temp.c_str(), strerror(errno)); return -1; } /* - fseek(in_file, 0L, SEEK_SET); - ftruncate(fileno(in_file), 0); - */ - - /* vector bssid_vec; // Convert the map to a vector and sort it @@ -1164,7 +1162,7 @@ continue; } - fprintf(netfile, "Network: \"%s\" BSSID: \"%s\"\n", + gzprintf(netfile, "Network: \"%s\" BSSID: \"%s\"\n", net->ssid.c_str(), net->bssid.Mac2String().c_str()); int devnum = 1; @@ -1172,9 +1170,9 @@ x != net->cisco_equip.end(); ++x) { cdp_packet cdp = x->second; - fprintf(netfile, "CDP Broadcast Device %d\n", devnum); - fprintf(netfile, " Device ID : %s\n", cdp.dev_id); - fprintf(netfile, " Capability: %s%s%s%s%s%s%s\n", + gzprintf(netfile, "CDP Broadcast Device %d\n", devnum); + gzprintf(netfile, " Device ID : %s\n", cdp.dev_id); + gzprintf(netfile, " Capability: %s%s%s%s%s%s%s\n", cdp.cap.level1 ? "Level 1 " : "" , cdp.cap.igmp_forward ? "IGMP forwarding " : "", cdp.cap.nlp ? "Network-layer protocols " : "", @@ -1182,17 +1180,17 @@ cdp.cap.level2_sourceroute ? "Level 2 source-route bridging " : "", cdp.cap.level2_transparent ? "Level 2 transparent bridging " : "", cdp.cap.level3 ? "Level 3 routing " : ""); - fprintf(netfile, " Interface : %s\n", cdp.interface); - fprintf(netfile, " IP : %d.%d.%d.%d\n", + gzprintf(netfile, " Interface : %s\n", cdp.interface); + gzprintf(netfile, " IP : %d.%d.%d.%d\n", cdp.ip[0], cdp.ip[1], cdp.ip[2], cdp.ip[3]); - fprintf(netfile, " Platform : %s\n", cdp.platform); - fprintf(netfile, " Software : %s\n", cdp.software); - fprintf(netfile, "\n"); + gzprintf(netfile, " Platform : %s\n", cdp.platform); + gzprintf(netfile, " Software : %s\n", cdp.software); + gzprintf(netfile, "\n"); devnum++; } // cdp } // net - fclose(netfile); + gzclose(netfile); if (unlink(in_fname.c_str()) == -1) { if (errno != ENOENT) { @@ -1233,15 +1231,16 @@ string fname_temp = in_fname + ".temp"; - FILE *netfile; + gzFile netfile; + FILE *tnetfile; - if ((netfile = fopen(in_fname.c_str(), "w+")) == NULL) { + if ((tnetfile = fopen(in_fname.c_str(), "w+")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing: %s", in_fname.c_str(), strerror(errno)); return -1; } - fclose(netfile); + fclose(tnetfile); if (unlink(fname_temp.c_str()) == -1) { if (errno != ENOENT) { @@ -1251,18 +1250,14 @@ } } - if ((netfile = fopen(fname_temp.c_str(), "w")) == NULL) { + if ((netfile = gzopen(fname_temp.c_str(), "w")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing even though we could unlink it: %s", fname_temp.c_str(), strerror(errno)); return -1; } - /* - fseek(in_file, 0L, SEEK_SET); - ftruncate(fileno(in_file), 0); - */ - int netnum = 1; + /* vector bssid_vec; @@ -1274,7 +1269,7 @@ sort(bssid_vec.begin(), bssid_vec.end(), SortFirstTimeLT()); */ - fprintf(netfile, "Network;NetType;ESSID;BSSID;Info;Channel;Cloaked;WEP;Decrypted;MaxRate;MaxSeenRate;Beacon;" + gzprintf(netfile, "Network;NetType;ESSID;BSSID;Info;Channel;Cloaked;WEP;Decrypted;MaxRate;MaxSeenRate;Beacon;" "LLC;Data;Crypt;Weak;Total;Carrier;Encoding;FirstTime;LastTime;BestQuality;BestSignal;BestNoise;" "GPSMinLat;GPSMinLon;GPSMinAlt;GPSMinSpd;GPSMaxLat;GPSMaxLon;GPSMaxAlt;GPSMaxSpd;" "GPSBestLat;GPSBestLon;GPSBestAlt;DataSize;IPType;IP;\n\r"); @@ -1371,7 +1366,7 @@ else if (net->ipdata.atype == address_tcp) iptype = "TCP"; - fprintf(netfile, + gzprintf(netfile, "%d;%s;%s;%s;%s;" "%d;%s;%s;%s;" "%2.1f;%ld;%d;" @@ -1398,7 +1393,7 @@ netnum++; } - fclose(netfile); + gzclose(netfile); if (unlink(in_fname.c_str()) == -1) { if (errno != ENOENT) { @@ -1439,15 +1434,16 @@ int Packetracker::WriteXMLNetworks(string in_fname) { string fname_temp = in_fname + ".temp"; - FILE *netfile; + gzFile netfile; + FILE *tnetfile; - if ((netfile = fopen(in_fname.c_str(), "w+")) == NULL) { + if ((tnetfile = fopen(in_fname.c_str(), "w+")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing: %s", in_fname.c_str(), strerror(errno)); return -1; } - fclose(netfile); + fclose(tnetfile); if (unlink(fname_temp.c_str()) == -1) { if (errno != ENOENT) { @@ -1457,24 +1453,19 @@ } } - if ((netfile = fopen(fname_temp.c_str(), "w")) == NULL) { + if ((netfile = gzopen(fname_temp.c_str(), "w")) == NULL) { snprintf(errstr, 1024, "Could not open %s for writing even though we could unlink it: %s", fname_temp.c_str(), strerror(errno)); return -1; } - /* - fseek(in_file, 0L, SEEK_SET); - ftruncate(fileno(in_file), 0); - */ - int netnum = 1; //vector bssid_vec; - fprintf(netfile, "\n"); - fprintf(netfile, "\n"); + gzprintf(netfile, "\n"); + gzprintf(netfile, "\n"); - fprintf(netfile, "\n\n"); + gzprintf(netfile, "\n\n"); char lt[25]; char ft[25]; @@ -1483,7 +1474,7 @@ time_t cur_time = time(0); snprintf(lt, 25, "%s", ctime(&cur_time)); - fprintf(netfile, "\n", + gzprintf(netfile, "\n", VERSION_MAJOR, VERSION_MINOR, VERSION_TINY, ft, lt); /* @@ -1529,66 +1520,66 @@ else snprintf(type, 15, "unknown"); - fprintf(netfile, " \n", + gzprintf(netfile, " \n", netnum, type, net->wep ? "true" : "false", net->cloaked ? "true" : "false", ft, lt); if (net->ssid != NOSSID) - fprintf(netfile, " %s\n", SanitizeXML(net->ssid).c_str()); + gzprintf(netfile, " %s\n", SanitizeXML(net->ssid).c_str()); - fprintf(netfile, " %s\n", net->bssid.Mac2String().c_str()); + gzprintf(netfile, " %s\n", net->bssid.Mac2String().c_str()); if (net->beacon_info != "") - fprintf(netfile, " %s\n", SanitizeXML(net->beacon_info).c_str()); - fprintf(netfile, " %d\n", net->channel); - fprintf(netfile, " %2.1f\n", net->maxrate); - fprintf(netfile, " %ld\n", (long) net->maxseenrate * 100); + gzprintf(netfile, " %s\n", SanitizeXML(net->beacon_info).c_str()); + gzprintf(netfile, " %d\n", net->channel); + gzprintf(netfile, " %2.1f\n", net->maxrate); + gzprintf(netfile, " %ld\n", (long) net->maxseenrate * 100); if (net->carrier_set & (1 << (int) carrier_80211b)) - fprintf(netfile, " IEEE 802.11b\n"); + gzprintf(netfile, " IEEE 802.11b\n"); if (net->carrier_set & (1 << (int) carrier_80211bplus)) - fprintf(netfile, " TI 802.11b+\n"); + gzprintf(netfile, " TI 802.11b+\n"); if (net->carrier_set & (1 << (int) carrier_80211a)) - fprintf(netfile, " IEEE 802.11a\n"); + gzprintf(netfile, " IEEE 802.11a\n"); if (net->carrier_set & (1 << (int) carrier_80211g)) - fprintf(netfile, " IEEE 802.11g\n"); + gzprintf(netfile, " IEEE 802.11g\n"); if (net->carrier_set & (1 << (int) carrier_80211fhss)) - fprintf(netfile, " IEEE 802.11 FHSS\n"); + gzprintf(netfile, " IEEE 802.11 FHSS\n"); if (net->carrier_set & (1 << (int) carrier_80211dsss)) - fprintf(netfile, " IEEE 802.11 FSSS\n"); + gzprintf(netfile, " IEEE 802.11 FSSS\n"); if (net->encoding_set & (1 << (int) encoding_cck)) - fprintf(netfile, " CCK\n"); + gzprintf(netfile, " CCK\n"); if (net->encoding_set & (1 << (int) encoding_pbcc)) - fprintf(netfile, " PBCC\n"); + gzprintf(netfile, " PBCC\n"); if (net->encoding_set & (1 << (int) encoding_ofdm)) - fprintf(netfile, " OFDM\n"); + gzprintf(netfile, " OFDM\n"); - fprintf(netfile, " \n"); - fprintf(netfile, " %d\n", net->llc_packets); - fprintf(netfile, " %d\n", net->data_packets); - fprintf(netfile, " %d\n", net->crypt_packets); - fprintf(netfile, " %d\n", net->interesting_packets); - fprintf(netfile, " %d\n", + gzprintf(netfile, " \n"); + gzprintf(netfile, " %d\n", net->llc_packets); + gzprintf(netfile, " %d\n", net->data_packets); + gzprintf(netfile, " %d\n", net->crypt_packets); + gzprintf(netfile, " %d\n", net->interesting_packets); + gzprintf(netfile, " %d\n", (net->llc_packets + net->data_packets)); - fprintf(netfile, " \n"); + gzprintf(netfile, " \n"); - fprintf(netfile, " %ld\n", net->datasize); + gzprintf(netfile, " %ld\n", net->datasize); if (net->gps_fixed != -1) { - fprintf(netfile, " \n", metric ? "metric" : "english"); - fprintf(netfile, " %f\n", net->min_lat); - fprintf(netfile, " %f\n", net->min_lon); - fprintf(netfile, " %f\n", + gzprintf(netfile, " \n", metric ? "metric" : "english"); + gzprintf(netfile, " %f\n", net->min_lat); + gzprintf(netfile, " %f\n", net->min_lon); + gzprintf(netfile, " %f\n", metric ? net->min_alt / 3.3 : net->min_alt); - fprintf(netfile, " %f\n", + gzprintf(netfile, " %f\n", metric ? net->min_spd * 1.6093 : net->min_spd); - fprintf(netfile, " %f\n", net->max_lat); - fprintf(netfile, " %f\n", net->max_lon); - fprintf(netfile, " %f\n", + gzprintf(netfile, " %f\n", net->max_lat); + gzprintf(netfile, " %f\n", net->max_lon); + gzprintf(netfile, " %f\n", metric ? net->max_alt / 3.3 : net->max_alt); - fprintf(netfile, " %f\n", + gzprintf(netfile, " %f\n", metric ? net->max_spd * 1.6093 : net->max_spd); - fprintf(netfile, " \n"); + gzprintf(netfile, " \n"); } if (net->ipdata.atype > address_factory) { @@ -1611,11 +1602,11 @@ break; } - fprintf(netfile, " \n", addrtype); - fprintf(netfile, " %d.%d.%d.%d\n", + gzprintf(netfile, " \n", addrtype); + gzprintf(netfile, " %d.%d.%d.%d\n", net->ipdata.range_ip[0], net->ipdata.range_ip[1], net->ipdata.range_ip[2], net->ipdata.range_ip[3]); - fprintf(netfile, " \n"); + gzprintf(netfile, " \n"); } netnum++; @@ -1645,44 +1636,44 @@ snprintf(lt, 25, "%s", ctime(&cli->last_time)); snprintf(ft, 25, "%s", ctime(&cli->first_time)); - fprintf(netfile, " \n", clinum, clitype, cli->wep ? "true" : "false", ft, lt); - fprintf(netfile, " %s\n", cli->mac.Mac2String().c_str()); - fprintf(netfile, " \n"); - fprintf(netfile, " %d\n", cli->data_packets); - fprintf(netfile, " %d\n", cli->crypt_packets); - fprintf(netfile, " %d\n", cli->interesting_packets); - fprintf(netfile, " \n"); + gzprintf(netfile, " %s\n", cli->mac.Mac2String().c_str()); + gzprintf(netfile, " \n"); + gzprintf(netfile, " %d\n", cli->data_packets); + gzprintf(netfile, " %d\n", cli->crypt_packets); + gzprintf(netfile, " %d\n", cli->interesting_packets); + gzprintf(netfile, " \n"); if (cli->gps_fixed != -1) { - fprintf(netfile, " \n", metric ? "metric" : "english"); - fprintf(netfile, " %f\n", cli->min_lat); - fprintf(netfile, " %f\n", cli->min_lon); - fprintf(netfile, " %f\n", + gzprintf(netfile, " \n", metric ? "metric" : "english"); + gzprintf(netfile, " %f\n", cli->min_lat); + gzprintf(netfile, " %f\n", cli->min_lon); + gzprintf(netfile, " %f\n", metric ? cli->min_alt / 3.3 : cli->min_alt); - fprintf(netfile, " %f\n", + gzprintf(netfile, " %f\n", metric ? cli->min_spd * 1.6093 : cli->min_spd); - fprintf(netfile, " %f\n", cli->max_lat); - fprintf(netfile, " %f\n", cli->max_lon); - fprintf(netfile, " %f\n", + gzprintf(netfile, " %f\n", cli->max_lat); + gzprintf(netfile, " %f\n", cli->max_lon); + gzprintf(netfile, " %f\n", metric ? cli->max_alt / 3.3 : cli->max_alt); - fprintf(netfile, " %f\n", + gzprintf(netfile, " %f\n", metric ? cli->max_spd * 1.6093 : cli->max_spd); - fprintf(netfile, " \n"); + gzprintf(netfile, " \n"); } - fprintf(netfile, " %ld\n", cli->datasize); - fprintf(netfile, " %2.1f\n", cli->maxrate); - fprintf(netfile, " %ld\n", (long) cli->maxseenrate * 100); + gzprintf(netfile, " %ld\n", cli->datasize); + gzprintf(netfile, " %2.1f\n", cli->maxrate); + gzprintf(netfile, " %ld\n", (long) cli->maxseenrate * 100); if (net->encoding_set & (1 << (int) encoding_cck)) - fprintf(netfile, " CCK\n"); + gzprintf(netfile, " CCK\n"); if (net->encoding_set & (1 << (int) encoding_pbcc)) - fprintf(netfile, " PBCC\n"); + gzprintf(netfile, " PBCC\n"); if (net->encoding_set & (1 << (int) encoding_ofdm)) - fprintf(netfile, " OFDM\n"); + gzprintf(netfile, " OFDM\n"); @@ -1706,11 +1697,11 @@ break; } - fprintf(netfile, " %hd.%hd.%hd.%hd\n", + gzprintf(netfile, " %hd.%hd.%hd.%hd\n", addrtype, cli->ipdata.ip[0], cli->ipdata.ip[1], cli->ipdata.ip[2], cli->ipdata.ip[3]); } - fprintf(netfile, " \n"); + gzprintf(netfile, " \n"); clinum++; } @@ -1720,10 +1711,10 @@ x != net->cisco_equip.end(); ++x) { cdp_packet cdp = x->second; - fprintf(netfile, " \n", devnum); - fprintf(netfile, " %s\n", + gzprintf(netfile, " \n", devnum); + gzprintf(netfile, " %s\n", cdp.dev_id); - fprintf(netfile, " \n", cdp.cap.level1 ? "true" : "false", @@ -1733,22 +1724,22 @@ cdp.cap.level2_sourceroute ? "true" : "false", cdp.cap.level2_transparent ? "true" : "false", cdp.cap.level3 ? "true" : "false"); - fprintf(netfile, " %s\n", cdp.interface); - fprintf(netfile, " %d.%d.%d.%d\n", + gzprintf(netfile, " %s\n", cdp.interface); + gzprintf(netfile, " %d.%d.%d.%d\n", cdp.ip[0], cdp.ip[1], cdp.ip[2], cdp.ip[3]); - fprintf(netfile, " %s\n", cdp.platform); - fprintf(netfile, " %s\n", cdp.software); - fprintf(netfile, " \n"); + gzprintf(netfile, " %s\n", cdp.platform); + gzprintf(netfile, " %s\n", cdp.software); + gzprintf(netfile, " \n"); devnum++; } // cdp - fprintf(netfile, " \n"); + gzprintf(netfile, " \n"); } // net - fprintf(netfile, "\n"); + gzprintf(netfile, "\n"); - fclose(netfile); + gzclose(netfile); if (unlink(in_fname.c_str()) == -1) { if (errno != ENOENT) { diff -Bbur kismet-devel/wtaplocaldump.cc kismet310/wtaplocaldump.cc --- kismet-devel/wtaplocaldump.cc 2003-03-16 16:02:05.000000000 -0500 +++ kismet310/wtaplocaldump.cc 2003-10-24 12:28:52.000000000 -0400 @@ -18,11 +18,13 @@ #include "config.h" +#include #include #include #include "wtaplocaldump.h" #ifdef USE_LOCAL_DUMP +static gzFile gz_dump_file; int WtapDumpFile::OpenDump(const char *file) { snprintf(type, 64, "wiretap (local code) dump"); @@ -31,7 +33,7 @@ num_dumped = 0; beacon_log = 1; - if ((dump_file = fopen(file, "w")) == NULL) { + if ((gz_dump_file = gzopen(file, "wb9")) == NULL) { snprintf(errstr, 1024, "Unable to open dump file %s (%s)", filename, strerror(errno)); return -1; } @@ -40,9 +42,9 @@ int nwritten; // Write the magic file identifier - nwritten = fwrite(&magic, 1, sizeof(magic), dump_file); + nwritten = gzwrite(gz_dump_file, &magic, sizeof(magic)); if (nwritten != sizeof(magic)) { - if (nwritten == 0 && ferror(dump_file)) + if (nwritten == 0 && gzerror(gz_dump_file,&errno)) snprintf(errstr, 1024, "Unable to write pcap magic header. (%s)", strerror(errno)); else snprintf(errstr, 1024, "Short write on pcap magic header."); @@ -61,9 +63,9 @@ file_hdr.network = 105; /* pcap file type */ // Write the header - nwritten = fwrite(&file_hdr, 1, sizeof(file_hdr), dump_file); + nwritten = gzwrite(gz_dump_file, &file_hdr, sizeof(file_hdr)); if (nwritten != sizeof(file_hdr)) { - if (nwritten == 0 && ferror(dump_file)) + if (nwritten == 0 && gzerror(gz_dump_file,&errno)) snprintf(errstr, 1024, "Unable to write pcap file header. (%s)", strerror(errno)); else snprintf(errstr, 1024, "Short write on pcap file header."); @@ -75,7 +77,7 @@ } int WtapDumpFile::CloseDump() { - fclose(dump_file); + gzclose(gz_dump_file); return num_dumped; } @@ -116,9 +118,9 @@ packhdr.incl_len = dump_packet->caplen; packhdr.orig_len = dump_packet->caplen; - nwritten = fwrite(&packhdr, 1, sizeof(pcaprec_hdr), dump_file); + nwritten = gzwrite(gz_dump_file, &packhdr, sizeof(pcaprec_hdr)); if (nwritten != sizeof(pcaprec_hdr)) { - if (nwritten == 0 && ferror(dump_file)) + if (nwritten == 0 && gzerror(gz_dump_file,&errno)) snprintf(errstr, 1024, "Unable to write pcap packet header (%s)", strerror(errno)); else snprintf(errstr, 1024, "Short write on pcap packet header"); @@ -126,9 +128,9 @@ return -1; } - nwritten = fwrite(dump_packet->data, 1, packhdr.incl_len, dump_file); + nwritten = gzwrite(gz_dump_file, dump_packet->data, packhdr.incl_len); if (nwritten != packhdr.incl_len) { - if (nwritten == 0 && ferror(dump_file)) + if (nwritten == 0 && gzerror(gz_dump_file,&errno)) snprintf(errstr, 1024, "Unable to write pcap packet (%s)", strerror(errno)); else snprintf(errstr, 1024, "Short write on pcap packet");