|
NAMElibscamperfile —
scamper warts file library
LIBRARYscamper warts file library (libscamperfile -lscamperfile)SYNOPSIS#include <scamper_file.h>
#include <scamper_addr.h>
#include <scamper_list.h>
#include <scamper_icmpext.h>
#include <scamper_trace.h>
#include <scamper_ping.h>
#include <scamper_tracelb.h>
#include <scamper_dealias.h>
#include
<scamper_neighbourdisc.h>
#include <scamper_tbit.h>
#include <scamper_sting.h>
#include <scamper_sniff.h>
DESCRIPTIONThelibscamperfile library provides the ability to read
and write warts files produced by scamper, read arts files produced by CAIDA's
Skitter, and write simple text representations of these data. A program that
uses libscamperfile to read a warts file (1) allocates a filter defining the
types of data contained in the file the program is interested in, (2) opens
the file, (3) reads each object from the file until end of file is reached,
(4) closes the file and frees the filter. A program that uses libscamperfile
is responsible for freeing the data returned.
ROUTINESscamper_file_t *scamper_file_filter_alloc (uint16_t
*types, uint16_t num)
Allocate a filter to use with scamper_file_read () that
specifies the types of data the program is interested in with the types
parameter, and the number of types in the num parameter. When the filter is no
longer required, the caller should use
scamper_file_filter_free () to free the filter. For
each data type specified the caller is subsequently responsible for freeing
the data object when it is no longer required. Valid data type values to
specify in the types array are:
void
int
scamper_file_t *
scamper_file_t *
scamper_file_t *
void
void
int
void
EXAMPLEThe following opens the file specified by name, reads all traceroute and ping data until end of file, processes the data, calls the appropriate methods to free the data, and then closes the file.uint16_t types[] = { SCAMPER_FILE_OBJ_TRACE, SCAMPER_FILE_OBJ_PING, }; scamper_file_t *in; scamper_file_filter_t *filter; scamper_trace_t *trace; scamper_ping_t *ping; uint16_t type; void *data; if((filter = scamper_file_filter_alloc(types, 2)) == NULL) { fprintf(stderr, "could not allocate filter\n"); return -1; } if((in = scamper_file_open(name, 'r', NULL)) == NULL) { fprintf(stderr, "could not open %s: %s\n", name, strerror(errno)); return -1; } while(scamper_file_read(in, filter, &type, (void *)&data) == 0) { if(data == NULL) break; /* EOF */ switch(type) { case SCAMPER_FILE_OBJ_TRACE: trace = data; process_trace(trace); scamper_trace_free(trace); break; case SCAMPER_FILE_OBJ_PING: ping = data; process_ping(ping); scamper_ping_free(ping); break; } } scamper_file_close(in); scamper_file_filter_free(filter); SEE ALSOscamper(1), sc_wartsdump(1), sc_warts2text(1),M. Luckie, Scamper: a Scalable and Extensible Packet Prober for Active Measurement of the Internet, Proc. ACM/SIGCOMM Internet Measurement Conference 2010. AUTHORSlibscamperfile was written by Matthew Luckie
<mjl@luckie.org.nz>.
Visit the GSP FreeBSD Man Page Interface. |