Changeset 5d6ebe1


Ignore:
Timestamp:
08/20/04 11:45:32 (16 years ago)
Author:
Perry Lorier <perry@…>
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
Message:

Added asn1 parsing
Started fixing bug with tcp option parsing

Location:
examples/tracedump
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • examples/tracedump/Makefile

    rd907ff5 r5d6ebe1  
    33CXXFLAGS=-g -Wall $(INCLUDES) -rdynamic
    44LDFLAGS=-L/usr/local/wand/lib
    5 LDLIBS=-ltrace -ldl
     5LDLIBS=-ltrace -ldl -lpcap -lz
    66LINK_LAYERS=$(addsuffix .so,$(basename $(wildcard link_*.cc)))
    77ETH_LAYERS=$(addsuffix .so,$(basename $(wildcard eth_*.cc)))
    88IP_LAYERS=$(addsuffix .so,$(basename $(wildcard ip_*.cc)))
    9 PLUGINS=$(LINK_LAYERS) $(ETH_LAYERS) $(IP_LAYERS)
     9TCP_LAYERS=$(addsuffix .so,$(basename $(wildcard tcp_*.cc)))
     10PLUGINS=$(LINK_LAYERS) $(ETH_LAYERS) $(IP_LAYERS) $(TCP_LAYERS)
    1011
    11 all: tracedump $(PLUGINS)
     12all: tracedump $(PLUGINS) asn1-test
    1213
    1314tracedump: tracedump.cc tracedump-libtrace.o tracedump-lib.o
    1415
     16tcp_1720.so: tcp_1720.cc asn1.o
     17
    1518%.so:%.cc
    16         $(CXX) $(CXXFLAGS) -fpic -shared $< -o $@
     19        $(CXX) $(CXXFLAGS) -fpic -shared $^ -o $@
     20
     21asn1-test: CXXFLAGS+=-DTEST
     22asn1-test: asn1.cc
    1723
    1824clean:
    1925        rm -f *.o tracedump *.so
    2026
     27install:
     28        cp *.so $(LIBDIR)
     29
    2130.PHONY: clean all
    2231
  • examples/tracedump/ip_6.cc

    rd907ff5 r5d6ebe1  
    66#include <netinet/tcp.h>
    77#include <netinet/in.h>
     8#include <assert.h>
    89
    910#define SAFE(x) \
     
    3132        switch(*type) {
    3233                case 0:
     34                        printf(" DEBUG: End of options\n");
    3335                        return 0;
    3436                case 1:
     37                        printf(" DEBUG: NOP\n");
    3538                        (*ptr)++;
    3639                        (*len)--;
    3740                        return 1;
    3841                default:
     42                        printf(" DEBUG: Type %i len %i\n",
     43                                        *type,*(*ptr+1));
    3944                        *optlen = *(*ptr+1);
     45                        assert(*optlen>0);
    4046                        (*len)-=*optlen;
    4147                        (*data)=(*ptr+2);
     
    7682        DISPLAYS(urg_ptr," Urgent %i");
    7783        unsigned char *pkt = (unsigned char*)packet+sizeof(*tcp);
    78         int plen = len-sizeof *tcp;
     84        int plen = (len-sizeof *tcp) <? (tcp->doff*4);
    7985        unsigned char type,optlen,*data;
    8086        while(get_next_option(&pkt,&plen,&type,&optlen,&data)) {
  • examples/tracedump/tracedump-libtrace.cc

    rd907ff5 r5d6ebe1  
    99        struct libtrace_t *trace = trace_create(argv[1]);
    1010        struct libtrace_packet_t packet;
    11 
     11        struct libtrace_filter_t *filter=NULL;
     12       
    1213        if (!trace) {
    1314                errx(1,"Failed to open trace");
    1415        }
    1516
     17        if (argc>2)
     18                filter=trace_bpf_setfilter(argv[2]);
     19
    1620        while(trace_read_packet(trace,&packet)!=-1) {
    1721                time_t sec = (time_t)trace_get_seconds(&packet);
    1822                char *link=(char *)trace_get_link(&packet);
     23                if (filter && !trace_bpf_filter(filter,&packet))
     24                        continue;
     25
    1926                printf("%s",ctime(&sec));
    2027                per_packet(trace_get_link_type(&packet),
Note: See TracChangeset for help on using the changeset viewer.