… | |
… | |
76 | level of user-friendlyness. |
76 | level of user-friendlyness. |
77 | |
77 | |
78 | =head2 EXPORT TAGS AND CONSTANTS |
78 | =head2 EXPORT TAGS AND CONSTANTS |
79 | |
79 | |
80 | By default this module doesn't export any symbols, but if you don't want |
80 | By default this module doesn't export any symbols, but if you don't want |
81 | to break your keyboard, editor or eyesigh with extreemly long names, I |
81 | to break your keyboard, editor or eyesight with extremely long names, I |
82 | recommend importing the C<:all> tag. Still, you can selectively import |
82 | recommend importing the C<:all> tag. Still, you can selectively import |
83 | things. |
83 | things. |
84 | |
84 | |
85 | =over |
85 | =over |
86 | |
86 | |
87 | =item C<:all> |
87 | =item C<:all> |
88 | |
88 | |
89 | All of the below. Really. Rcommended for at least first steps, or if you |
89 | All of the below. Really. Recommended for at least first steps, or if you |
90 | don't care about a few kilobytes of wasted memory (and namespace). |
90 | don't care about a few kilobytes of wasted memory (and namespace). |
91 | |
91 | |
92 | =item C<:const> |
92 | =item C<:const> |
93 | |
93 | |
94 | All of the stricly ASN.1-related constants defined by this module, the |
94 | All of the strictly ASN.1-related constants defined by this module, the |
95 | same as C<:const_asn :const_index>. Notably, this does not contain |
95 | same as C<:const_asn :const_index>. Notably, this does not contain |
96 | C<:const_ber_type> and C<:const_snmp>. |
96 | C<:const_ber_type> and C<:const_snmp>. |
97 | |
97 | |
98 | A good set to get everything you need to decode and match BER data would be |
98 | A good set to get everything you need to decode and match BER data would be |
99 | C<:decode :const>. |
99 | C<:decode :const>. |
… | |
… | |
104 | |
104 | |
105 | BER_CLASS BER_TAG BER_CONSTRUCTED BER_DATA |
105 | BER_CLASS BER_TAG BER_CONSTRUCTED BER_DATA |
106 | |
106 | |
107 | =item C<:const_asn> |
107 | =item C<:const_asn> |
108 | |
108 | |
109 | ASN class values (these are C<0>, C<1>, C<2> and C<3>, reespectively - |
109 | ASN class values (these are C<0>, C<1>, C<2> and C<3>, respectively - |
110 | exactly thw two topmost bits from the identifdier octet shifted 6 bits to |
110 | exactly thw two topmost bits from the identifier octet shifted 6 bits to |
111 | the right): |
111 | the right): |
112 | |
112 | |
113 | ASN_UNIVERSAL ASN_APPLICATION ASN_CONTEXT ASN_PRIVATE |
113 | ASN_UNIVERSAL ASN_APPLICATION ASN_CONTEXT ASN_PRIVATE |
114 | |
114 | |
115 | ASN tag values (some of which are aliases, such as C<ASN_OID>). Their |
115 | ASN tag values (some of which are aliases, such as C<ASN_OID>). Their |
… | |
… | |
169 | and also have a flag that says whether a value consists of subvalues (is |
169 | and also have a flag that says whether a value consists of subvalues (is |
170 | "constructed") or not (is "primitive"). |
170 | "constructed") or not (is "primitive"). |
171 | |
171 | |
172 | Tags are simple integers, and ASN.1 defines a somewhat weird assortment of |
172 | Tags are simple integers, and ASN.1 defines a somewhat weird assortment of |
173 | those - for example, you have 32 bit signed integers and 16(!) different |
173 | those - for example, you have 32 bit signed integers and 16(!) different |
174 | string types, but there is no unsigned32 type for example. Different |
174 | string types, but there is no Unsigned32 type for example. Different |
175 | applications work around this in different ways, for example, SNMP defines |
175 | applications work around this in different ways, for example, SNMP defines |
176 | application-specific Gauge32, Counter32 and Unsigned32, which are mapped |
176 | application-specific Gauge32, Counter32 and Unsigned32, which are mapped |
177 | to two different tags: you can distinguish between Counter32 and the |
177 | to two different tags: you can distinguish between Counter32 and the |
178 | others, but not between Gause32 and Unsigned32, without the ASN.1 schema. |
178 | others, but not between Gause32 and Unsigned32, without the ASN.1 schema. |
179 | |
179 | |
… | |
… | |
183 | |
183 | |
184 | This module represents every BER value as a 4-element tuple (actually an |
184 | This module represents every BER value as a 4-element tuple (actually an |
185 | array-reference): |
185 | array-reference): |
186 | |
186 | |
187 | [CLASS, TAG, CONSTRUCTED, DATA] |
187 | [CLASS, TAG, CONSTRUCTED, DATA] |
|
|
188 | |
|
|
189 | For example: |
|
|
190 | |
|
|
191 | [ASN_UNIVERSAL, ASN_INTEGER32, 0, 177] # the integer 177 |
|
|
192 | [ASN_UNIVERSAL, ASN_OCTET_STRING, 0, "john"] # the string "john" |
|
|
193 | [ASN_UNIVERSAL, ASN_OID, 0, "1.3.6.133"] # some OID |
|
|
194 | [ASN_UNIVERSAL, ASN_SEQUENCE, 1, [ [ASN_UNIVERSAL... # a sequencE |
188 | |
195 | |
189 | To avoid non-descriptive hardcoded array index numbers, this module |
196 | To avoid non-descriptive hardcoded array index numbers, this module |
190 | defines symbolic constants to access these members: C<BER_CLASS>, |
197 | defines symbolic constants to access these members: C<BER_CLASS>, |
191 | C<BER_TAG>, C<BER_CONSTRUCTED> and C<BER_DATA>. |
198 | C<BER_TAG>, C<BER_CONSTRUCTED> and C<BER_DATA>. |
192 | |
199 | |