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

« back to all changes in this revision

Viewing changes to libs-external/USI++/usi++/icmp.h

  • 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
/*** This Programs/Libraries are (C)opyright by Sebastian Krahmer.
 
2
 *** You may use it under the terms of the GPL. You should have
 
3
 *** already received the file COPYING that shows you your rights.
 
4
 *** Please look at COPYING for further license-details.
 
5
 ***  
 
6
 *** THERE IS ABSOLUTELY NO WARRANTY. SO YOU USE IT AT YOUR OWN RISK.
 
7
 *** IT WAS WRITTEN IN THE HOPE THAT IT WILL BE USEFULL. I AM NOT RESPONSIBLE
 
8
 *** FOR ANY DAMAGE YOU MAYBE GET DUE TO USING MY PROGRAMS.
 
9
 ***/
 
10
 
 
11
#ifndef _ICMP_H_
 
12
#define _ICMP_H_
 
13
 
 
14
#include "usi-structs.h"
 
15
#include "datalink.h"
 
16
#include "ip.h"
 
17
 
 
18
namespace usipp {
 
19
 
 
20
 
 
21
/*! \class ICMP icmp.h
 
22
 *  \brief the ICMP-class
 
23
 */
 
24
/*! \example icmp_sniff.cc
 
25
 */
 
26
 
 
27
class ICMP : public IP {
 
28
private:
 
29
        struct icmphdr icmphdr;
 
30
public:
 
31
        /*! Expects host.
 
32
         */
 
33
        ICMP(const char*);
 
34
        /*! Expects destination i network byte order
 
35
         */
 
36
                ICMP(u_int32_t);
 
37
 
 
38
        virtual ~ICMP();
 
39
 
 
40
        /*! Copy-Construktor */
 
41
        ICMP(const ICMP &);     
 
42
 
 
43
        /*! Assign-operator */
 
44
        ICMP &operator=(const ICMP &);
 
45
 
 
46
        /*! Assign-operator */
 
47
        ICMP &operator=(const IP &);
 
48
 
 
49
        /*! send an ICMP-packet containing 'payload' which
 
50
         *  is 'paylen' bytes long
 
51
         */
 
52
        virtual int sendpack(void*, size_t);
 
53
 
 
54
        /*! send a ICMP-packet with string 'payload' as payload.
 
55
         */
 
56
        virtual int sendpack(char*);
 
57
 
 
58
                /*! send standard UNIX-like payload
 
59
         */
 
60
                virtual int send_ping_payload();
 
61
 
 
62
                /*! send the ICMP timestamp request payload
 
63
         */
 
64
                virtual int send_timestamp_payload();
 
65
 
 
66
                virtual int send_addrmask_payload();
 
67
 
 
68
        /*! handle packets, that are NOT actually for the
 
69
         *  local adress!
 
70
         */
 
71
        virtual int sniffpack(void*, size_t);
 
72
 
 
73
        /*! Initialize a device ("eth0" for example) for packet-
 
74
         *  capturing. It MUST be called before sniffpack() is launched.
 
75
         *  Set 'promisc' to 1 if you want the device running in promiscous mode.
 
76
         *  Fetch at most 'snaplen' bytes per call.
 
77
         */
 
78
        virtual int init_device(char *, int, size_t);
 
79
 
 
80
        /*! Set the type-field in the actuall ICMP-packet.
 
81
         */
 
82
        int set_type(u_int8_t);
 
83
 
 
84
        /*! Set ICMP-code.
 
85
         */
 
86
        int set_code(u_int8_t);
 
87
 
 
88
        /*! Set id field in the actuall ICMP-packet 
 
89
         */
 
90
        int set_icmpId(u_int16_t);
 
91
 
 
92
        /*! Set the sequecenumber of the actuall ICMP-packet.
 
93
         */
 
94
        int set_seq(u_int16_t);
 
95
        
 
96
        int set_gateway(u_int32_t);
 
97
        
 
98
        int set_mtu(u_int16_t);
 
99
 
 
100
        /*! Get the type-field from the actuall ICMP-packet.
 
101
         */
 
102
        u_int8_t get_type();
 
103
 
 
104
        /*! Get ICMP-code.
 
105
         */
 
106
        u_int8_t get_code();
 
107
 
 
108
        /*! Get the id field from actuall ICMP-packet.
 
109
         */
 
110
        u_int16_t get_icmpId();
 
111
 
 
112
        /*! Get the sequence-number of actuall ICMP-packet
 
113
         */
 
114
        u_int16_t get_seq();
 
115
 
 
116
        iphdr get_orig();
 
117
        
 
118
        u_int32_t get_gateway();
 
119
        
 
120
        u_int16_t get_mtu();
 
121
}; // class ICMP{}
 
122
 
 
123
 
 
124
 
 
125
} // namespace usipp
 
126
#endif // _ICMP_H_