Changeset 72bfe20 for lib/format_pcap.c
- Timestamp:
- 08/08/05 16:33:16 (17 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:
- c3274c6
- Parents:
- 8184acc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_pcap.c
r9e2a109 r72bfe20 33 33 #include "libtrace.h" 34 34 #include "libtrace_int.h" 35 #include "format_helper.h" 35 36 #include <inttypes.h> 36 37 #include <sys/types.h> … … 56 57 57 58 #if HAVE_PCAP 59 60 #define CONNINFO libtrace->format_data->conn_info 61 #define INPUT libtrace->format_data->input 58 62 59 63 struct libtrace_format_data_t { … … 76 80 libtrace->format_data = (struct libtrace_format_data_t *) 77 81 malloc(sizeof(struct libtrace_format_data_t)); 78 libtrace->format_data->conn_info.path = libtrace->uridata; 79 if (!strncmp(libtrace->format_data->conn_info.path,"-",1)) { 80 if ((libtrace->format_data->input.pcap = 81 pcap_open_offline(libtrace->format_data->conn_info.path, 82 CONNINFO.path = libtrace->uridata; 83 84 libtrace->sourcetype = TRACE; 85 if (!strncmp(CONNINFO.path,"-",1)) { 86 if ((INPUT.pcap = 87 pcap_open_offline(CONNINFO.path, 82 88 errbuf)) == NULL) { 83 89 fprintf(stderr,"%s\n",errbuf); … … 85 91 } 86 92 } else { 87 if (stat( libtrace->format_data->conn_info.path,&buf) == -1) {93 if (stat(CONNINFO.path,&buf) == -1) { 88 94 perror("stat"); 89 95 return 0; 90 96 } 91 97 if (S_ISCHR(buf.st_mode)) { 92 if (( libtrace->format_data->input.pcap =93 pcap_open_live( libtrace->format_data->conn_info.path,98 if ((INPUT.pcap = 99 pcap_open_live(CONNINFO.path, 94 100 4096, 95 101 1, … … 100 106 } 101 107 } else { 102 if (( libtrace->format_data->input.pcap =103 pcap_open_offline( libtrace->format_data->conn_info.path,108 if ((INPUT.pcap = 109 pcap_open_offline(CONNINFO.path, 104 110 errbuf)) == NULL) { 105 111 fprintf(stderr,"%s\n",errbuf); … … 110 116 fprintf(stderr, 111 117 "Unsupported scheme (%s) for format pcap\n", 112 libtrace->format_data->conn_info.path);118 CONNINFO.path); 113 119 return 0; 114 120 … … 117 123 static int pcapint_init_input(struct libtrace_t *libtrace) { 118 124 char errbuf[PCAP_ERRBUF_SIZE]; 119 if ((libtrace->format_data->input.pcap = 120 pcap_open_live(libtrace->format_data->conn_info.path, 125 libtrace->format_data = (struct libtrace_format_data_t *) 126 malloc(sizeof(struct libtrace_format_data_t)); 127 CONNINFO.path = libtrace->uridata; 128 libtrace->sourcetype = INTERFACE; 129 if ((INPUT.pcap = 130 pcap_open_live(CONNINFO.path, 121 131 4096, 122 132 1, … … 149 159 int pcapbytes = 0; 150 160 151 while ((pcapbytes = pcap_dispatch( libtrace->format_data->input.pcap,161 while ((pcapbytes = pcap_dispatch(INPUT.pcap, 152 162 1, /* number of packets */ 153 163 &trace_pcap_handler, … … 274 284 } 275 285 286 static int pcap_get_fd(struct libtrace_packet_t *packet) { 287 return pcap_fileno(packet->trace->format_data->input.pcap); 288 } 289 276 290 static void pcap_help() { 277 291 printf("pcap format module: $Revision$\n"); … … 307 321 pcap_fin_input, /* fin_input */ 308 322 NULL, /* fin_output */ 309 NULL, /* read */310 323 pcap_read_packet, /* read_packet */ 311 324 NULL, /* write_packet */ … … 320 333 pcap_get_wire_length, /* get_wire_length */ 321 334 pcap_set_capture_length, /* set_capture_length */ 335 NULL, /* get_fd */ 336 trace_event_trace, /* trace_event */ 322 337 pcap_help /* help */ 323 338 }; … … 331 346 pcap_fin_input, /* fin_input */ 332 347 NULL, /* fin_output */ 333 NULL, /* read */334 348 pcap_read_packet, /* read_packet */ 335 349 NULL, /* write_packet */ … … 344 358 pcap_get_wire_length, /* get_wire_length */ 345 359 pcap_set_capture_length, /* set_capture_length */ 360 pcap_get_fd, /* get_fd */ 361 trace_event_device, /* trace_event */ 346 362 pcapint_help /* help */ 347 363 };
Note: See TracChangeset
for help on using the changeset viewer.