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

« back to all changes in this revision

Viewing changes to libs-external/USI++/samples/syn.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 <iostream>
 
2
#include <usi++/usi++.h>
 
3
#include <stdio.h>
 
4
#include <stdlib.h>
 
5
#include <string.h>
 
6
 
 
7
using namespace usipp;
 
8
 
 
9
int main(int argc, char **argv)
 
10
{
 
11
        if (argc < 5) {
 
12
                cerr<<"Usage: "<<*argv<<" <src-ip> <dst-ip> <src-port> <dst-port>\n";
 
13
                exit(1);
 
14
        }
 
15
 
 
16
        u_int16_t sport = atoi(argv[3]);
 
17
        u_int16_t dport = atoi(argv[4]);
 
18
 
 
19
        TCP tcp(argv[2]);
 
20
 
 
21
        tcp.set_srcport(sport);
 
22
        tcp.set_dstport(dport);
 
23
 
 
24
        if (strcmp(argv[1], "0") != 0)
 
25
                tcp.set_src(argv[1]);
 
26
 
 
27
        tcp.set_seq(1);
 
28
        tcp.set_ack(0);
 
29
        tcp.set_flags(TH_SYN);
 
30
        
 
31
        tcp.sendpack("");
 
32
 
 
33
        return 0;
 
34
}
 
35