Changeset ffc8c8d
- Timestamp:
- 08/11/05 11:30:41 (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:
- 4d5a9a7
- Parents:
- a8ba977
- Location:
- lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_erf.c
r39b37d2 rffc8c8d 139 139 // DEVICE 140 140 libtrace->sourcetype = DEVICE; 141 if((INPUT.fd = 142 dag_open(CONNINFO.path)) < 0) { 141 if((INPUT.fd = dag_open(CONNINFO.path)) < 0) { 143 142 fprintf(stderr,"Cannot open DAG %s: %m\n", 144 143 CONNINFO.path,errno); 145 144 exit(0); 146 145 } 147 if((DAG.buf = (void *) 148 dag_mmap(INPUT.fd)) == MAP_FAILED) { 146 if((DAG.buf = (void *)dag_mmap(INPUT.fd)) == MAP_FAILED) { 149 147 fprintf(stderr,"Cannot mmap DAG %s: %m\n", 150 148 CONNINFO.path,errno); … … 161 159 return 0; 162 160 } 161 return 1; 163 162 } 164 163 #endif … … 225 224 } 226 225 } 226 return 1; 227 227 } 228 228 … … 276 276 return 0; 277 277 } 278 return 1; 278 279 } 279 280 … … 312 313 } 313 314 314 315 return 1; 315 316 } 316 317 … … 346 347 if (!OUTPUT.rtserver) 347 348 return 0; 348 349 350 return 1; 349 351 } 350 352 -
lib/format_pcap.c
r72bfe20 rffc8c8d 34 34 #include "libtrace_int.h" 35 35 #include "format_helper.h" 36 #include <inttypes.h> 36 37 #ifdef HAVE_INTTYPES_H 38 # include <inttypes.h> 39 #else 40 # error "Can't find inttypes.h - this needs to be fixed" 41 #endif 42 37 43 #include <sys/types.h> 38 44 #include <sys/stat.h> … … 114 120 } 115 121 } 116 fprintf(stderr, 117 "Unsupported scheme (%s) for format pcap\n", 118 CONNINFO.path); 119 return 0; 122 //fprintf(stderr, "Unsupported scheme (%s) for format pcap\n", 123 // CONNINFO.path); 124 return 1; 120 125 121 126 } … … 136 141 return 0; 137 142 } 138 143 return 1; 139 144 } 140 145 … … 153 158 154 159 packet->size = numbytes + sizeof(struct pcap_pkthdr); 155 156 } 160 } 161 157 162 static int pcap_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) { 158 163 const u_char *pcappkt; 159 164 int pcapbytes = 0; 160 165 161 while ((pcapbytes = pcap_dispatch(INPUT.pcap,166 pcapbytes = pcap_dispatch(INPUT.pcap, 162 167 1, /* number of packets */ 163 168 &trace_pcap_handler, 164 (u_char *)packet) ) == 0);165 166 if (pcapbytes < 0) {167 return -1;169 (u_char *)packet); 170 171 if (pcapbytes <= 0) { 172 return pcapbytes; 168 173 } 169 174 return (packet->size - sizeof(struct pcap_pkthdr)); -
lib/format_template.c
r39b37d2 rffc8c8d 34 34 #include "config.h" 35 35 36 #include <inttypes.h> 36 #ifdef HAVE_INTTYPES_H 37 # include <inttypes.h> 38 #else 39 # error "Can't find inttypes.h" 40 #endif 37 41 38 42 struct libtrace_format_data_t { -
lib/format_wag.c
r39b37d2 rffc8c8d 47 47 #endif 48 48 #include <sys/types.h> 49 #include <sys/time.h> 50 #include <time.h> 49 51 #include <sys/socket.h> 50 52 #include <sys/un.h> … … 145 147 } 146 148 } 149 return 1; 147 150 } 148 151 … … 239 242 240 243 // wag isn't in network byte order yet 241 size = htons(size);244 //size = htons(size); 242 245 //printf("%d %d\n",size,htons(size)); 243 246 … … 280 283 uint64_t timestamp = 0; 281 284 timestamp = wagptr->ts.subsecs; 282 timestamp |= (uint64_t)wagptr->ts.secs<<32;285 //timestamp |= (uint64_t)wagptr->ts.secs<<32; 283 286 timestamp = ((timestamp%44000000)*(UINT_MAX/44000000)) 284 287 | ((timestamp/44000000)<<32); … … 288 291 static int wag_get_capture_length(const struct libtrace_packet_t *packet) { 289 292 struct wag_data_frame *wagptr = (struct wag_data_frame *)packet->buffer; 290 return (wagptr->hdr.size);291 //return ntohs(wagptr->hdr.size);293 //return (wagptr->hdr.size); 294 return ntohs(wagptr->hdr.size); 292 295 } 293 296 294 297 static int wag_get_wire_length(const struct libtrace_packet_t *packet) { 295 298 struct wag_data_frame *wagptr = (struct wag_data_frame *)packet->buffer; 296 return (wagptr->hdr.size);297 //return ntohs(wagptr->hdr.size);299 //return (wagptr->hdr.size); 300 return ntohs(wagptr->hdr.size); 298 301 } 299 302 … … 340 343 wag_get_direction, /* get_direction */ 341 344 NULL, /* set_direction */ 342 wag_get_erf_timestamp, /* get_ wag_timestamp */345 wag_get_erf_timestamp, /* get_erf_timestamp */ 343 346 NULL, /* get_timeval */ 344 347 NULL, /* get_seconds */ -
lib/libtrace.h
ra114d8b5 rffc8c8d 36 36 37 37 /** API version as 3 byte hex digits */ 38 #define LIBTRACE_API_VERSION 0x01001 038 #define LIBTRACE_API_VERSION 0x010014 39 39 40 40 #ifdef __cplusplus … … 94 94 uint8_t status; 95 95 }; 96 97 /** Enumeration of error codes */ 98 enum {E_NOERROR, E_BAD_FORMAT, E_NO_INIT, E_NO_INIT_OUT, E_URI_LONG, E_URI_NOCOLON, E_INIT_FAILED }; 96 99 97 100 /** Structure for dealing with IP packets */ … … 195 198 void trace_help(); 196 199 197 void trace_perror(); 200 /** Prints error information 201 * 202 * Prints out a descriptive error message for the currently set trace_err value 203 */ 204 void trace_perror(char *caller); 198 205 199 206 /** Create a trace file from a URI -
lib/libtrace_int.h
r72bfe20 rffc8c8d 72 72 73 73 typedef enum {SOCKET, TRACE, STDIN, DEVICE, INTERFACE, RT } source_t; 74 75 76 static struct { 77 int err_num; // error code 78 char *problem; // the format, uri etc that caused the error for reporting purposes 79 } trace_err; 80 74 81 75 82 #define RP_BUFSIZE 65536 -
lib/trace.c
r3dcc2e2 rffc8c8d 113 113 #endif 114 114 115 //#if HAVE_PCAP_H116 //# include <pcap.h>117 //# ifdef HAVE_PCAP_INT_H118 //# include <pcap-int.h>119 //# endif120 //#endif121 122 //#ifdef HAVE_ZLIB_H123 //# include <zlib.h>124 //#endif125 126 127 //#include "wag.h"128 129 //#ifdef HAVE_DAG_API130 //# include "dagnew.h"131 //# include "dagapi.h"132 //#else133 //# include "dagformat.h"134 //#endif135 136 115 #include "libtrace_int.h" 137 116 #include "format_helper.h" 138 //#include "format/format_list.h"139 117 #include <err.h> 140 118 141 119 #define MAXOPTS 1024 142 120 143 //typedef enum {SOCKET, TRACE, STDIN, DEVICE, INTERFACE, RT } source_t;144 145 //typedef enum {ERF, PCAP, PCAPINT, DAG, RTCLIENT, WAG, WAGINT } format_e_t;146 147 //typedef enum {RTSERVER, GZERF } output_t;148 121 #if HAVE_BPF 149 122 /** A type encapsulating a bpf filter … … 158 131 #endif 159 132 160 // Error codes 161 enum {E_NOERROR, E_BAD_FORMAT, E_NO_INIT, E_NO_INIT_OUT, E_URI_LONG, E_URI_NOCOLON }; 162 163 static struct { 164 int err_num; // error code 165 char *problem; // the format, uri etc that caused the error for reporting purposes 166 } trace_err; 133 167 134 168 135 struct libtrace_format_t **format_list = 0; … … 216 183 fprintf(stderr, "%s: A uri must contain at least one colon e.g. format:destination\n", caller); 217 184 break; 185 case E_INIT_FAILED: 186 fprintf(stderr, "%s: libtrace failed to initialise (%s)\n",caller,trace_err.problem); 187 218 188 default: 219 189 fprintf(stderr, "Unkown errcode %d\n",trace_err.err_num); … … 310 280 311 281 if (libtrace->format->init_input) { 312 libtrace->format->init_input( libtrace); 282 if (!libtrace->format->init_input( libtrace)) { 283 trace_err.err_num = E_INIT_FAILED; 284 trace_err.problem = scan; 285 return 0; 286 } 313 287 } else { 314 288 trace_err.err_num = E_NO_INIT; … … 382 356 383 357 if (libtrace->format->init_output) { 384 libtrace->format->init_output( libtrace); 358 if(!libtrace->format->init_output( libtrace)) { 359 return 0; 360 } 385 361 } else { 386 362 trace_err.err_num = E_NO_INIT_OUT; … … 460 436 461 437 if (!libtrace) { 462 fprintf(stderr," Oi!You called trace_read_packet() with a NULL libtrace parameter!\n");438 fprintf(stderr,"You called trace_read_packet() with a NULL libtrace parameter!\n"); 463 439 } 464 440 assert(libtrace);
Note: See TracChangeset
for help on using the changeset viewer.