Changeset 4bd8a5b
- Timestamp:
- 12/24/06 17:05:29 (15 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 870e501
- Parents:
- 778d459
- Location:
- lib
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/dagformat.h
re2aebe7 r4bd8a5b 101 101 102 102 /** sizeof(dag_record_t) without the payload helpers */ 103 #define dag_record_size 16 103 #define dag_record_size 16U 104 104 105 105 #endif /* _DAGFORMAT_H_ */ -
lib/format_duck.c
rac0fdbf r4bd8a5b 140 140 141 141 if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { 142 packet->buffer = malloc( LIBTRACE_PACKET_BUFSIZE);142 packet->buffer = malloc((size_t)LIBTRACE_PACKET_BUFSIZE); 143 143 packet->buf_control = TRACE_CTRL_PACKET; 144 144 if (!packet->buffer) { … … 181 181 182 182 if ((numbytes = libtrace_io_read(INPUT->file, packet->payload, 183 duck_size)) != (int)duck_size) {183 (size_t)duck_size)) != (int)duck_size) { 184 184 if (numbytes == -1) { 185 185 trace_set_err(libtrace, errno, "Reading DUCK failed"); -
lib/format_erf.c
r5e85c23 r4bd8a5b 60 60 #define COLLECTOR_PORT 3435 61 61 62 static struct libtrace_format_t erf ;62 static struct libtrace_format_t erfformat; 63 63 64 64 #define DATA(x) ((struct erf_format_data_t *)x->format_data) … … 173 173 174 174 libtrace_io_seek(DATA(libtrace)->seek.index, 175 current*sizeof(record),175 (int64_t)(current*sizeof(record)), 176 176 SEEK_SET); 177 177 libtrace_io_read(DATA(libtrace)->seek.index, … … 192 192 do { 193 193 libtrace_io_seek(DATA(libtrace)->seek.index, 194 current*sizeof(record),SEEK_SET);194 (int64_t)(current*sizeof(record)),SEEK_SET); 195 195 libtrace_io_read(DATA(libtrace)->seek.index, 196 196 &record,sizeof(record)); … … 199 199 200 200 /* We've found our location in the trace, now use it. */ 201 libtrace_io_seek(INPUT.file, record.offset,SEEK_SET);201 libtrace_io_seek(INPUT.file,(int64_t) record.offset,SEEK_SET); 202 202 203 203 return 0; /* success */ … … 316 316 317 317 if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { 318 packet->buffer = malloc( LIBTRACE_PACKET_BUFSIZE);318 packet->buffer = malloc((size_t)LIBTRACE_PACKET_BUFSIZE); 319 319 packet->buf_control = TRACE_CTRL_PACKET; 320 320 if (!packet->buffer) { … … 332 332 if ((numbytes=libtrace_io_read(INPUT.file, 333 333 packet->buffer, 334 dag_record_size)) == -1) {334 (size_t)dag_record_size)) == -1) { 335 335 trace_set_err(libtrace,errno,"read(%s)", 336 336 libtrace->uridata); … … 354 354 if ((numbytes=libtrace_io_read(INPUT.file, 355 355 buffer2, 356 size)) != (int)size) {356 (size_t)size)) != (int)size) { 357 357 if (numbytes==-1) { 358 358 trace_set_err(libtrace,errno, "read(%s)", libtrace->uridata); … … 377 377 378 378 if ((numbytes = 379 libtrace_io_write(OUTPUT.file, erfptr, dag_record_size + pad)) 380 != (int)dag_record_size+pad) { 379 libtrace_io_write(OUTPUT.file, 380 erfptr, 381 (size_t)(dag_record_size + pad))) 382 != (int)(dag_record_size+pad)) { 381 383 trace_set_err_out(libtrace,errno, 382 384 "write(%s)",libtrace->uridata); … … 385 387 386 388 size=ntohs(erfptr->rlen)-(dag_record_size+pad); 387 numbytes=libtrace_io_write(OUTPUT.file, buffer, size);389 numbytes=libtrace_io_write(OUTPUT.file, buffer, (size_t)size); 388 390 if (numbytes != size) { 389 391 trace_set_err_out(libtrace,errno, … … 434 436 { 435 437 int numbytes = 0; 436 int pad = 0;438 unsigned int pad = 0; 437 439 dag_record_t *dag_hdr = (dag_record_t *)packet->header; 438 440 void *payload = packet->payload; … … 589 591 } 590 592 591 static struct libtrace_format_t erf = {593 static struct libtrace_format_t erfformat = { 592 594 "erf", 593 595 "$Id$", … … 626 628 627 629 void erf_constructor(void) { 628 register_format(&erf );629 } 630 register_format(&erfformat); 631 } -
lib/format_helper.c
r2a1a502 r4bd8a5b 32 32 #include <sys/types.h> 33 33 #include <fcntl.h> /* for O_LARGEFILE */ 34 #include <math.h> 34 35 #include "libtrace.h" 35 36 #include "libtrace_int.h" … … 112 113 113 114 ts=trace_get_seconds(trace->event.packet); 114 if ( trace->event.tdelta!=0.0) {115 if (fabs(trace->event.tdelta)<1e-9) { 115 116 /* Get the adjusted current time */ 116 117 gettimeofday(&stv, NULL); -
lib/format_legacy.c
rcab58c5 r4bd8a5b 116 116 if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { 117 117 packet->buf_control = TRACE_CTRL_PACKET; 118 packet->buffer=malloc( LIBTRACE_PACKET_BUFSIZE);118 packet->buffer=malloc((size_t)LIBTRACE_PACKET_BUFSIZE); 119 119 } 120 120 buffer = packet->buffer; … … 136 136 if ((numbytes=libtrace_io_read(INPUT.file, 137 137 buffer, 138 64)) != 64) {138 (size_t)64)) != 64) { 139 139 if (numbytes!=0) { 140 140 trace_set_err(libtrace,errno,"read(%s)",libtrace->uridata); -
lib/format_linux.c
r496b8e5 r4bd8a5b 118 118 if (bind(FORMAT(libtrace->format_data)->fd, 119 119 (struct sockaddr*)&addr, 120 sizeof(addr))==-1) {120 (socklen_t)sizeof(addr))==-1) { 121 121 free(libtrace->format_data); 122 122 return -1; … … 151 151 SO_TIMESTAMP, 152 152 &one, 153 sizeof(one))==-1) {153 (socklen_t)sizeof(one))==-1) { 154 154 perror("setsockopt(SO_TIMESTAMP)"); 155 155 } … … 237 237 238 238 if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { 239 packet->buffer = malloc( LIBTRACE_PACKET_BUFSIZE);239 packet->buffer = malloc((size_t)LIBTRACE_PACKET_BUFSIZE); 240 240 packet->buf_control = TRACE_CTRL_PACKET; 241 241 } … … 303 303 hdr.sll_pkttype = 0; 304 304 hdr.sll_halen = htons(6); /* FIXME */ 305 memcpy(hdr.sll_addr,packet->payload, hdr.sll_halen);305 memcpy(hdr.sll_addr,packet->payload,(size_t)hdr.sll_halen); 306 306 307 307 return sendto(DATAOUT(trace)->fd, … … 309 309 trace_get_capture_length(packet), 310 310 0, 311 (struct sockaddr*)&hdr, sizeof(hdr));311 (struct sockaddr*)&hdr, (socklen_t)sizeof(hdr)); 312 312 313 313 } -
lib/format_pcapfile.c
r6ef54f6 r4bd8a5b 215 215 216 216 if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { 217 packet->buffer = malloc( LIBTRACE_PACKET_BUFSIZE);217 packet->buffer = malloc((size_t)LIBTRACE_PACKET_BUFSIZE); 218 218 packet->buf_control = TRACE_CTRL_PACKET; 219 219 } … … 237 237 err=libtrace_io_read(DATA(libtrace)->file, 238 238 (char*)packet->buffer+sizeof(libtrace_pcapfile_pkt_hdr_t), 239 swapl(libtrace,((libtrace_pcapfile_pkt_hdr_t*)packet->buffer)->caplen)239 (size_t)swapl(libtrace,((libtrace_pcapfile_pkt_hdr_t*)packet->buffer)->caplen) 240 240 ); 241 241 … … 447 447 } 448 448 pcapptr = (libtrace_pcapfile_pkt_hdr_t *)packet->header; 449 pcapptr->caplen = swapl(packet->trace, size);449 pcapptr->caplen = swapl(packet->trace,(uint32_t)size); 450 450 return trace_get_capture_length(packet); 451 451 } -
lib/format_rt.c
reb1aab2 r4bd8a5b 53 53 #define RT_INFO ((struct rt_format_data_t*)libtrace->format_data) 54 54 55 static char *rt_deny_reason(uint8_t reason) { 55 static char *rt_deny_reason(enum rt_conn_denied_t reason) 56 { 56 57 char *string = 0; 57 58 … … 111 112 } 112 113 114 memset(&remote,0, sizeof(remote)); 113 115 remote.sin_family = AF_INET; 114 116 remote.sin_port = htons(RT_INFO->port); 115 117 remote.sin_addr = *((struct in_addr *)he->h_addr); 116 memset(&(remote.sin_zero), 0, 8);117 118 118 119 if (connect(RT_INFO->input_fd, (struct sockaddr *)&remote, 119 sizeof(struct sockaddr)) == -1) {120 (socklen_t)sizeof(struct sockaddr)) == -1) { 120 121 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 121 122 "Could not connect to host %s on port %d", … … 217 218 RT_INFO->hostname = 218 219 (char *)strndup(uridata, 219 (s can - uridata));220 (size_t)(scan - uridata)); 220 221 RT_INFO->port = 221 222 atoi(++scan); … … 284 285 } 285 286 286 #define RT_BUF_SIZE 4000 287 288 static int rt_read(libtrace_t *libtrace, void **buffer, size_t len, int block) { 287 #define RT_BUF_SIZE 4000U 288 289 static int rt_read(libtrace_t *libtrace, void **buffer, size_t len, int block) 290 { 289 291 int numbytes; 290 292 … … 292 294 293 295 if (!RT_INFO->pkt_buffer) { 294 RT_INFO->pkt_buffer = malloc( RT_BUF_SIZE);296 RT_INFO->pkt_buffer = malloc((size_t)RT_BUF_SIZE); 295 297 RT_INFO->buf_current = RT_INFO->pkt_buffer; 296 298 RT_INFO->buf_filled = 0; … … 441 443 char *buf_ptr; 442 444 int numbytes = 0; 443 unsigned int to_write = 0;445 size_t to_write = 0; 444 446 rt_header_t *hdr; 445 447 rt_ack_t *ack_hdr; … … 516 518 517 519 if (packet->type >= TRACE_RT_DATA_SIMPLE) { 518 if (rt_read(libtrace, &packet->buffer, RT_INFO->rt_hdr.length,blocking) != RT_INFO->rt_hdr.length) { 520 if (rt_read(libtrace, 521 &packet->buffer, 522 (size_t)RT_INFO->rt_hdr.length, 523 blocking) != RT_INFO->rt_hdr.length) { 519 524 return -1; 520 525 } … … 538 543 case TRACE_RT_STATUS: 539 544 if (rt_read(libtrace, &packet->buffer, 540 RT_INFO->rt_hdr.length, blocking) != 545 (size_t)RT_INFO->rt_hdr.length, 546 blocking) != 541 547 RT_INFO->rt_hdr.length) { 542 548 return -1; … … 548 554 case TRACE_RT_DUCK_2_5: 549 555 if (rt_read(libtrace, &packet->buffer, 550 RT_INFO->rt_hdr.length, blocking) != 556 (size_t)RT_INFO->rt_hdr.length, 557 blocking) != 551 558 RT_INFO->rt_hdr.length) { 552 559 return -1; -
lib/format_wag.c
rcab58c5 r4bd8a5b 92 92 93 93 static int wag_init_input(libtrace_t *libtrace) { 94 libtrace->format_data = calloc( 1, sizeof(struct wag_format_data_t));95 94 libtrace->format_data = calloc((size_t)1, 95 sizeof(struct wag_format_data_t)); 96 96 return 0; 97 97 } … … 123 123 static int wtf_init_input(libtrace_t *libtrace) 124 124 { 125 libtrace->format_data = calloc(1,sizeof(struct wag_format_data_t)); 125 libtrace->format_data = calloc((size_t)1, 126 sizeof(struct wag_format_data_t)); 126 127 return 0; 127 128 } … … 216 217 size_t framesize; 217 218 char *buf_ptr = (char *)buffer; 218 unsigned int to_read = 0;219 size_t to_read = 0; 219 220 uint16_t magic = 0; 220 221 long fd_flags; … … 295 296 296 297 while (to_read>0) { 297 int ret=read(INPUT.fd,buf_ptr, to_read);298 int ret=read(INPUT.fd,buf_ptr,(size_t)to_read); 298 299 299 300 if (ret == -1) { … … 322 323 if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) { 323 324 packet->buf_control = TRACE_CTRL_PACKET; 324 packet->buffer = malloc( LIBTRACE_PACKET_BUFSIZE);325 packet->buffer = malloc((size_t)LIBTRACE_PACKET_BUFSIZE); 325 326 } 326 327 … … 330 331 331 332 if ((numbytes = wag_read(libtrace, (void *)packet->buffer, 332 RP_BUFSIZE, block_flag)) <= 0) {333 (size_t)RP_BUFSIZE, block_flag)) <= 0) { 333 334 334 335 return numbytes; … … 354 355 if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) { 355 356 packet->buf_control = TRACE_CTRL_PACKET; 356 packet->buffer = malloc( LIBTRACE_PACKET_BUFSIZE);357 packet->buffer = malloc((size_t)LIBTRACE_PACKET_BUFSIZE); 357 358 } 358 359 packet->type = TRACE_RT_DATA_WAG; … … 385 386 assert(size > 0); 386 387 387 if ((numbytes=libtrace_io_read(INPUT.file, buffer2, size)) != size) { 388 if ((numbytes=libtrace_io_read(INPUT.file, buffer2, (size_t)size)) 389 != size) { 388 390 trace_set_err(libtrace, 389 391 errno,"read(%s,buffer)",packet->trace->uridata); -
lib/libtrace.h.in
r7dd71f0 r4bd8a5b 930 930 libtrace_ip_t *trace_get_ip(libtrace_packet_t *packet); 931 931 932 /** get a pointer to the IPv6 header (if any) 933 * @param packet the packet opaque pointer 934 * 935 * @return a pointer to the IPv6 header, or NULL if there is no IPv6 header 936 */ 937 DLLEXPORT SIMPLE_FUNCTION 938 libtrace_ip6_t *trace_get_ip6(libtrace_packet_t *packet); 939 932 940 /** Gets a pointer to the transport layer header (if any) 933 941 * @param packet a pointer to a libtrace_packet structure -
lib/libtrace_int.h
r5d56d34 r4bd8a5b 112 112 #endif 113 113 114 #define RP_BUFSIZE 65536 114 #define RP_BUFSIZE 65536U 115 115 116 116 struct libtrace_event_status_t { … … 134 134 * doesn't support filters natively 135 135 */ 136 unsigned int snaplen; /**< used by libtrace if the module136 size_t snaplen; /**< used by libtrace if the module 137 137 * doesn't support snapping natively 138 138 */ … … 359 359 libtrace_rt_types_t pcap_dlt_to_rt(libtrace_dlt_t dlt); 360 360 libtrace_dlt_t rt_to_pcap_dlt(libtrace_rt_types_t rt_type); 361 libtrace_linktype_t erf_type_to_libtrace( charerf);362 charlibtrace_to_erf_type(libtrace_linktype_t linktype);361 libtrace_linktype_t erf_type_to_libtrace(uint8_t erf); 362 uint8_t libtrace_to_erf_type(libtrace_linktype_t linktype); 363 363 libtrace_linktype_t arphrd_type_to_libtrace(unsigned int); 364 364 unsigned int libtrace_to_arphrd_type(libtrace_linktype_t); -
lib/libtraceio-zlib.c
reecda9f r4bd8a5b 10 10 ssize_t libtrace_io_read(libtrace_io_t *io, void *buf, size_t len) 11 11 { 12 int err=gzread(io->file,buf, len);12 int err=gzread(io->file,buf,(unsigned) len); 13 13 int err2=errno; 14 14 if (err>=0) { … … 63 63 ssize_t libtrace_io_write(libtrace_io_t *io, const void *buf, size_t len) 64 64 { 65 return (ssize_t)gzwrite(io->file,buf, len);65 return (ssize_t)gzwrite(io->file,buf,(unsigned)len); 66 66 } 67 67 -
lib/link_wireless.c
r73da4ae r4bd8a5b 61 61 p = (uint8_t *) &(rtap->it_present); 62 62 63 while ( bswap_le_to_host32(*((uint32_t*)p)) & (1 << TRACE_RADIOTAP_EXT) ) {63 while ( bswap_le_to_host32(*((uint32_t*)p)) & (1U << TRACE_RADIOTAP_EXT) ) { 64 64 p += sizeof (uint32_t); 65 65 } -
lib/linktypes.c
re7d66bf r4bd8a5b 101 101 } 102 102 103 libtrace_linktype_t erf_type_to_libtrace( charerf)103 libtrace_linktype_t erf_type_to_libtrace(uint8_t erf) 104 104 { 105 105 switch (erf) { … … 112 112 } 113 113 114 charlibtrace_to_erf_type(libtrace_linktype_t linktype)114 uint8_t libtrace_to_erf_type(libtrace_linktype_t linktype) 115 115 { 116 116 switch(linktype) { … … 131 131 break; 132 132 } 133 return -1;133 return 255; 134 134 } 135 135 … … 261 261 memcpy(tmp+sizeof(libtrace_pcapfile_pkt_hdr_t), 262 262 packet->payload, 263 remaining);263 (size_t)remaining); 264 264 if (packet->buf_control == TRACE_CTRL_EXTERNAL) { 265 265 packet->buf_control=TRACE_CTRL_PACKET; … … 300 300 memcpy(tmp+sizeof(libtrace_pcapfile_pkt_hdr_t), 301 301 packet->payload, 302 remaining);302 (size_t)remaining); 303 303 if (packet->buf_control == TRACE_CTRL_EXTERNAL) { 304 304 packet->buf_control=TRACE_CTRL_PACKET; -
lib/trace.c
r778d459 r4bd8a5b 224 224 pcap_constructor(); 225 225 #endif 226 #if HAVE_BIOCSETIF226 #ifdef HAVE_BIOCSETIF 227 227 bpf_constructor(); 228 228 #endif … … 252 252 } 253 253 254 #define RP_BUFSIZE 65536 255 #define URI_PROTO_LINE 16 254 #define URI_PROTO_LINE 16U 256 255 257 256 … … 375 374 xstrncpy(scan, uri, strlen(uri)); 376 375 } else { 377 xstrncpy(scan,uri, ( uridata - uri));376 xstrncpy(scan,uri, (size_t)(uridata - uri)); 378 377 } 379 378 … … 606 605 { 607 606 libtrace_packet_t *packet = 608 (libtrace_packet_t*)calloc( 1,sizeof(libtrace_packet_t));607 (libtrace_packet_t*)calloc((size_t)1,sizeof(libtrace_packet_t)); 609 608 packet->buf_control=TRACE_CTRL_PACKET; 610 609 return packet; … … 966 965 } 967 966 pcap=(pcap_t *)pcap_open_dead( 968 libtrace_to_pcap_dlt(linktype),969 1500 );967 (int)libtrace_to_pcap_dlt(linktype), 968 1500U); 970 969 /* build filter */ 971 970 if (pcap_compile( pcap, &filter->filter, filter->filterstring, … … 1234 1233 } 1235 1234 1236 *format=xstrndup(uri, ( uridata - uri));1235 *format=xstrndup(uri, (size_t)(uridata - uri)); 1237 1236 1238 1237 /* push uridata past the delimiter */ … … 1397 1396 if (!buf2) 1398 1397 buf2=staticbuf; 1399 snprintf(buf2, 18,"%02x:%02x:%02x:%02x:%02x:%02x",1398 snprintf(buf2,(size_t)18,"%02x:%02x:%02x:%02x:%02x:%02x", 1400 1399 addr[0],addr[1],addr[2], 1401 1400 addr[3],addr[4],addr[5]); … … 1447 1446 packet->payload=(void*)((char*)packet->buffer+sizeof(hdr)); 1448 1447 memcpy(packet->header,&hdr,sizeof(hdr)); 1449 memcpy(packet->payload,data, len);1448 memcpy(packet->payload,data,(size_t)len); 1450 1449 packet->type=pcap_dlt_to_rt(libtrace_to_pcap_dlt(linktype)); 1451 1450 }
Note: See TracChangeset
for help on using the changeset viewer.