… | |
… | |
35 | ASN_VISIBLE_STRING = 0x1a, //X |
35 | ASN_VISIBLE_STRING = 0x1a, //X |
36 | ASN_ISO646_STRING = 0x1a, //X |
36 | ASN_ISO646_STRING = 0x1a, //X |
37 | ASN_GENERAL_STRING = 0x1b, //X |
37 | ASN_GENERAL_STRING = 0x1b, //X |
38 | ASN_UNIVERSAL_STRING = 0x1c, //X |
38 | ASN_UNIVERSAL_STRING = 0x1c, //X |
39 | ASN_CHARACTER_STRING = 0x1d, //X |
39 | ASN_CHARACTER_STRING = 0x1d, //X |
40 | ASN_BMPSTRING = 0x1e, //X |
40 | ASN_BMP_STRING = 0x1e, //X |
41 | |
41 | |
42 | ASN_TAG_BER = 0x1f, |
42 | ASN_TAG_BER = 0x1f, |
43 | ASN_TAG_MASK = 0x1f, |
43 | ASN_TAG_MASK = 0x1f, |
44 | |
44 | |
45 | // primitive/constructed |
45 | // primitive/constructed |
46 | ASN_CONSTRUCTED = 0x20, |
46 | ASN_CONSTRUCTED = 0x20, |
47 | |
47 | |
48 | // ASN_CLASS |
48 | // ASN_CLASS |
49 | ASN_UNIVERSAL = 0x00, |
49 | ASN_UNIVERSAL = 0x00, |
50 | ASN_APPLICATION = 0x40, |
50 | ASN_APPLICATION = 0x01, |
51 | ASN_CONTEXT = 0x80, |
51 | ASN_CONTEXT = 0x02, |
52 | ASN_PRIVATE = 0xc0, |
52 | ASN_PRIVATE = 0x03, |
53 | |
53 | |
54 | ASN_CLASS_MASK = 0xc0, |
54 | ASN_CLASS_MASK = 0xc0, |
55 | ASN_CLASS_SHIFT = 6, |
55 | ASN_CLASS_SHIFT = 6, |
56 | |
56 | |
57 | // ASN_APPLICATION SNMP |
57 | // ASN_APPLICATION SNMP |
… | |
… | |
62 | SNMP_OPAQUE = 0x04, |
62 | SNMP_OPAQUE = 0x04, |
63 | SNMP_COUNTER64 = 0x06, |
63 | SNMP_COUNTER64 = 0x06, |
64 | }; |
64 | }; |
65 | |
65 | |
66 | enum { |
66 | enum { |
|
|
67 | BER_TYPE_BYTES, |
|
|
68 | BER_TYPE_UTF8, |
|
|
69 | BER_TYPE_UCS2, |
|
|
70 | BER_TYPE_UCS4, |
|
|
71 | BER_TYPE_INT, |
|
|
72 | BER_TYPE_OID, |
|
|
73 | BER_TYPE_RELOID, |
|
|
74 | BER_TYPE_NULL, |
|
|
75 | BER_TYPE_BOOL, |
|
|
76 | BER_TYPE_REAL, |
|
|
77 | BER_TYPE_IPADDRESS, |
|
|
78 | BER_TYPE_CROAK, |
|
|
79 | }; |
|
|
80 | |
|
|
81 | enum { |
67 | BER_CLASS = 0, |
82 | BER_CLASS = 0, |
68 | BER_TAG = 1, |
83 | BER_TAG = 1, |
69 | BER_CONSTRUCTED = 2, |
84 | BER_CONSTRUCTED = 2, |
70 | BER_DATA = 3, |
85 | BER_DATA = 3, |
71 | BER_ARRAYSIZE |
86 | BER_ARRAYSIZE |
72 | }; |
87 | }; |
73 | |
88 | |
74 | #define MAX_OID_STRLEN 4096 |
89 | #define MAX_OID_STRLEN 4096 |
75 | |
90 | |
|
|
91 | typedef void profile_type; |
|
|
92 | |
|
|
93 | static profile_type *cur_profile, *default_profile; |
76 | static SV *buf_sv; // encoding buffer |
94 | static SV *buf_sv; // encoding buffer |
77 | static U8 *buf, *cur, *end; // buffer start, current, end |
95 | static U8 *buf, *cur, *end; // buffer start, current, end |
78 | |
96 | |
79 | #if __GNUC__ >= 3 |
97 | #if __GNUC__ >= 3 |
80 | # define expect(expr,value) __builtin_expect ((expr), (value)) |
98 | # define expect(expr,value) __builtin_expect ((expr), (value)) |
… | |
… | |
85 | #endif |
103 | #endif |
86 | |
104 | |
87 | #define expect_false(expr) expect ((expr) != 0, 0) |
105 | #define expect_false(expr) expect ((expr) != 0, 0) |
88 | #define expect_true(expr) expect ((expr) != 0, 1) |
106 | #define expect_true(expr) expect ((expr) != 0, 1) |
89 | |
107 | |
|
|
108 | ///////////////////////////////////////////////////////////////////////////// |
|
|
109 | |
|
|
110 | static SV *sviv_cache[32]; |
|
|
111 | |
90 | // for "small" integers, return a readonly sv, otherwise create a new one |
112 | // for "small" integers, return a readonly sv, otherwise create a new one |
91 | static SV *newSVcacheint (int val) |
113 | static SV *newSVcacheint (int val) |
92 | { |
114 | { |
93 | static SV *cache[32]; |
|
|
94 | |
|
|
95 | if (expect_false (val < 0 || val >= sizeof (cache))) |
115 | if (expect_false (val < 0 || val >= sizeof (sviv_cache))) |
96 | return newSViv (val); |
116 | return newSViv (val); |
97 | |
117 | |
98 | if (expect_false (!cache [val])) |
118 | if (expect_false (!sviv_cache [val])) |
99 | { |
119 | { |
100 | cache [val] = newSVuv (val); |
120 | sviv_cache [val] = newSVuv (val); |
101 | SvREADONLY_on (cache [val]); |
121 | SvREADONLY_on (sviv_cache [val]); |
102 | } |
122 | } |
103 | |
123 | |
104 | return SvREFCNT_inc_NN (cache [val]); |
124 | return SvREFCNT_inc_NN (sviv_cache [val]); |
|
|
125 | } |
|
|
126 | |
|
|
127 | ///////////////////////////////////////////////////////////////////////////// |
|
|
128 | |
|
|
129 | static HV *profile_stash; |
|
|
130 | |
|
|
131 | static profile_type * |
|
|
132 | SvPROFILE (SV *profile) |
|
|
133 | { |
|
|
134 | if (!SvOK (profile)) |
|
|
135 | return default_profile; |
|
|
136 | |
|
|
137 | if (!SvROK (profile)) |
|
|
138 | croak ("invalid profile"); |
|
|
139 | |
|
|
140 | profile = SvRV (profile); |
|
|
141 | |
|
|
142 | if (SvSTASH (profile) != profile_stash) |
|
|
143 | croak ("invalid profile object"); |
|
|
144 | |
|
|
145 | return (void *)profile; |
|
|
146 | } |
|
|
147 | |
|
|
148 | static int |
|
|
149 | profile_lookup (profile_type *profile, int klass, int tag) |
|
|
150 | { |
|
|
151 | SV *sv = (SV *)profile; |
|
|
152 | U32 idx = (tag << 2) + klass; |
|
|
153 | |
|
|
154 | if (expect_false (idx >= SvCUR (sv))) |
|
|
155 | return BER_TYPE_BYTES; |
|
|
156 | |
|
|
157 | return SvPVX (sv)[idx]; |
|
|
158 | } |
|
|
159 | |
|
|
160 | static int |
|
|
161 | profile_set (profile_type *profile, int klass, int tag, int type) |
|
|
162 | { |
|
|
163 | SV *sv = (SV *)profile; |
|
|
164 | U32 idx = (tag << 2) + klass; |
|
|
165 | STRLEN oldlen = SvCUR (sv); |
|
|
166 | STRLEN newlen = idx + 2; |
|
|
167 | |
|
|
168 | if (idx >= oldlen) |
|
|
169 | { |
|
|
170 | sv_grow (sv, newlen); |
|
|
171 | memset (SvPVX (sv) + oldlen, BER_TYPE_BYTES, newlen - oldlen); |
|
|
172 | SvCUR_set (sv, newlen); |
|
|
173 | } |
|
|
174 | |
|
|
175 | SvPVX (sv)[idx] = type; |
|
|
176 | } |
|
|
177 | |
|
|
178 | static SV * |
|
|
179 | profile_new () |
|
|
180 | { |
|
|
181 | SV *sv = newSVpvn ("", 0); |
|
|
182 | |
|
|
183 | static const struct { |
|
|
184 | int klass; |
|
|
185 | int tag; |
|
|
186 | int type; |
|
|
187 | } *celem, default_map[] = { |
|
|
188 | { ASN_UNIVERSAL, ASN_BOOLEAN , BER_TYPE_BOOL }, |
|
|
189 | { ASN_UNIVERSAL, ASN_INTEGER32 , BER_TYPE_INT }, |
|
|
190 | { ASN_UNIVERSAL, ASN_NULL , BER_TYPE_NULL }, |
|
|
191 | { ASN_UNIVERSAL, ASN_OBJECT_IDENTIFIER, BER_TYPE_OID }, |
|
|
192 | { ASN_UNIVERSAL, ASN_OBJECT_DESCRIPTOR, BER_TYPE_OID }, |
|
|
193 | { ASN_UNIVERSAL, ASN_RELATIVE_OID , BER_TYPE_RELOID }, |
|
|
194 | { ASN_UNIVERSAL, ASN_REAL , BER_TYPE_REAL }, |
|
|
195 | { ASN_UNIVERSAL, ASN_UTF8_STRING , BER_TYPE_UTF8 }, |
|
|
196 | { ASN_UNIVERSAL, ASN_BMP_STRING , BER_TYPE_UCS2 }, |
|
|
197 | { ASN_UNIVERSAL, ASN_UNIVERSAL_STRING , BER_TYPE_UCS4 }, |
|
|
198 | }; |
|
|
199 | |
|
|
200 | for (celem = default_map + sizeof (default_map) / sizeof (default_map [0]); celem > default_map; celem--) |
|
|
201 | profile_set ((void *)sv, celem->klass, celem->tag, celem->type); |
|
|
202 | |
|
|
203 | return sv_bless (newRV_noinc (sv), profile_stash); |
105 | } |
204 | } |
106 | |
205 | |
107 | ///////////////////////////////////////////////////////////////////////////// |
206 | ///////////////////////////////////////////////////////////////////////////// |
108 | // decoder |
207 | // decoder |
109 | |
208 | |
… | |
… | |
187 | } |
286 | } |
188 | |
287 | |
189 | return res; |
288 | return res; |
190 | } |
289 | } |
191 | |
290 | |
192 | static U32 |
291 | static SV * |
193 | get_integer32 (void) |
292 | decode_int () |
194 | { |
293 | { |
195 | U32 length = get_length (); |
294 | int len = get_length (); |
196 | |
295 | |
197 | if (length <= 0) |
296 | if (len <= 0) |
198 | { |
297 | { |
199 | error ("INTEGER32 length equal to zero"); |
298 | error ("integer length equal to zero"); |
200 | return 0; |
299 | return 0; |
201 | } |
300 | } |
202 | |
301 | |
203 | U8 *data = get_n (length); |
302 | U8 *data = get_n (len); |
204 | |
303 | |
205 | if (length > 5 || (length > 4 && data [0])) |
304 | int negative = data [0] & 0x80; |
206 | { |
|
|
207 | error ("INTEGER32 length too long"); |
|
|
208 | return 0; |
|
|
209 | } |
|
|
210 | |
305 | |
211 | U32 res = data [0] & 0x80 ? 0xffffffff : 0; |
306 | UV val = negative ? -1 : 0; // copy signbit to all bits |
212 | |
307 | |
213 | while (length--) |
308 | do |
214 | res = (res << 8) | *data++; |
309 | val = (val << 8) | *data++; |
|
|
310 | while (--len); |
215 | |
311 | |
216 | return res; |
312 | // the cast to IV relies on implementation-defined behaviour (two's complement cast) |
|
|
313 | // but that's ok, as perl relies on it as well. |
|
|
314 | return negative ? newSViv ((IV)val) : newSVuv (val); |
217 | } |
315 | } |
218 | |
316 | |
219 | static SV * |
317 | static SV * |
220 | decode_integer32 (void) |
318 | decode_data (void) |
221 | { |
319 | { |
222 | return newSViv ((I32)get_integer32 ()); |
|
|
223 | } |
|
|
224 | |
|
|
225 | static SV * |
|
|
226 | decode_unsigned32 (void) |
|
|
227 | { |
|
|
228 | return newSVuv ((U32)get_integer32 ()); |
|
|
229 | } |
|
|
230 | |
|
|
231 | #if IVSIZE >= 8 |
|
|
232 | |
|
|
233 | static U64TYPE |
|
|
234 | get_integer64 (void) |
|
|
235 | { |
|
|
236 | U32 length = get_length (); |
320 | U32 len = get_length (); |
237 | |
|
|
238 | if (length <= 0) |
|
|
239 | { |
|
|
240 | error ("INTEGER64 length equal to zero"); |
|
|
241 | return 0; |
|
|
242 | } |
|
|
243 | |
|
|
244 | U8 *data = get_n (length); |
321 | U8 *data = get_n (len); |
245 | |
|
|
246 | if (length > 9 || (length > 8 && data [0])) |
|
|
247 | { |
|
|
248 | error ("INTEGER64 length too long"); |
|
|
249 | return 0; |
|
|
250 | } |
|
|
251 | |
|
|
252 | U64TYPE res = data [0] & 0x80 ? 0xffffffffffffffff : 0; |
|
|
253 | |
|
|
254 | while (length--) |
|
|
255 | res = (res << 8) | *data++; |
|
|
256 | |
|
|
257 | return res; |
|
|
258 | } |
|
|
259 | |
|
|
260 | static SV * |
|
|
261 | decode_integer64 (void) |
|
|
262 | { |
|
|
263 | return newSViv ((I64TYPE)get_integer64 ()); |
|
|
264 | } |
|
|
265 | |
|
|
266 | static SV * |
|
|
267 | decode_unsigned64 (void) |
|
|
268 | { |
|
|
269 | return newSVuv ((U64TYPE)get_integer64 ()); |
|
|
270 | } |
|
|
271 | |
|
|
272 | #endif |
|
|
273 | |
|
|
274 | static SV * |
|
|
275 | decode_octet_string (void) |
|
|
276 | { |
|
|
277 | U32 length = get_length (); |
|
|
278 | U8 *data = get_n (length); |
|
|
279 | return newSVpvn (data, length); |
322 | return newSVpvn ((char *)data, len); |
280 | } |
323 | } |
281 | |
324 | |
282 | // gelper for decode_object_identifier |
325 | // gelper for decode_object_identifier |
283 | static char * |
326 | static char * |
284 | write_uv (char *buf, U32 u) |
327 | write_uv (char *buf, U32 u) |
285 | { |
328 | { |
286 | // the one-digit case is absolutely predominant, so this pays off (hopefully) |
329 | // the one-digit case is absolutely predominant, so this pays off (hopefully) |
287 | if (u < 10) |
330 | if (expect_true (u < 10)) |
288 | *buf++ = u + '0'; |
331 | *buf++ = u + '0'; |
289 | else |
332 | else |
290 | { |
333 | { |
291 | char *beg = buf; |
334 | char *beg = buf; |
292 | |
335 | |
… | |
… | |
308 | |
351 | |
309 | return buf; |
352 | return buf; |
310 | } |
353 | } |
311 | |
354 | |
312 | static SV * |
355 | static SV * |
313 | decode_object_identifier (void) |
356 | decode_oid (int relative) |
314 | { |
357 | { |
315 | U32 length = get_length (); |
358 | U32 len = get_length (); |
316 | |
359 | |
317 | if (length <= 0) |
360 | if (len <= 0) |
318 | { |
361 | { |
319 | error ("OBJECT IDENTIFIER length equal to zero"); |
362 | error ("OBJECT IDENTIFIER length equal to zero"); |
320 | return &PL_sv_undef; |
363 | return &PL_sv_undef; |
321 | } |
364 | } |
322 | |
365 | |
323 | U8 *end = cur + length; |
366 | U8 *end = cur + len; |
324 | U32 w = get_w (); |
367 | U32 w = get_w (); |
325 | |
368 | |
326 | static char oid[MAX_OID_STRLEN]; // must be static |
369 | static char oid[MAX_OID_STRLEN]; // must be static |
327 | char *app = oid; |
370 | char *app = oid; |
328 | |
371 | |
|
|
372 | if (relative) |
|
|
373 | app = write_uv (app, w); |
|
|
374 | else |
|
|
375 | { |
329 | app = write_uv (app, (U8)w / 40); |
376 | app = write_uv (app, (U8)w / 40); |
330 | *app++ = '.'; |
377 | *app++ = '.'; |
331 | app = write_uv (app, (U8)w % 40); |
378 | app = write_uv (app, (U8)w % 40); |
|
|
379 | } |
332 | |
380 | |
333 | // we assume an oid component is never > 64 bytes |
381 | // we assume an oid component is never > 64 bytes |
334 | while (cur < end && oid + sizeof (oid) - app > 64) |
382 | while (cur < end && oid + sizeof (oid) - app > 64) |
335 | { |
383 | { |
336 | w = get_w (); |
384 | w = get_w (); |
… | |
… | |
339 | } |
387 | } |
340 | |
388 | |
341 | return newSVpvn (oid, app - oid); |
389 | return newSVpvn (oid, app - oid); |
342 | } |
390 | } |
343 | |
391 | |
|
|
392 | // TODO: this is unacceptably slow |
|
|
393 | static SV * |
|
|
394 | decode_ucs (int chrsize) |
|
|
395 | { |
|
|
396 | SV *res = NEWSV (0, 0); |
|
|
397 | |
|
|
398 | U32 len = get_length (); |
|
|
399 | |
|
|
400 | if (len & (chrsize - 1)) |
|
|
401 | croak ("BER_TYPE_UCS has an invalid number of octets (%d)", len); |
|
|
402 | |
|
|
403 | while (len) |
|
|
404 | { |
|
|
405 | U8 b1 = get_u8 (); |
|
|
406 | U8 b2 = get_u8 (); |
|
|
407 | U32 chr = (b1 << 8) | b2; |
|
|
408 | |
|
|
409 | if (chrsize == 4) |
|
|
410 | { |
|
|
411 | U8 b3 = get_u8 (); |
|
|
412 | U8 b4 = get_u8 (); |
|
|
413 | chr = (chr << 16) | (b3 << 8) | b4; |
|
|
414 | } |
|
|
415 | |
|
|
416 | U8 uchr [UTF8_MAXBYTES]; |
|
|
417 | int uclen = uvuni_to_utf8 (uchr, chr) - uchr; |
|
|
418 | |
|
|
419 | sv_catpvn (res, (const char *)uchr, uclen); |
|
|
420 | len -= chrsize; |
|
|
421 | } |
|
|
422 | |
|
|
423 | SvUTF8_on (res); |
|
|
424 | |
|
|
425 | return res; |
|
|
426 | } |
|
|
427 | |
344 | static SV * |
428 | static SV * |
345 | decode_ber () |
429 | decode_ber () |
346 | { |
430 | { |
347 | int identifier = get_u8 (); |
431 | int identifier = get_u8 (); |
348 | |
432 | |
349 | SV *res; |
433 | SV *res; |
350 | |
434 | |
351 | int constructed = identifier & ASN_CONSTRUCTED; |
435 | int constructed = identifier & ASN_CONSTRUCTED; |
352 | int klass = identifier & ASN_CLASS_MASK; |
436 | int klass = (identifier & ASN_CLASS_MASK) >> ASN_CLASS_SHIFT; |
353 | int tag = identifier & ASN_TAG_MASK; |
437 | int tag = identifier & ASN_TAG_MASK; |
354 | |
438 | |
355 | if (tag == ASN_TAG_BER) |
439 | if (tag == ASN_TAG_BER) |
356 | tag = get_w (); |
440 | tag = get_w (); |
357 | |
441 | |
358 | if (tag == ASN_TAG_BER) |
442 | if (tag == ASN_TAG_BER) |
… | |
… | |
371 | croak ("constructed type %02x overflow (%x %x)\n", identifier, cur - buf, seqend); |
455 | croak ("constructed type %02x overflow (%x %x)\n", identifier, cur - buf, seqend); |
372 | |
456 | |
373 | res = newRV_inc ((SV *)av); |
457 | res = newRV_inc ((SV *)av); |
374 | } |
458 | } |
375 | else |
459 | else |
376 | switch (identifier) |
460 | switch (profile_lookup (cur_profile, klass, tag)) |
377 | { |
461 | { |
378 | case ASN_NULL: |
462 | case BER_TYPE_NULL: |
379 | res = &PL_sv_undef; |
463 | res = &PL_sv_undef; |
380 | break; |
464 | break; |
381 | |
465 | |
382 | case ASN_OBJECT_IDENTIFIER: |
466 | case BER_TYPE_BOOL: |
|
|
467 | { |
|
|
468 | U32 len = get_length (); |
|
|
469 | |
|
|
470 | if (len != 1) |
|
|
471 | croak ("BER_TYPE_BOOLEAN type with invalid length %d encountered", len); |
|
|
472 | |
|
|
473 | res = newSVcacheint (get_u8 () ? 0 : 1); |
|
|
474 | } |
|
|
475 | break; |
|
|
476 | |
|
|
477 | case BER_TYPE_OID: |
383 | res = decode_object_identifier (); |
478 | res = decode_oid (0); |
384 | break; |
479 | break; |
385 | |
480 | |
386 | case ASN_INTEGER32: |
481 | case BER_TYPE_RELOID: |
|
|
482 | res = decode_oid (1); |
|
|
483 | break; |
|
|
484 | |
|
|
485 | case BER_TYPE_INT: |
387 | res = decode_integer32 (); |
486 | res = decode_int (); |
388 | break; |
487 | break; |
389 | |
488 | |
390 | case ASN_APPLICATION | SNMP_UNSIGNED32: |
489 | case BER_TYPE_UTF8: |
391 | case ASN_APPLICATION | SNMP_COUNTER32: |
490 | res = decode_data (); |
392 | case ASN_APPLICATION | SNMP_TIMETICKS: |
491 | SvUTF8_on (res); |
|
|
492 | break; |
|
|
493 | |
|
|
494 | case BER_TYPE_BYTES: |
|
|
495 | res = decode_data (); |
|
|
496 | break; |
|
|
497 | |
|
|
498 | case BER_TYPE_IPADDRESS: |
|
|
499 | { |
|
|
500 | U32 len = get_length (); |
|
|
501 | |
|
|
502 | if (len != 4) |
|
|
503 | croak ("BER_TYPE_IPADDRESS type with invalid length %d encountered", len); |
|
|
504 | |
|
|
505 | U8 c1 = get_u8 (); |
|
|
506 | U8 c2 = get_u8 (); |
|
|
507 | U8 c3 = get_u8 (); |
|
|
508 | U8 c4 = get_u8 (); |
|
|
509 | |
|
|
510 | res = newSVpvf ("%d.%d.%d.%d", c1, c2, c3, c4); |
|
|
511 | } |
|
|
512 | break; |
|
|
513 | |
|
|
514 | case BER_TYPE_UCS2: |
|
|
515 | res = decode_ucs (2); |
|
|
516 | break; |
|
|
517 | |
|
|
518 | case BER_TYPE_UCS4: |
393 | res = decode_unsigned32 (); |
519 | res = decode_ucs (4); |
394 | break; |
520 | break; |
395 | |
521 | |
396 | #if 0 // handled by default case |
522 | case BER_TYPE_REAL: |
397 | case ASN_OCTET_STRING: |
523 | case BER_TYPE_CROAK: |
398 | case ASN_APPLICATION | ASN_IPADDRESS: |
|
|
399 | case ASN_APPLICATION | ASN_OPAQUE: |
|
|
400 | res = decode_octet_string (); |
|
|
401 | break; |
|
|
402 | #endif |
|
|
403 | |
|
|
404 | case ASN_APPLICATION | SNMP_COUNTER64: |
|
|
405 | res = decode_integer64 (); |
|
|
406 | break; |
|
|
407 | |
|
|
408 | default: |
524 | default: |
409 | res = decode_octet_string (); |
525 | croak ("unconfigured/unsupported class/tag %d/%d", klass, tag); |
410 | break; |
|
|
411 | } |
526 | } |
412 | |
527 | |
413 | AV *av = newAV (); |
528 | AV *av = newAV (); |
414 | av_fill (av, BER_ARRAYSIZE - 1); |
529 | av_fill (av, BER_ARRAYSIZE - 1); |
415 | AvARRAY (av)[BER_CLASS ] = newSVcacheint (klass >> ASN_CLASS_SHIFT); |
530 | AvARRAY (av)[BER_CLASS ] = newSVcacheint (klass); |
416 | AvARRAY (av)[BER_TAG ] = newSVcacheint (tag); |
531 | AvARRAY (av)[BER_TAG ] = newSVcacheint (tag); |
417 | AvARRAY (av)[BER_CONSTRUCTED] = newSVcacheint (constructed ? 1 : 0); |
532 | AvARRAY (av)[BER_CONSTRUCTED] = newSVcacheint (constructed ? 1 : 0); |
418 | AvARRAY (av)[BER_DATA ] = res; |
533 | AvARRAY (av)[BER_DATA ] = res; |
419 | |
534 | |
420 | return newRV_noinc ((SV *)av); |
535 | return newRV_noinc ((SV *)av); |
… | |
… | |
516 | } |
631 | } |
517 | |
632 | |
518 | static void |
633 | static void |
519 | put_length (U32 val) |
634 | put_length (U32 val) |
520 | { |
635 | { |
521 | need (5); |
636 | need (5 + val); |
522 | cur = put_length_at (val, cur); |
637 | cur = put_length_at (val, cur); |
523 | } |
638 | } |
524 | |
639 | |
525 | // return how many bytes the encoded length requires |
640 | // return how many bytes the encoded length requires |
526 | static int length_length (U32 val) |
641 | static int length_length (U32 val) |
… | |
… | |
529 | ? 1 |
644 | ? 1 |
530 | : 2 + (val > 0xffU) + (val > 0xffffU) + (val > 0xffffffU); |
645 | : 2 + (val > 0xffU) + (val > 0xffffU) + (val > 0xffffffU); |
531 | } |
646 | } |
532 | |
647 | |
533 | static void |
648 | static void |
534 | encode_octet_string (SV *sv) |
649 | encode_data (const char *ptr, STRLEN len) |
535 | { |
650 | { |
536 | STRLEN len; |
|
|
537 | char *ptr = SvPVbyte (sv, len); |
|
|
538 | |
|
|
539 | put_length (len); |
651 | put_length (len); |
540 | need (len); |
|
|
541 | memcpy (cur, ptr, len); |
652 | memcpy (cur, ptr, len); |
542 | cur += len; |
653 | cur += len; |
543 | } |
654 | } |
544 | |
655 | |
545 | static void |
656 | static void |
546 | encode_integer32 (IV iv) |
657 | encode_uv (UV uv) |
547 | { |
658 | { |
548 | need (5); |
659 | } |
|
|
660 | |
|
|
661 | static void |
|
|
662 | encode_int (SV *sv) |
|
|
663 | { |
|
|
664 | need (8 + 1 + 1); // 64 bit + length + extra 0 |
|
|
665 | |
|
|
666 | if (expect_false (!SvIOK (sv))) |
|
|
667 | sv_2iv_flags (sv, 0); |
549 | |
668 | |
550 | U8 *lenb = cur++; |
669 | U8 *lenb = cur++; |
551 | |
670 | |
552 | if (iv < 0) |
671 | if (SvIOK_notUV (sv)) |
553 | { |
672 | { |
|
|
673 | IV iv = SvIVX (sv); |
|
|
674 | |
|
|
675 | if (expect_false (iv < 0)) |
|
|
676 | { |
554 | // get two's complement bit pattern - works even on hypthetical non-2c machines |
677 | // get two's complement bit pattern - works even on hypothetical non-2c machines |
555 | U32 uv = iv; |
678 | UV uv = iv; |
556 | |
679 | |
|
|
680 | #if UVSIZE > 4 |
|
|
681 | *cur = uv >> 56; cur += !!(~uv & 0xff80000000000000U); |
|
|
682 | *cur = uv >> 48; cur += !!(~uv & 0xffff800000000000U); |
|
|
683 | *cur = uv >> 40; cur += !!(~uv & 0xffffff8000000000U); |
|
|
684 | *cur = uv >> 32; cur += !!(~uv & 0xffffffff80000000U); |
|
|
685 | #endif |
557 | *cur = uv >> 24; cur += !!(~uv & 0xff800000U); |
686 | *cur = uv >> 24; cur += !!(~uv & 0xffffffffff800000U); |
558 | *cur = uv >> 16; cur += !!(~uv & 0xffff8000U); |
687 | *cur = uv >> 16; cur += !!(~uv & 0xffffffffffff8000U); |
559 | *cur = uv >> 8; cur += !!(~uv & 0xffffff80U); |
688 | *cur = uv >> 8; cur += !!(~uv & 0xffffffffffffff80U); |
560 | *cur = uv ; cur += 1; |
689 | *cur = uv ; cur += 1; |
561 | } |
|
|
562 | else |
|
|
563 | { |
|
|
564 | *cur = iv >> 24; cur += *cur > 0; |
|
|
565 | *cur = iv >> 16; cur += *cur > 0; |
|
|
566 | *cur = iv >> 8; cur += *cur > 0; |
|
|
567 | *cur = iv ; cur += 1; |
|
|
568 | } |
|
|
569 | |
690 | |
570 | *lenb = cur - lenb - 1; |
691 | *lenb = cur - lenb - 1; |
571 | } |
|
|
572 | |
692 | |
573 | static void |
693 | return; |
574 | encode_unsigned64 (U64TYPE uv) |
694 | } |
575 | { |
695 | } |
576 | need (9); |
|
|
577 | |
696 | |
578 | U8 *lenb = cur++; |
697 | UV uv = SvUV (sv); |
579 | |
698 | |
580 | *cur = uv >> 56; cur += *cur > 0; |
699 | // prepend an extra 0 if the high bit is 1 |
581 | *cur = uv >> 48; cur += *cur > 0; |
700 | *cur = 0; cur += !!(uv & ((UV)1 << (UVSIZE * 8 - 1))); |
582 | *cur = uv >> 40; cur += *cur > 0; |
701 | |
583 | *cur = uv >> 32; cur += *cur > 0; |
702 | #if UVSIZE > 4 |
584 | *cur = uv >> 24; cur += *cur > 0; |
703 | *cur = uv >> 56; cur += !!(uv & 0xff80000000000000U); |
585 | *cur = uv >> 16; cur += *cur > 0; |
704 | *cur = uv >> 48; cur += !!(uv & 0xffff800000000000U); |
586 | *cur = uv >> 8; cur += *cur > 0; |
705 | *cur = uv >> 40; cur += !!(uv & 0xffffff8000000000U); |
|
|
706 | *cur = uv >> 32; cur += !!(uv & 0xffffffff80000000U); |
|
|
707 | #endif |
|
|
708 | *cur = uv >> 24; cur += !!(uv & 0xffffffffff800000U); |
|
|
709 | *cur = uv >> 16; cur += !!(uv & 0xffffffffffff8000U); |
|
|
710 | *cur = uv >> 8; cur += !!(uv & 0xffffffffffffff80U); |
587 | *cur = uv ; cur += 1; |
711 | *cur = uv ; cur += 1; |
588 | |
712 | |
589 | *lenb = cur - lenb - 1; |
713 | *lenb = cur - lenb - 1; |
590 | } |
714 | } |
591 | |
715 | |
… | |
… | |
631 | |
755 | |
632 | return str; |
756 | return str; |
633 | } |
757 | } |
634 | |
758 | |
635 | static void |
759 | static void |
636 | encode_object_identifier (SV *oid) |
760 | encode_oid (SV *oid, int relative) |
637 | { |
761 | { |
638 | STRLEN slen; |
762 | STRLEN len; |
639 | char *ptr = SvPV (oid, slen); // utf8 vs. bytes does not matter |
763 | char *ptr = SvPV (oid, len); // utf8 vs. bytes does not matter |
640 | |
764 | |
641 | // we need at most as many octets as the string form |
765 | // we need at most as many octets as the string form |
642 | need (slen + 1); |
766 | need (len + 1); |
643 | STRLEN mark = len_fixup_mark (); |
767 | STRLEN mark = len_fixup_mark (); |
644 | |
768 | |
645 | UV w1, w2; |
769 | UV w1, w2; |
646 | |
770 | |
|
|
771 | if (!relative) |
|
|
772 | { |
647 | ptr = read_uv (ptr, &w1); |
773 | ptr = read_uv (ptr, &w1); |
648 | ptr = read_uv (ptr, &w2); |
774 | ptr = read_uv (ptr, &w2); |
649 | |
775 | |
650 | put_w_nocheck (w1 * 40 + w2); |
776 | put_w_nocheck (w1 * 40 + w2); |
|
|
777 | } |
651 | |
778 | |
652 | while (*ptr) |
779 | while (*ptr) |
653 | { |
780 | { |
654 | ptr = read_uv (ptr, &w1); |
781 | ptr = read_uv (ptr, &w1); |
655 | put_w_nocheck (w1); |
782 | put_w_nocheck (w1); |
656 | } |
783 | } |
657 | |
784 | |
658 | len_fixup (mark); |
785 | len_fixup (mark); |
659 | } |
786 | } |
660 | |
787 | |
661 | // checkl whether an SV is a BER tuple and returns its AV * |
788 | // check whether an SV is a BER tuple and returns its AV * |
662 | static AV * |
789 | static AV * |
663 | ber_tuple (SV *tuple) |
790 | ber_tuple (SV *tuple) |
664 | { |
791 | { |
665 | SV *rv; |
792 | SV *rv; |
666 | |
793 | |
… | |
… | |
674 | croak ("BER tuple must contain exactly %d elements, not %d", BER_ARRAYSIZE, AvFILL ((AV *)rv) + 1); |
801 | croak ("BER tuple must contain exactly %d elements, not %d", BER_ARRAYSIZE, AvFILL ((AV *)rv) + 1); |
675 | |
802 | |
676 | return (AV *)rv; |
803 | return (AV *)rv; |
677 | } |
804 | } |
678 | |
805 | |
|
|
806 | static void |
|
|
807 | encode_ucs (SV *data, int chrsize) |
|
|
808 | { |
|
|
809 | STRLEN uchars = sv_len_utf8 (data); |
|
|
810 | STRLEN len;; |
|
|
811 | char *ptr = SvPVutf8 (data, len); |
|
|
812 | |
|
|
813 | put_length (uchars * chrsize); |
|
|
814 | |
|
|
815 | while (uchars--) |
|
|
816 | { |
|
|
817 | STRLEN uclen; |
|
|
818 | UV uchr = utf8_to_uvchr_buf (ptr, ptr + len, &uclen); |
|
|
819 | |
|
|
820 | ptr += uclen; |
|
|
821 | len -= uclen; |
|
|
822 | |
|
|
823 | if (chrsize == 4) |
|
|
824 | { |
|
|
825 | *cur++ = uchr >> 24; |
|
|
826 | *cur++ = uchr >> 16; |
|
|
827 | } |
|
|
828 | |
|
|
829 | *cur++ = uchr >> 8; |
|
|
830 | *cur++ = uchr; |
|
|
831 | } |
|
|
832 | } |
679 | static void |
833 | static void |
680 | encode_ber (SV *tuple) |
834 | encode_ber (SV *tuple) |
681 | { |
835 | { |
682 | AV *av = ber_tuple (tuple); |
836 | AV *av = ber_tuple (tuple); |
683 | |
837 | |
… | |
… | |
716 | encode_ber (AvARRAY (av)[i]); |
870 | encode_ber (AvARRAY (av)[i]); |
717 | |
871 | |
718 | len_fixup (mark); |
872 | len_fixup (mark); |
719 | } |
873 | } |
720 | else |
874 | else |
721 | switch (identifier | tag) |
875 | switch (profile_lookup (cur_profile, klass, tag)) |
722 | { |
876 | { |
723 | case ASN_NULL: |
877 | case BER_TYPE_NULL: |
724 | put_length (0); |
878 | put_length (0); |
725 | break; |
879 | break; |
726 | |
880 | |
727 | case ASN_OBJECT_IDENTIFIER: |
881 | case BER_TYPE_BOOL: |
|
|
882 | put_length (1); |
|
|
883 | *cur++ = SvTRUE (data) ? 0xff : 0x00; |
|
|
884 | break; |
|
|
885 | |
|
|
886 | case BER_TYPE_OID: |
728 | encode_object_identifier (data); |
887 | encode_oid (data, 0); |
729 | break; |
888 | break; |
730 | |
889 | |
731 | case ASN_INTEGER32: |
890 | case BER_TYPE_RELOID: |
|
|
891 | encode_oid (data, 1); |
|
|
892 | break; |
|
|
893 | |
|
|
894 | case BER_TYPE_INT: |
732 | encode_integer32 (SvIV (data)); |
895 | encode_int (data); |
733 | break; |
896 | break; |
734 | |
897 | |
735 | case ASN_APPLICATION | SNMP_UNSIGNED32: |
898 | case BER_TYPE_BYTES: |
736 | case ASN_APPLICATION | SNMP_COUNTER32: |
899 | { |
737 | case ASN_APPLICATION | SNMP_TIMETICKS: |
900 | STRLEN len; |
738 | case ASN_APPLICATION | SNMP_COUNTER64: |
901 | const char *ptr = SvPVbyte (data, len); |
739 | encode_unsigned64 (SvUV (data)); |
902 | encode_data (ptr, len); |
|
|
903 | } |
740 | break; |
904 | break; |
741 | |
905 | |
|
|
906 | case BER_TYPE_UTF8: |
|
|
907 | { |
|
|
908 | STRLEN len; |
|
|
909 | const char *ptr = SvPVutf8 (data, len); |
|
|
910 | encode_data (ptr, len); |
|
|
911 | } |
|
|
912 | break; |
|
|
913 | |
|
|
914 | case BER_TYPE_IPADDRESS: |
|
|
915 | { |
|
|
916 | U8 ip[4]; |
|
|
917 | sscanf (SvPV_nolen (data), "%hhu.%hhu.%hhu.%hhu", ip + 0, ip + 1, ip + 2, ip + 3); |
|
|
918 | encode_data ((const char *)ip, sizeof (ip)); |
|
|
919 | } |
|
|
920 | break; |
|
|
921 | |
|
|
922 | case BER_TYPE_UCS2: |
|
|
923 | encode_ucs (data, 2); |
|
|
924 | break; |
|
|
925 | |
|
|
926 | case BER_TYPE_UCS4: |
|
|
927 | encode_ucs (data, 4); |
|
|
928 | break; |
|
|
929 | |
|
|
930 | case BER_TYPE_REAL: |
|
|
931 | case BER_TYPE_CROAK: |
742 | default: |
932 | default: |
743 | encode_octet_string (data); |
933 | croak ("unconfigured/unsupported class/tag %d/%d", klass, tag); |
744 | break; |
|
|
745 | } |
934 | } |
746 | |
935 | |
747 | } |
936 | } |
748 | |
937 | |
749 | ///////////////////////////////////////////////////////////////////////////// |
938 | ///////////////////////////////////////////////////////////////////////////// |
… | |
… | |
753 | PROTOTYPES: ENABLE |
942 | PROTOTYPES: ENABLE |
754 | |
943 | |
755 | BOOT: |
944 | BOOT: |
756 | { |
945 | { |
757 | HV *stash = gv_stashpv ("Convert::BER::XS", 1); |
946 | HV *stash = gv_stashpv ("Convert::BER::XS", 1); |
|
|
947 | |
|
|
948 | profile_stash = gv_stashpv ("Convert::BER::XS::Profile", 1); |
758 | |
949 | |
759 | static const struct { |
950 | static const struct { |
760 | const char *name; |
951 | const char *name; |
761 | IV iv; |
952 | IV iv; |
762 | } *civ, const_iv[] = { |
953 | } *civ, const_iv[] = { |
763 | { "ASN_BOOLEAN", ASN_BOOLEAN }, |
954 | #define const_iv(name) { # name, name }, |
764 | { "ASN_INTEGER32", ASN_INTEGER32 }, |
955 | const_iv (ASN_BOOLEAN) |
765 | { "ASN_BIT_STRING", ASN_BIT_STRING }, |
956 | const_iv (ASN_INTEGER32) |
766 | { "ASN_OCTET_STRING", ASN_OCTET_STRING }, |
957 | const_iv (ASN_BIT_STRING) |
767 | { "ASN_NULL", ASN_NULL }, |
958 | const_iv (ASN_OCTET_STRING) |
768 | { "ASN_OBJECT_IDENTIFIER", ASN_OBJECT_IDENTIFIER }, |
959 | const_iv (ASN_NULL) |
769 | { "ASN_TAG_BER", ASN_TAG_BER }, |
960 | const_iv (ASN_OBJECT_IDENTIFIER) |
770 | { "ASN_TAG_MASK", ASN_TAG_MASK }, |
961 | const_iv (ASN_OBJECT_DESCRIPTOR) |
771 | { "ASN_CONSTRUCTED", ASN_CONSTRUCTED }, |
962 | const_iv (ASN_OID) |
772 | { "ASN_UNIVERSAL", ASN_UNIVERSAL >> ASN_CLASS_SHIFT }, |
963 | const_iv (ASN_EXTERNAL) |
773 | { "ASN_APPLICATION", ASN_APPLICATION >> ASN_CLASS_SHIFT }, |
964 | const_iv (ASN_REAL) |
774 | { "ASN_CONTEXT", ASN_CONTEXT >> ASN_CLASS_SHIFT }, |
965 | const_iv (ASN_SEQUENCE) |
775 | { "ASN_PRIVATE", ASN_PRIVATE >> ASN_CLASS_SHIFT }, |
966 | const_iv (ASN_ENUMERATED) |
776 | { "ASN_CLASS_MASK", ASN_CLASS_MASK }, |
967 | const_iv (ASN_EMBEDDED_PDV) |
777 | { "ASN_CLASS_SHIFT", ASN_CLASS_SHIFT }, |
968 | const_iv (ASN_UTF8_STRING) |
778 | { "ASN_SEQUENCE", ASN_SEQUENCE }, |
969 | const_iv (ASN_RELATIVE_OID) |
779 | { "SNMP_IPADDRESS", SNMP_IPADDRESS }, |
970 | const_iv (ASN_SET) |
780 | { "SNMP_COUNTER32", SNMP_COUNTER32 }, |
971 | const_iv (ASN_NUMERIC_STRING) |
781 | { "SNMP_UNSIGNED32", SNMP_UNSIGNED32 }, |
972 | const_iv (ASN_PRINTABLE_STRING) |
782 | { "SNMP_TIMETICKS", SNMP_TIMETICKS }, |
973 | const_iv (ASN_TELETEX_STRING) |
783 | { "SNMP_OPAQUE", SNMP_OPAQUE }, |
974 | const_iv (ASN_T61_STRING) |
784 | { "SNMP_COUNTER64", SNMP_COUNTER64 }, |
975 | const_iv (ASN_VIDEOTEX_STRING) |
|
|
976 | const_iv (ASN_IA5_STRING) |
|
|
977 | const_iv (ASN_ASCII_STRING) |
|
|
978 | const_iv (ASN_UTC_TIME) |
|
|
979 | const_iv (ASN_GENERALIZED_TIME) |
|
|
980 | const_iv (ASN_GRAPHIC_STRING) |
|
|
981 | const_iv (ASN_VISIBLE_STRING) |
|
|
982 | const_iv (ASN_ISO646_STRING) |
|
|
983 | const_iv (ASN_GENERAL_STRING) |
|
|
984 | const_iv (ASN_UNIVERSAL_STRING) |
|
|
985 | const_iv (ASN_CHARACTER_STRING) |
|
|
986 | const_iv (ASN_BMP_STRING) |
785 | |
987 | |
786 | { "BER_CLASS" , BER_CLASS }, |
988 | const_iv (ASN_UNIVERSAL) |
787 | { "BER_TAG" , BER_TAG }, |
989 | const_iv (ASN_APPLICATION) |
788 | { "BER_CONSTRUCTED", BER_CONSTRUCTED }, |
990 | const_iv (ASN_CONTEXT) |
789 | { "BER_DATA" , BER_DATA }, |
991 | const_iv (ASN_PRIVATE) |
|
|
992 | |
|
|
993 | const_iv (BER_CLASS) |
|
|
994 | const_iv (BER_TAG) |
|
|
995 | const_iv (BER_CONSTRUCTED) |
|
|
996 | const_iv (BER_DATA) |
|
|
997 | |
|
|
998 | const_iv (BER_TYPE_BYTES) |
|
|
999 | const_iv (BER_TYPE_UTF8) |
|
|
1000 | const_iv (BER_TYPE_UCS2) |
|
|
1001 | const_iv (BER_TYPE_UCS4) |
|
|
1002 | const_iv (BER_TYPE_INT) |
|
|
1003 | const_iv (BER_TYPE_OID) |
|
|
1004 | const_iv (BER_TYPE_RELOID) |
|
|
1005 | const_iv (BER_TYPE_NULL) |
|
|
1006 | const_iv (BER_TYPE_BOOL) |
|
|
1007 | const_iv (BER_TYPE_REAL) |
|
|
1008 | const_iv (BER_TYPE_IPADDRESS) |
|
|
1009 | const_iv (BER_TYPE_CROAK) |
|
|
1010 | |
|
|
1011 | const_iv (SNMP_IPADDRESS) |
|
|
1012 | const_iv (SNMP_COUNTER32) |
|
|
1013 | const_iv (SNMP_UNSIGNED32) |
|
|
1014 | const_iv (SNMP_TIMETICKS) |
|
|
1015 | const_iv (SNMP_OPAQUE) |
|
|
1016 | const_iv (SNMP_COUNTER64) |
790 | }; |
1017 | }; |
791 | |
1018 | |
792 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
1019 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
793 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
1020 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
794 | } |
1021 | } |
795 | |
1022 | |
796 | SV * |
1023 | SV * |
797 | ber_decode (SV *ber) |
1024 | ber_decode (SV *ber, SV *profile = &PL_sv_undef) |
798 | CODE: |
1025 | CODE: |
799 | { |
1026 | { |
|
|
1027 | cur_profile = SvPROFILE (profile); |
800 | STRLEN len; |
1028 | STRLEN len; |
801 | |
|
|
802 | buf = SvPVbyte (ber, len); |
1029 | buf = SvPVbyte (ber, len); |
803 | cur = buf; |
1030 | cur = buf; |
804 | end = buf + len; |
1031 | end = buf + len; |
805 | |
1032 | |
806 | RETVAL = decode_ber (); |
1033 | RETVAL = decode_ber (); |
… | |
… | |
881 | } |
1108 | } |
882 | |
1109 | |
883 | ############################################################################# |
1110 | ############################################################################# |
884 | |
1111 | |
885 | void |
1112 | void |
886 | ber_encode (SV *tuple) |
1113 | ber_encode (SV *tuple, SV *profile = &PL_sv_undef) |
887 | PPCODE: |
1114 | PPCODE: |
888 | { |
1115 | { |
|
|
1116 | cur_profile = SvPROFILE (profile); |
889 | buf_sv = sv_2mortal (NEWSV (0, 256)); |
1117 | buf_sv = sv_2mortal (NEWSV (0, 256)); |
890 | SvPOK_only (buf_sv); |
1118 | SvPOK_only (buf_sv); |
891 | set_buf (buf_sv); |
1119 | set_buf (buf_sv); |
892 | |
1120 | |
893 | encode_ber (tuple); |
1121 | encode_ber (tuple); |
… | |
… | |
923 | AvARRAY (av)[BER_DATA ] = newSVsv (arrayref); |
1151 | AvARRAY (av)[BER_DATA ] = newSVsv (arrayref); |
924 | RETVAL = newRV_noinc ((SV *)av); |
1152 | RETVAL = newRV_noinc ((SV *)av); |
925 | } |
1153 | } |
926 | OUTPUT: RETVAL |
1154 | OUTPUT: RETVAL |
927 | |
1155 | |
|
|
1156 | MODULE = Convert::BER::XS PACKAGE = Convert::BER::XS::Profile |
|
|
1157 | |
|
|
1158 | SV * |
|
|
1159 | new (SV *klass) |
|
|
1160 | CODE: |
|
|
1161 | RETVAL = profile_new (); |
|
|
1162 | OUTPUT: RETVAL |
|
|
1163 | |
|
|
1164 | void |
|
|
1165 | set (SV *profile, int klass, int tag, int type) |
|
|
1166 | CODE: |
|
|
1167 | profile_set (SvPROFILE (profile), klass, tag, type); |
|
|
1168 | |
|
|
1169 | IV |
|
|
1170 | get (SV *profile, int klass, int tag) |
|
|
1171 | CODE: |
|
|
1172 | RETVAL = profile_lookup (SvPROFILE (profile), klass, tag); |
|
|
1173 | OUTPUT: RETVAL |
|
|
1174 | |
|
|
1175 | void |
|
|
1176 | _set_default (SV *profile) |
|
|
1177 | CODE: |
|
|
1178 | default_profile = SvPROFILE (profile); |
|
|
1179 | |
|
|
1180 | |