summaryrefslogtreecommitdiff
path: root/ACE/ace/Monitor_Control/Solaris_Network_Interface_Monitor.h
blob: 15dbc9c50e159fdfd05a9053e6c045730ce8c1fe (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
89
// -*- C++ -*-

//=============================================================================
/**
 * @file Solaris_Network_Interface_Monitor.h
 *
 * @author Jeff Parsons <j.parsons@vanderbilt.edu>
 */
//=============================================================================

#ifndef SOLARIS_NETWORK_INTERFACE_MONITOR_H
#define SOLARIS_NETWORK_INTERFACE_MONITOR_H

#include /**/ "ace/pre.h"

#include "ace/SString.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/Monitor_Control/Monitor_Control_export.h"

#if defined (ACE_HAS_KSTAT)

#include "ace/os_include/os_kstat.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

namespace ACE
{
  namespace Monitor_Control
  {
    /**
     * @class Solaris_Network_Interface_Monitor
     *
     * @brief Mixin class for network interface monitors compiled on
     *        Solaris machines.
     */
    class MONITOR_CONTROL_Export Solaris_Network_Interface_Monitor
    {
    protected:
      /// The kstat interface can access a wealth of
      /// network information about the system. To get the specific
      /// value we want to monitor, we just vary the lookup string.
      Solaris_Network_Interface_Monitor (const ACE_TCHAR *lookup_str);

      /// Platform-specific implementation.
      void update_i ();

      /// Platform-specific reset.
      void clear_impl ();

    protected:
      ACE_UINT64 value_;

    private:
      /// Common code.

      void init ();
      void access_kstats (ACE_UINT64 &which_member);
      int check_ks_module (const unsigned long ks_instance,
                           const unsigned long which_max,
                           const char *max_str,
                           ACE_UINT64 *value_array,
                           ACE_UINT64 &which_member);


    private:
      static const unsigned long MAX_LO_INTERFACES = 5UL;
      static const unsigned long MAX_HME_INTERFACES = 10UL;
      ACE_UINT64 value_array_lo_[MAX_LO_INTERFACES];
      ACE_UINT64 value_array_hme_[MAX_HME_INTERFACES];
      ACE_UINT64 start_;
      ACE_TString lookup_str_;
      kstat_ctl_t *kstats_;
      kstat_t *kstat_;
      kid_t kstat_id_;
    };
  }
}

ACE_END_VERSIONED_NAMESPACE_DECL

#endif /* defined (ACE_HAS_KSTAT) */

#include /**/ "ace/post.h"

#endif // SOLARIS_NETWORK_INTERFACE_MONITOR_H