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
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
// 
// SNMP helper stuff. 
// 
// $Id: SNMP.pmod,v 1.1 2007/09/10 11:07:42 grubba Exp $ 
// 
// 2007-08-29 Henrik Grubbström 
// 
 
// Some OIDs 
 
//! iso.organizations.dod.internet 
constant INTERNET_OID = ({ 1, 3, 6, 1 }); 
 
//! iso.organizations.dod.internet.private.enterprises.roxenis 
constant RIS_OID = INTERNET_OID + ({ 4, 1, 8614 }); 
 
//! iso.organizations.dod.internet.private.enterprises.roxenis.app.webserver 
constant RIS_OID_WEBSERVER = RIS_OID + ({ 1, 1 }); 
 
class Documentation(string name, 
                    string doc) 
{ 
} 
 
// ASN1 datatypes. 
 
class app_integer 
{ 
  inherit Standards.ASN1.Types.asn1_integer : integer; 
  inherit Documentation : doc; 
  constant cls = 1; 
  constant type_name = "APPLICATION INTEGER"; 
  constant tag = 0; 
  static void create(int val, string|void name, string|void doc_string) 
  { 
    integer::create(val); 
    doc::create(name, doc_string); 
  } 
} 
 
class app_octet_string 
{ 
  inherit Standards.ASN1.Types.asn1_octet_string : octet_string; 
  inherit Documentation : doc; 
  constant cls = 1; 
  constant type_name = "APPLICATION OCTET_STRING"; 
  constant tag = 0; 
  static void create(string val, string|void name, string|void doc_string) 
  { 
    octet_string::create(val); 
    doc::create(name, doc_string); 
  } 
} 
 
class OID 
{ 
  inherit Standards.ASN1.Types.asn1_identifier : identifier; 
  inherit Documentation : doc; 
  constant type_name = "OID"; 
  static void create(array(int) oid, string|void name, string|void doc_string) 
  { 
    identifier::create(@oid); 
    doc::create(name, doc_string); 
  } 
} 
 
class Integer 
{ 
  inherit Standards.ASN1.Types.asn1_integer : integer; 
  inherit Documentation : doc; 
  constant type_name = "INTEGER"; 
  static void create(int val, string|void name, string|void doc_string) 
  { 
    integer::create(val); 
    doc::create(name, doc_string); 
  } 
} 
 
class String 
{ 
  inherit Standards.ASN1.Types.asn1_octet_string : octet_string; 
  inherit Documentation : doc; 
  constant type_name = "STRING"; 
  static void create(string val, string|void name, string|void doc_string) 
  { 
    octet_string::create(val); 
    doc::create(name, doc_string); 
  } 
} 
 
class Counter 
{ 
  inherit app_integer; 
  constant tag = 1; 
  constant type_name = "COUNTER"; 
} 
 
class Gauge 
{ 
  inherit app_integer; 
  constant tag = 2; 
  constant type_name = "GAUGE"; 
} 
 
class Tick 
{ 
  inherit app_integer; 
  constant tag = 3; 
  constant type_name = "TICK"; 
} 
 
class Opaque 
{ 
  inherit app_octet_string; 
  constant tag = 4; 
  constant type_name = "OPAQUE"; 
} 
 
class Counter64 
{ 
  inherit app_integer; 
  constant tag = 6; 
  constant type_name = "COUNTER64"; 
} 
 
//! No such object marker. 
Protocols.LDAP.ldap_privates.asn1_context_octet_string NO_SUCH_OBJECT = 
  Protocols.LDAP.ldap_privates.asn1_context_octet_string(0, ""); 
 
//! No such instance marker. 
Protocols.LDAP.ldap_privates.asn1_context_octet_string NO_SUCH_INSTANCE = 
  Protocols.LDAP.ldap_privates.asn1_context_octet_string(1, ""); 
 
//! End of MIB marker. 
Protocols.LDAP.ldap_privates.asn1_context_octet_string END_OF_MIB = 
  Protocols.LDAP.ldap_privates.asn1_context_octet_string(2, ""); 
 
//! The NULL counter. 
Counter NULL_COUNTER = Counter(0); 
 
 
class SimpleMIB 
{ 
  inherit ADT.Trie; 
 
  static void create(array(int) oid, 
                     array(Standards.ASN1.Types.Object|function)| 
                     mapping(int:Standards.ASN1.Types.Object|function) values) 
  { 
    ::create(oid); 
    foreach(values; int i; function|Standards.ASN1.Types.Object val) { 
      if (!zero_type(val)) { 
        insert(oid + ({ i, 0 }), val); 
      } 
    } 
  } 
 
  Standards.ASN1.Types.Object lookup(array(int) key) 
  { 
    function|Standards.ASN1.Types.Object res = ::lookup(key); 
    if (zero_type(res)) return UNDEFINED; 
    if (functionp(res)) return res(); 
    return res; 
  } 
}