Component index
Section index

Component tcpdump


Search

	/*
	    This shows how to use the tcpdump component to retrieve statistics
	    and content of various TCP sessions.
	*/
	<mod>
	static void sample_test1(const char *device,const char *filter)
	{
	    <call tcpdump>(device,filter);
	    <f newsession>
	        printf ("newsession: %08x:%u -> %08x:%u (nbsession %d)\n"
	            ,session.saddr,session.sport
	            ,session.daddr,session.dport
	            ,getnbsession());
	    </f>
	    <f endsession>
	        printf ("endsession: %08x:%u -> %08x:%u (nbsession %d)\n"
	            ,session.saddr,session.sport
	            ,session.daddr,session.dport
	            ,getnbsession());
	    </f>
	    <f packet>
	        printf ("packet: %08x:%u %s %08x:%u\n\t[rec %u/%Lu/%ld.%ld snd %u/%Lu/%ld.%ld]\n"
	            ,session.saddr,session.sport
	            ,from ? "<-" : "->"
	            ,session.daddr,session.dport
	            ,stats.from.nbpk,stats.from.size
	            ,stats.from.stamp.tv_sec,stats.from.stamp.tv_usec
	            ,stats.to.nbpk,stats.to.size
	            ,stats.to.stamp.tv_sec,stats.to.stamp.tv_usec);
	        samples_printhex (packet,len);
	    </f>
	    </call>
	}
	</mod>