1# -*- mode: Perl -*-
2
3BEGIN { unshift @INC, "lib", "../lib" }
4use strict;
5use FileHandle;
6use SNMP::MIB::Compiler;
7use Data::Compare;
8
9local $^W = 1;
10$| = 1;
11
12print "1..1\n";
13my $t = 1;
14
15my $mib = new SNMP::MIB::Compiler();
16$mib->{'filename'} = '<DATA>';
17$mib->{'debug_lexer'} = 0;
18
19# create a stream to the pseudo MIB file
20my $s = Stream->new(*DATA);
21$mib->{'stream'} = $s;
22
23my ($res, $ref, $token, $value);
24
25# Test 1
26($token, $value) = $mib->get_token('IDENTIFIER');
27my $node = $value;
28($token, $value) = $mib->get_token('TYPEMODREFERENCE');
29unless ($value eq 'AGENT-CAPABILITIES') {
30  print "not ok $t\n";
31  exit 0;
32}
33$res = $mib->parse_agentcapabilities();
34my $good = {
35  'supports' => {
36    'SNMPv2-MIB' => {
37      'variation' => {
38        'coldStart' => {
39          'description' => '"A coldStart trap is generated on all
40                         reboots."'
41        }
42      },
43      'includes' => [ 'systemGroup', 'snmpGroup', 'snmpSetGroup',
44		      'snmpBasicNotificationsGroup' ]
45    },
46    'TCP-MIB' => {
47      'variation' => {
48        'tcpConnState' => {
49          'access' => 'read-only',
50          'description' => '"Unable to set this on 4BSD"'
51        }
52      },
53      'includes' => [ 'tcpGroup' ]
54    },
55    'IF-MIB' => {
56      'variation' => {
57        'ifOperStatus' => {
58          'description' => '"Information limited on 4BSD"',
59          'syntax' => {
60            'values' => { 1 => 'up', 2 => 'down' },
61            'type' => 'INTEGER'
62          }
63        },
64        'ifAdminStatus' => {
65          'description' => '"Unable to set test mode on 4BSD"',
66          'syntax' => {
67            'values' => { 1 => 'up', 2 => 'down' },
68            'type' => 'INTEGER'
69          }
70        }
71      },
72      'includes' => [ 'ifGeneralGroup', 'ifPacketGroup' ]
73    },
74    'EVAL-MIB' => {
75      'variation' => {
76        'exprEntry' => {
77          'creation-requires' => [ 'evalString' ],
78          'description' => '"Conceptual row creation supported"'
79        }
80      },
81      'includes' => [ 'functionsGroup', 'expressionsGroup' ]
82    },
83    'UDP-MIB' => {
84      'includes' => [ 'udpGroup' ]
85    },
86    'IP-MIB' => {
87      'variation' => {
88        'ipInAddrErrors' => {
89          'access' => 'not-implemented',
90          'description' => '"Information not available on 4BSD"'
91        },
92        'ipDefaultTTL' => {
93          'description' => '"Hard-wired on 4BSD"',
94          'syntax' => {
95            'type' => 'INTEGER',
96            'range' => { 'min' => 255, 'max' => 255 }
97          }
98        },
99        'ipNetToMediaEntry' => {
100          'creation-requires' => [ 'ipNetToMediaPhysAddress' ],
101          'description' => '"Address mappings on 4BSD require
102                         both protocol and media addresses"'
103        }
104      },
105      'includes' => [ 'ipGroup', 'icmpGroup' ]
106    }
107  },
108  'oid' => [ 'acmeAgents', 1 ],
109  'description' => '"ACME agent for 4BSD"',
110  'status' => 'current',
111  'product-release' => '"ACME Agent release 1.1 for 4BSD"'
112};
113
114print Compare ($res, $good) ? "" : "not ", "ok 1\n";
115
116# end
117
118__DATA__
119
120-- extracted from rfc1904.txt
121
122exampleAgent AGENT-CAPABILITIES
123    PRODUCT-RELEASE      "ACME Agent release 1.1 for 4BSD"
124    STATUS               current
125    DESCRIPTION          "ACME agent for 4BSD"
126
127    SUPPORTS             SNMPv2-MIB
128        INCLUDES         { systemGroup, snmpGroup, snmpSetGroup,
129                           snmpBasicNotificationsGroup }
130
131        VARIATION        coldStart
132            DESCRIPTION  "A coldStart trap is generated on all
133                         reboots."
134
135    SUPPORTS             IF-MIB
136        INCLUDES         { ifGeneralGroup, ifPacketGroup }
137
138        VARIATION        ifAdminStatus
139            SYNTAX       INTEGER { up(1), down(2) }
140            DESCRIPTION  "Unable to set test mode on 4BSD"
141
142        VARIATION        ifOperStatus
143            SYNTAX       INTEGER { up(1), down(2) }
144            DESCRIPTION  "Information limited on 4BSD"
145
146    SUPPORTS             IP-MIB
147        INCLUDES         { ipGroup, icmpGroup }
148
149        VARIATION        ipDefaultTTL
150            SYNTAX       INTEGER (255..255)
151            DESCRIPTION  "Hard-wired on 4BSD"
152
153        VARIATION        ipInAddrErrors
154            ACCESS       not-implemented
155            DESCRIPTION  "Information not available on 4BSD"
156
157        VARIATION        ipNetToMediaEntry
158            CREATION-REQUIRES { ipNetToMediaPhysAddress }
159            DESCRIPTION  "Address mappings on 4BSD require
160                         both protocol and media addresses"
161
162    SUPPORTS             TCP-MIB
163        INCLUDES         { tcpGroup }
164        VARIATION        tcpConnState
165            ACCESS       read-only
166            DESCRIPTION  "Unable to set this on 4BSD"
167
168    SUPPORTS             UDP-MIB
169        INCLUDES         { udpGroup }
170
171    SUPPORTS             EVAL-MIB
172        INCLUDES         { functionsGroup, expressionsGroup }
173        VARIATION        exprEntry
174            CREATION-REQUIRES { evalString }
175            DESCRIPTION "Conceptual row creation supported"
176
177    ::= { acmeAgents 1 }
178