- Timestamp:
- 08/20/04 11:45:32 (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:
- d2e3359
- Parents:
- d907ff5
- Location:
- examples/tracedump
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/tracedump/Makefile
rd907ff5 r5d6ebe1 3 3 CXXFLAGS=-g -Wall $(INCLUDES) -rdynamic 4 4 LDFLAGS=-L/usr/local/wand/lib 5 LDLIBS=-ltrace -ldl 5 LDLIBS=-ltrace -ldl -lpcap -lz 6 6 LINK_LAYERS=$(addsuffix .so,$(basename $(wildcard link_*.cc))) 7 7 ETH_LAYERS=$(addsuffix .so,$(basename $(wildcard eth_*.cc))) 8 8 IP_LAYERS=$(addsuffix .so,$(basename $(wildcard ip_*.cc))) 9 PLUGINS=$(LINK_LAYERS) $(ETH_LAYERS) $(IP_LAYERS) 9 TCP_LAYERS=$(addsuffix .so,$(basename $(wildcard tcp_*.cc))) 10 PLUGINS=$(LINK_LAYERS) $(ETH_LAYERS) $(IP_LAYERS) $(TCP_LAYERS) 10 11 11 all: tracedump $(PLUGINS) 12 all: tracedump $(PLUGINS) asn1-test 12 13 13 14 tracedump: tracedump.cc tracedump-libtrace.o tracedump-lib.o 14 15 16 tcp_1720.so: tcp_1720.cc asn1.o 17 15 18 %.so:%.cc 16 $(CXX) $(CXXFLAGS) -fpic -shared $< -o $@ 19 $(CXX) $(CXXFLAGS) -fpic -shared $^ -o $@ 20 21 asn1-test: CXXFLAGS+=-DTEST 22 asn1-test: asn1.cc 17 23 18 24 clean: 19 25 rm -f *.o tracedump *.so 20 26 27 install: 28 cp *.so $(LIBDIR) 29 21 30 .PHONY: clean all 22 31 -
examples/tracedump/ip_6.cc
rd907ff5 r5d6ebe1 6 6 #include <netinet/tcp.h> 7 7 #include <netinet/in.h> 8 #include <assert.h> 8 9 9 10 #define SAFE(x) \ … … 31 32 switch(*type) { 32 33 case 0: 34 printf(" DEBUG: End of options\n"); 33 35 return 0; 34 36 case 1: 37 printf(" DEBUG: NOP\n"); 35 38 (*ptr)++; 36 39 (*len)--; 37 40 return 1; 38 41 default: 42 printf(" DEBUG: Type %i len %i\n", 43 *type,*(*ptr+1)); 39 44 *optlen = *(*ptr+1); 45 assert(*optlen>0); 40 46 (*len)-=*optlen; 41 47 (*data)=(*ptr+2); … … 76 82 DISPLAYS(urg_ptr," Urgent %i"); 77 83 unsigned char *pkt = (unsigned char*)packet+sizeof(*tcp); 78 int plen = len-sizeof *tcp;84 int plen = (len-sizeof *tcp) <? (tcp->doff*4); 79 85 unsigned char type,optlen,*data; 80 86 while(get_next_option(&pkt,&plen,&type,&optlen,&data)) { -
examples/tracedump/tracedump-libtrace.cc
rd907ff5 r5d6ebe1 9 9 struct libtrace_t *trace = trace_create(argv[1]); 10 10 struct libtrace_packet_t packet; 11 11 struct libtrace_filter_t *filter=NULL; 12 12 13 if (!trace) { 13 14 errx(1,"Failed to open trace"); 14 15 } 15 16 17 if (argc>2) 18 filter=trace_bpf_setfilter(argv[2]); 19 16 20 while(trace_read_packet(trace,&packet)!=-1) { 17 21 time_t sec = (time_t)trace_get_seconds(&packet); 18 22 char *link=(char *)trace_get_link(&packet); 23 if (filter && !trace_bpf_filter(filter,&packet)) 24 continue; 25 19 26 printf("%s",ctime(&sec)); 20 27 per_packet(trace_get_link_type(&packet),
Note: See TracChangeset
for help on using the changeset viewer.