summaryrefslogtreecommitdiff
path: root/src/lbtest.hh
blob: 208adaa0c99dd4da80b5a84e0689f95a882d463e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Module: lbtest.hh
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation.
 */
#ifndef __LBTEST_HH__
#define __LBTEST_HH__

#include <assert.h>
#include <map>
#include <set>
#include <vector>
#include <string>

using namespace std;

class LBHealth;

/**
 *
 *
 **/
class PktData
{
public:
  PktData(string iface, int rtt) : _iface(iface),_rtt(rtt) {}
  string _iface;
  int _rtt;
};


/**
 *
 *
 **/
class LBTest {
public:
  typedef enum {K_NONE,K_SUCCESS,K_FAILURE} TestState;
public:
  LBTest(bool debug) : 
    _debug(debug),
    _resp_time(5*1000),
    _state(K_NONE)
  {init();}

  virtual ~LBTest();

  virtual void
  init();

  virtual void
  start();
  
  virtual void
  send(LBHealth &health) = 0;

  virtual string
  dump() = 0;

  int
  recv(LBHealth &health);

  virtual string
  name() = 0;

private:
  int
  receive(int recv_sock);


public:
  bool _debug;
  string _target;
  int    _resp_time;
  int _state;

  static int _recv_icmp_sock;
  static int _send_raw_sock;
  static int _send_icmp_sock;
  static bool _initialized;
  static bool _received;
  static int _packet_id;
  static map<int,PktData> _results;
};

#endif //__LBTEST_HH__