Changeset 1298
- Timestamp:
- 11/06/07 14:55:03 (6 years ago)
- Location:
- trunk/lib
- Files:
-
- 3 edited
-
libtrace.h.in (modified) (1 diff)
-
protocols_l2.c (modified) (2 diffs)
-
trace.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/libtrace.h.in
r1296 r1298 202 202 TRACE_ERR_OPTION_UNAVAIL= -6, 203 203 /** This feature is unsupported */ 204 TRACE_ERR_UNSUPPORTED = -7 204 TRACE_ERR_UNSUPPORTED = -7, 205 /** Illegal use of the API */ 206 TRACE_ERR_BAD_STATE = -8 205 207 }; 206 208 -
trunk/lib/protocols_l2.c
r1290 r1298 32 32 uint32_t *remaining) 33 33 { 34 assert(type && "You must pass a type in!");35 36 34 if (*type == 0x8100) { 37 35 libtrace_8021q_t *vlanhdr = (libtrace_8021q_t *)ethernet; … … 59 57 uint16_t *type, uint32_t *remaining) 60 58 { 61 assert(type && "You must pass a type in!");62 63 59 if (*type == 0x8847) { 64 60 if ((((char*)ethernet)[2]&0x01)==0) { -
trunk/lib/trace.c
r1289 r1298 130 130 131 131 void register_format(struct libtrace_format_t *f) { 132 assert(f->next==NULL); 132 assert(f->next==NULL); /* Can't register a format twice */ 133 133 f->next=formats_list; 134 134 formats_list=f; … … 463 463 break; 464 464 default: 465 assert(!" init_output() should return -1 for failure, or 0 for success");465 assert(!"Internal error: init_output() should return -1 for failure, or 0 for success"); 466 466 } 467 467 } else { … … 486 486 { 487 487 assert(libtrace); 488 assert(!trace_is_err(libtrace) && "Please use trace_is_err to check for errors after calling trace_create!"); 488 if (trace_is_err(libtrace)) 489 return -1; 489 490 if (libtrace->format->start_input) { 490 491 int ret=libtrace->format->start_input(libtrace); … … 515 516 { 516 517 assert(libtrace); 517 assert(libtrace->started && "BUG: Called trace_pause without calling trace_start first"); 518 if (!libtrace->started) { 519 trace_set_err(libtrace,TRACE_ERR_BAD_STATE, "You must call trace_start() before calling trace_pause()"); 520 return -1; 521 } 518 522 if (libtrace->format->pause_input) 519 523 libtrace->format->pause_input(libtrace); … … 528 532 int ret; 529 533 libtrace_err_t err; 530 531 assert(!trace_is_err(libtrace) && "Please use trace_is_err to check for errors after calling trace_create!"); 534 535 if (trace_is_err(libtrace)) { 536 return -1; 537 } 532 538 533 539 if (libtrace->format->config_input) { … … 698 704 699 705 assert(libtrace && "You called trace_read_packet() with a NULL libtrace parameter!\n"); 700 assert(libtrace->started && "BUG: You must call libtrace_start() before trace_read_packet()\n"); 706 if (trace_is_err(libtrace)) 707 return -1; 708 if (!libtrace->started) { 709 trace_set_err(libtrace,TRACE_ERR_BAD_STATE,"You must call libtrace_start() before trace_read_packet()\n"); 710 return -1; 711 } 712 if (packet->buf_control==TRACE_CTRL_PACKET || packet->buf_control==TRACE_CTRL_EXTERNAL) { 713 trace_set_err(libtrace,TRACE_ERR_BAD_STATE,"Packet passed to trace_read_packet() is invalid\n"); 714 return -1; 715 } 701 716 assert(packet); 702 assert((packet->buf_control==TRACE_CTRL_PACKET || packet->buf_control==TRACE_CTRL_EXTERNAL)&&703 "BUG: You must allocate a packet using packet_create()");704 717 705 718 /* Store the trace we are reading from into the packet opaque … … 758 771 assert(packet); 759 772 /* Verify the packet is valid */ 760 assert(libtrace->started); 773 if (!libtrace->started) { 774 trace_set_err_out(libtrace,TRACE_ERR_BAD_STATE, 775 "Trace is not started before trace_write_packet"); 776 return -1; 777 } 761 778 762 779 if (libtrace->format->write_packet) { … … 1085 1102 return 0; 1086 1103 #else 1087 assert(!" This shouldnever be called when BPF not enabled");1104 assert(!"Internal bug: This never be called when BPF not enabled"); 1088 1105 trace_set_err(packet->trace,TRACE_ERR_OPTION_UNAVAIL, 1089 1106 "Feature unavailable");
Note: See TracChangeset
for help on using the changeset viewer.
