Component index
Section index

Component tcpdump


	    Using the class TCPINFO, we see how we can attach a TCPINFO object
	    to a TCP session to collect per-session information. In this case
	    we are counting the eol characters sent/received.
	class TCPINFO: public ARRAY_OBJ{
	    int nbrec;
	    int nbsent;
	        nbrec = 0;
	        nbsent = 0;
	static void sample_countlines(const char *device,const char *filter)
	    <call tcpdump>(device,filter);
	    <f newsession>
	        data = new TCPINFO;
	    <f endsession>
	        TCPINFO *info = (TCPINFO*)data;
	        printf ("endsession: %08x:%u -> %08x:%u -- newlines: received %d sent %d\n"
	    <f packet>
	        TCPINFO *info = (TCPINFO*)data;
	        const char *pt = (const char*)packet;
	        int nl = 0;
	        for (int i=0; i<len; i++){
	            if (pt[i] == '\n') nl++;
	        if (from){
	            info->nbsent += nl;
	            info->nbrec += nl;