Changeset d5879cc for lib/trace.c
- Timestamp:
- 02/27/06 16:40:19 (16 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:
- 8a8e54b
- Parents:
- ab4cb04
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
rab4cb04 rd5879cc 158 158 } 159 159 format_list[nformats] = f; 160 /* Now, verify things */ 161 if (format_list[nformats]->init_input) { 162 #define REQUIRE(x) \ 163 if (!format_list[nformats]->x) \ 164 fprintf(stderr,"%s: Input format should provide " #x "\n",format_list[nformats]->name) 165 REQUIRE(read_packet); 166 REQUIRE(start_input); 167 REQUIRE(config_input); 168 REQUIRE(pause_input); 169 REQUIRE(fin_input); 170 REQUIRE(get_link_type); 171 REQUIRE(get_capture_length); 172 REQUIRE(get_wire_length); 173 REQUIRE(get_framing_length); 174 REQUIRE(trace_event); 175 if (!format_list[nformats]->get_erf_timestamp 176 && !format_list[nformats]->get_seconds 177 && !format_list[nformats]->get_timeval) { 178 fprintf(stderr,"%s: A trace format capable of input, should provide at least one of\n" 179 "get_erf_timestamp, get_seconds or trace_timeval\n",format_list[nformats]->name); 180 } 181 #undef REQUIRE 182 } 183 else { 184 #define REQUIRE(x) \ 185 if (format_list[nformats]->x) \ 186 fprintf(stderr,"%s: Non Input format shouldn't need " #x "\n",format_list[nformats]->name) 187 REQUIRE(read_packet); 188 REQUIRE(start_input); 189 REQUIRE(pause_input); 190 REQUIRE(fin_input); 191 REQUIRE(get_link_type); 192 REQUIRE(get_capture_length); 193 REQUIRE(get_wire_length); 194 REQUIRE(get_framing_length); 195 REQUIRE(trace_event); 196 #undef REQUIRE 197 } 198 if (format_list[nformats]->init_output) { 199 #define REQUIRE(x) \ 200 if (!format_list[nformats]->x) \ 201 fprintf(stderr,"%s: Output format should provide " #x "\n",format_list[nformats]->name) 202 REQUIRE(write_packet); 203 REQUIRE(start_output); 204 REQUIRE(config_output); 205 REQUIRE(fin_output); 206 #undef REQUIRE 207 } 208 else { 209 #define REQUIRE(x) \ 210 if (format_list[nformats]->x) \ 211 fprintf(stderr,"%s: Non Output format shouldn't need " #x "\n",format_list[nformats]->name) 212 REQUIRE(write_packet); 213 REQUIRE(start_output); 214 REQUIRE(config_output); 215 REQUIRE(fin_output); 216 #undef REQUIRE 217 } 160 218 nformats++; 161 219 } … … 256 314 257 315 if (libtrace->format->init_input) { 258 if (!libtrace->format->init_input(libtrace)) { 316 int err=libtrace->format->init_input(libtrace); 317 assert (err==-1 || err==0); 318 if (err==-1) { 259 319 /* init_input should call trace_set_err to set 260 320 * the error message … … 615 675 } 616 676 617 /* get a pointer to the link layer618 * @param packet a pointer to a libtrace_packet structure619 *620 * @returns a pointer to the link layer, or NULL if there is no link layer621 *622 * @note you should call trace_get_link_type() to find out what type of link layer this is623 */624 677 void *trace_get_link(const struct libtrace_packet_t *packet) { 625 678 return (void *)packet->payload; … … 1293 1346 if (filter->filterstring && ! filter->flag) { 1294 1347 pcap_t *pcap; 1348 libtrace_linktype_t linktype=trace_get_link_type(packet); 1349 if (linktype==(libtrace_linktype_t)-1) { 1350 trace_set_err(packet->trace,TRACE_ERR_BAD_PACKET, 1351 "Packet has an unknown linktype"); 1352 return -1; 1353 } 1354 if (libtrace_to_pcap_dlt(linktype) == -1) { 1355 trace_set_err(packet->trace,TRACE_ERR_BAD_PACKET, 1356 "Unknown pcap equivilent linktype"); 1357 return -1; 1358 } 1295 1359 pcap=(pcap_t *)pcap_open_dead( 1296 libtrace_to_pcap_dlt( trace_get_link_type(packet)),1360 libtrace_to_pcap_dlt(linktype), 1297 1361 1500); 1298 1362 /* build filter */
Note: See TracChangeset
for help on using the changeset viewer.