Changeset 2193905 for lib/format_pcap.c
- Timestamp:
- 11/29/18 10:12:59 (2 years ago)
- Branches:
- develop
- Children:
- fdf23b8
- Parents:
- d74ca03
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_pcap.c
rf6f3ae5 r2193905 31 31 32 32 #include <sys/stat.h> 33 #include <assert.h>34 33 #include <stdio.h> 35 34 #include <stdlib.h> … … 103 102 104 103 if (!libtrace->format_data) { 105 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcap_init_input()"); 104 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 105 "format data inside pcap_init_input()"); 106 106 return -1; 107 107 } … … 178 178 return -1; 179 179 } 180 /*assert(0);*/181 180 return -1; 182 181 } … … 185 184 libtrace->format_data = malloc(sizeof(struct pcap_format_data_out_t)); 186 185 if (!libtrace->format_data) { 187 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcap_init_output()"); 186 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 187 "format data inside pcap_init_output()"); 188 188 return -1; 189 189 } … … 198 198 libtrace->format_data = malloc(sizeof(struct pcap_format_data_out_t)); 199 199 if (!libtrace->format_data) { 200 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapint_init_output()"); 200 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 201 "format data inside pcapint_init_output()"); 201 202 return -1; 202 203 } … … 222 223 libtrace->format_data = malloc(sizeof(struct pcap_format_data_t)); 223 224 if (!libtrace->format_data) { 224 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapint_init_input()"); 225 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 226 "format data inside pcapint_init_input()"); 225 227 return -1; 226 228 } … … 261 263 return -1; 262 264 } 263 /*assert(0);*/264 265 return -1; 265 266 } … … 446 447 uint32_t flags = 0; 447 448 448 /*assert(libtrace->format_data);*/449 449 if (!libtrace->format_data) { 450 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, call init_input() before calling pcap_read_packet()"); 450 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, " 451 "call trace_create() before calling pcap_read_packet()"); 451 452 return -1; 452 453 } … … 611 612 pcap_pkt_hdr.len = trace_get_wire_length(packet); 612 613 613 /*assert(pcap_pkt_hdr.caplen<65536);*/614 614 if (pcap_pkt_hdr.caplen >= 65536) { 615 615 trace_set_err_out(libtrace, TRACE_ERR_BAD_HEADER, "Header capture length is larger than it should be in pcap_write_packet()"); 616 616 return -1; 617 617 } 618 /*assert(pcap_pkt_hdr.len<65536);*/619 618 if (pcap_pkt_hdr.len >= 65536) { 620 619 trace_set_err_out(libtrace, TRACE_ERR_BAD_HEADER, "Header wire length is larger than it should be pcap_write_packet()"); … … 720 719 struct pcap_pkthdr *pcapptr = 0; 721 720 pcapptr = (struct pcap_pkthdr *)packet->header; 722 /*assert(pcapptr->caplen<=65536);*/723 721 if (pcapptr->caplen > 65536) { 724 722 trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Capture length is to large, Packet may be corrupt in pcap_get_capture_length()"); … … 756 754 static size_t pcap_set_capture_length(libtrace_packet_t *packet,size_t size) { 757 755 struct pcap_pkthdr *pcapptr = 0; 758 /*assert(packet);*/759 756 if (!packet) { 760 757 fprintf(stderr, "NULL packet passed to pcap_set_capture_length()\n"); … … 777 774 return TRACE_ERR_NULL_TRACE; 778 775 } 779 /*assert(trace->format_data);*/780 776 if (!trace->format_data) { 781 777 /* cant do this because trace is a const? */
Note: See TracChangeset
for help on using the changeset viewer.