Namespaces   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members   Examples  

/* Output looks similar to tcpdump -p arp ;-)
 */
#include <usi++/usi++.h>
#include <iostream>

int main()
{

	/* The ARP-objects don't need to call
	 * init_device() before monitoring the network,
	 * because initialization is done in constructor.
	 */
#ifdef linux
   	ARP *a = new ARP("eth0", 1);
#else
	ARP *a = new ARP("ed0", 1);
#endif

        char smac[100], dmac[100], shw[100], dhw[100],
	     sip[100], dip[100];
        
        while (1) {
           	a->sniffpack();
		if (a->get_op() == ARPOP_REQUEST) {
			cout<<"["<<a->get_hwsrc(shw, 100)<<"-"<<a->get_hwdst(dhw, 100)<<"]"
			    <<"arp who has "<<a->get_tpa(0, dip, 100)
			    <<" tell "<<a->get_spa(1, sip, 100)<<endl;
		}
		if (a->get_op() == ARPOP_REPLY) {
			cout<<a->get_spa(0, sip, 100)<<" is at "
			    <<a->get_sha(smac, 100)<<endl;
		}
        }
        return 0;
}

        

Generated at Sun Oct 10 13:51:35 1999 for libusi++ by doxygen  written by Dimitri van Heesch, © 1997-1999