blob: dfb406367fea72e2bf11b4c1f579ca1452140ead [file] [log] [blame]
Lev Walkin22b54552004-10-28 13:22:54 +00001/*
Lev Walkind0625682006-08-25 02:35:08 +00002 * Generic converter template for a selected ASN.1 type.
Lev Walkind19216f2017-08-04 03:02:57 -07003 * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>.
Lev Walkin8a4a06c2007-06-29 12:44:01 +00004 * All rights reserved.
Lev Walkin22b54552004-10-28 13:22:54 +00005 *
Lev Walkind0625682006-08-25 02:35:08 +00006 * To compile with your own ASN.1 type, please redefine the PDU as shown:
Lev Walkin22b54552004-10-28 13:22:54 +00007 *
Lev Walkind0625682006-08-25 02:35:08 +00008 * cc -DPDU=MyCustomType -o myDecoder.o -c converter-sample.c
Lev Walkin22b54552004-10-28 13:22:54 +00009 */
Lev Walkinfb35e082017-08-04 03:06:51 -070010#ifdef HAVE_CONFIG_H
Lev Walkin22b54552004-10-28 13:22:54 +000011#include <config.h>
12#endif
13#include <stdio.h>
14#include <sys/types.h>
Lev Walkinfb35e082017-08-04 03:06:51 -070015#include <stdlib.h> /* for atoi(3) */
16#include <unistd.h> /* for getopt(3) */
17#include <string.h> /* for strerror(3) */
18#include <sysexits.h> /* for EX_* exit codes */
19#include <errno.h> /* for errno */
Lev Walkin22b54552004-10-28 13:22:54 +000020
Lev Walkin00949562005-03-10 13:39:03 +000021#include <asn_application.h>
Lev Walkinfb35e082017-08-04 03:06:51 -070022#include <asn_internal.h> /* for ASN__DEFAULT_STACK_MAX */
Lev Walkin22b54552004-10-28 13:22:54 +000023
Lev Walkind0625682006-08-25 02:35:08 +000024/* Convert "Type" defined by -DPDU into "asn_DEF_Type" */
Lev Walkinfb35e082017-08-04 03:06:51 -070025#define ASN_DEF_PDU(t) asn_DEF_ ## t
26#define DEF_PDU_Type(t) ASN_DEF_PDU(t)
27#define PDU_Type DEF_PDU_Type(PDU)
Lev Walkind0625682006-08-25 02:35:08 +000028
Lev Walkinfb35e082017-08-04 03:06:51 -070029extern asn_TYPE_descriptor_t PDU_Type; /* ASN.1 type to be decoded */
30#ifdef ASN_PDU_COLLECTION /* Generated by asn1c: -pdu=... */
Lev Walkin59b176e2005-11-26 11:25:14 +000031extern asn_TYPE_descriptor_t *asn_pdu_collection[];
32#endif
Lev Walkin22b54552004-10-28 13:22:54 +000033
34/*
Lev Walkin00949562005-03-10 13:39:03 +000035 * Open file and parse its contens.
Lev Walkin22b54552004-10-28 13:22:54 +000036 */
Lev Walkin00949562005-03-10 13:39:03 +000037static void *data_decode_from_file(asn_TYPE_descriptor_t *asnTypeOfPDU,
Lev Walkinfb35e082017-08-04 03:06:51 -070038 FILE *file, const char *name, ssize_t suggested_bufsize, int first_pdu);
Lev Walkind1bfea62005-11-08 03:06:16 +000039static int write_out(const void *buffer, size_t size, void *key);
Lev Walkinc744a022006-09-15 18:33:25 +000040static FILE *argument_to_file(char *av[], int idx);
41static char *argument_to_name(char *av[], int idx);
Lev Walkin22b54552004-10-28 13:22:54 +000042
Lev Walkinfb35e082017-08-04 03:06:51 -070043 int opt_debug; /* -d (or -dd) */
44static int opt_check; /* -c (constraints checking) */
45static int opt_stack; /* -s (maximum stack size) */
46static int opt_nopad; /* -per-nopad (PER input is not padded) */
47static int opt_onepdu; /* -1 (decode single PDU) */
Lev Walkind1bfea62005-11-08 03:06:16 +000048
49/* Input data format selector */
50static enum input_format {
Lev Walkinfb35e082017-08-04 03:06:51 -070051 INP_BER, /* -iber: BER input */
52 INP_XER, /* -ixer: XER input */
53 INP_OER, /* -ioer: OER input */
54 INP_PER /* -iper: Unaligned PER input */
55} iform; /* -i<format> */
Lev Walkind1bfea62005-11-08 03:06:16 +000056
57/* Output data format selector */
58static enum output_format {
Lev Walkinfb35e082017-08-04 03:06:51 -070059 OUT_XER, /* -oxer: XER (XML) output */
60 OUT_DER, /* -oder: DER (BER) output */
61 OUT_OER, /* -ooer: Canonical OER output */
62 OUT_PER, /* -oper: Unaligned PER output */
63 OUT_TEXT, /* -otext: semi-structured text */
64 OUT_NULL /* -onull: No pretty-printing */
65} oform; /* -o<format> */
Lev Walkin22b54552004-10-28 13:22:54 +000066
Lev Walkinfb35e082017-08-04 03:06:51 -070067#ifdef JUNKTEST /* Enable -J <probability> */
68#define JUNKOPT "J:"
69static double opt_jprob; /* Junk bit probability */
Lev Walkin1f12da42006-09-24 19:47:07 +000070static int junk_failures;
71static void junk_bytes_with_probability(uint8_t *, size_t, double prob);
72#else
Lev Walkinfb35e082017-08-04 03:06:51 -070073#define JUNKOPT
Lev Walkin1f12da42006-09-24 19:47:07 +000074#endif
75
Lev Walkin1d9e8dd2005-12-07 05:46:03 +000076/* Debug output function */
77static inline void
78DEBUG(const char *fmt, ...) {
Lev Walkinfb35e082017-08-04 03:06:51 -070079 va_list ap;
80 if(!opt_debug) return;
81 fprintf(stderr, "AD: ");
82 va_start(ap, fmt);
83 vfprintf(stderr, fmt, ap);
84 va_end(ap);
85 fprintf(stderr, "\n");
Lev Walkin1d9e8dd2005-12-07 05:46:03 +000086}
Lev Walkin22b54552004-10-28 13:22:54 +000087
88int
Lev Walkinc744a022006-09-15 18:33:25 +000089main(int ac, char *av[]) {
Lev Walkinfb35e082017-08-04 03:06:51 -070090 static asn_TYPE_descriptor_t *pduType = &PDU_Type;
91 ssize_t suggested_bufsize = 8192; /* close or equal to stdio buffer */
92 int number_of_iterations = 1;
93 int num;
94 int ch;
Lev Walkin22b54552004-10-28 13:22:54 +000095
Lev Walkinfb35e082017-08-04 03:06:51 -070096 /* Figure out if specialty decoder needs to be default */
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080097 if(pduType->op->oer_decoder)
Lev Walkinfb35e082017-08-04 03:06:51 -070098 iform = INP_OER;
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080099 else if(pduType->op->uper_decoder)
Lev Walkinfb35e082017-08-04 03:06:51 -0700100 iform = INP_PER;
Lev Walkin59b176e2005-11-26 11:25:14 +0000101
Lev Walkinfb35e082017-08-04 03:06:51 -0700102 /*
103 * Pocess the command-line argments.
104 */
105 while((ch = getopt(ac, av, "i:o:1b:cdn:p:hs:" JUNKOPT)) != -1)
106 switch(ch) {
107 case 'i':
108 if(optarg[0] == 'b') { iform = INP_BER; break; }
109 if(optarg[0] == 'x') { iform = INP_XER; break; }
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800110 if(pduType->op->oer_decoder
Lev Walkin7e5ea1d2017-08-06 00:59:28 -0700111 && optarg[0] == 'o') { iform = INP_OER; break; }
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800112 if(pduType->op->uper_decoder
Lev Walkinfb35e082017-08-04 03:06:51 -0700113 && optarg[0] == 'p') { iform = INP_PER; break; }
114 fprintf(stderr, "-i<format>: '%s': improper format selector\n",
115 optarg);
116 exit(EX_UNAVAILABLE);
117 case 'o':
118 if(optarg[0] == 'd') { oform = OUT_DER; break; }
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800119 if(pduType->op->oer_encoder
Lev Walkinfb35e082017-08-04 03:06:51 -0700120 && optarg[0] == 'o') { oform = OUT_OER; break; }
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800121 if(pduType->op->uper_encoder
Lev Walkinfb35e082017-08-04 03:06:51 -0700122 && optarg[0] == 'p') { oform = OUT_PER; break; }
123 if(optarg[0] == 'x') { oform = OUT_XER; break; }
124 if(optarg[0] == 't') { oform = OUT_TEXT; break; }
125 if(optarg[0] == 'n') { oform = OUT_NULL; break; }
126 fprintf(stderr, "-o<format>: '%s': improper format selector\n",
127 optarg);
128 exit(EX_UNAVAILABLE);
129 case '1':
130 opt_onepdu = 1;
131 break;
132 case 'b':
133 suggested_bufsize = atoi(optarg);
134 if(suggested_bufsize < 1
135 || suggested_bufsize > 16 * 1024 * 1024) {
136 fprintf(stderr,
137 "-b %s: Improper buffer size (1..16M)\n",
138 optarg);
139 exit(EX_UNAVAILABLE);
140 }
141 break;
142 case 'c':
143 opt_check = 1;
144 break;
145 case 'd':
146 opt_debug++; /* Double -dd means ASN.1 debug */
147 break;
148 case 'n':
149 number_of_iterations = atoi(optarg);
150 if(number_of_iterations < 1) {
151 fprintf(stderr,
152 "-n %s: Improper iterations count\n", optarg);
153 exit(EX_UNAVAILABLE);
154 }
155 break;
156 case 'p':
157 if(strcmp(optarg, "er-nopad") == 0) {
158 opt_nopad = 1;
159 break;
160 }
161#ifdef ASN_PDU_COLLECTION
162 if(strcmp(optarg, "list") == 0) {
163 asn_TYPE_descriptor_t **pdu = asn_pdu_collection;
164 fprintf(stderr, "Available PDU types:\n");
165 for(; *pdu; pdu++) printf("%s\n", (*pdu)->name);
166 exit(0);
167 } else if(optarg[0] >= 'A' && optarg[0] <= 'Z') {
168 asn_TYPE_descriptor_t **pdu = asn_pdu_collection;
169 while(*pdu && strcmp((*pdu)->name, optarg)) pdu++;
170 if(*pdu) { pduType = *pdu; break; }
171 fprintf(stderr, "-p %s: Unrecognized PDU\n", optarg);
Lev Walkin7e5ea1d2017-08-06 00:59:28 -0700172 exit(EX_USAGE);
173 }
174#else /* Without -pdu=auto there's just a single type */
175 if(strcmp(optarg, "list") == 0) {
176 fprintf(stderr, "Available PDU types:\n");
177 printf("%s\n", pduType->name);
178 exit(0);
179 } else if(optarg[0] >= 'A' && optarg[0] <= 'Z') {
180 if(strcmp(optarg, pduType->name) == 0) {
181 break;
182 }
183 fprintf(stderr, "-p %s: Unrecognized PDU\n", optarg);
184 exit(EX_USAGE);
Lev Walkinfb35e082017-08-04 03:06:51 -0700185 }
186#endif /* ASN_PDU_COLLECTION */
187 fprintf(stderr, "-p %s: Unrecognized option\n", optarg);
188 exit(EX_UNAVAILABLE);
189 case 's':
190 opt_stack = atoi(optarg);
191 if(opt_stack < 0) {
192 fprintf(stderr,
193 "-s %s: Non-negative value expected\n",
194 optarg);
195 exit(EX_UNAVAILABLE);
196 }
197 break;
198#ifdef JUNKTEST
199 case 'J':
200 opt_jprob = strtod(optarg, 0);
201 if(opt_jprob <= 0.0 || opt_jprob > 1.0) {
202 fprintf(stderr,
203 "-J %s: Probability range 0..1 expected \n",
204 optarg);
205 exit(EX_UNAVAILABLE);
206 }
207 break;
208#endif /* JUNKTEST */
209 case 'h':
210 default:
211#ifdef ASN_CONVERTER_TITLE
212#define _AXS(x) #x
213#define _ASX(x) _AXS(x)
214 fprintf(stderr, "%s\n", _ASX(ASN_CONVERTER_TITLE));
Lev Walkin8a4a06c2007-06-29 12:44:01 +0000215#endif
Lev Walkinae0c3c22017-08-26 17:20:32 -0700216 fprintf(stderr, "Usage: %s [options] <datafile> ...\n", av[0]);
Lev Walkinfb35e082017-08-04 03:06:51 -0700217 fprintf(stderr, "Where options are:\n");
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800218 if(pduType->op->oer_decoder)
Lev Walkinfb35e082017-08-04 03:06:51 -0700219 fprintf(stderr,
220 " -ioer Input is in OER (Octet Encoding Rules)%s\n",
221 iform == INP_OER ? " (DEFAULT)" : "");
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800222 if(pduType->op->uper_decoder)
Lev Walkinfb35e082017-08-04 03:06:51 -0700223 fprintf(stderr,
224 " -iper Input is in Unaligned PER (Packed Encoding Rules)%s\n",
225 iform == INP_PER ? " (DEFAULT)" : "");
226 fprintf(stderr,
227 " -iber Input is in BER (Basic Encoding Rules)%s\n",
228 iform == INP_BER ? " (DEFAULT)" : "");
229 fprintf(stderr,
230 " -ixer Input is in XER (XML Encoding Rules)\n");
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800231 if(pduType->op->oer_encoder)
Lev Walkinfb35e082017-08-04 03:06:51 -0700232 fprintf(stderr,
233 " -ooer Output in Canonical OER (Octet Encoding Rules)\n");
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800234 if(pduType->op->uper_encoder)
Lev Walkinfb35e082017-08-04 03:06:51 -0700235 fprintf(stderr,
236 " -oper Output in Unaligned PER (Packed Encoding Rules)\n");
237 fprintf(stderr,
238 " -oder Output in DER (Distinguished Encoding Rules)\n"
239 " -oxer Output in XER (XML Encoding Rules) (DEFAULT)\n"
240 " -otext Output in plain semi-structured text (dump)\n"
241 " -onull Verify (decode) input, but do not output\n");
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +0800242 if(pduType->op->uper_decoder)
Lev Walkinfb35e082017-08-04 03:06:51 -0700243 fprintf(stderr,
244 " -per-nopad Assume PER PDUs are not padded (-iper)\n");
245#ifdef ASN_PDU_COLLECTION
246 fprintf(stderr,
247 " -p <PDU> Specify PDU type to decode\n"
248 " -p list List available PDUs\n");
249#endif /* ASN_PDU_COLLECTION */
250 fprintf(stderr,
251 " -1 Decode only the first PDU in file\n"
252 " -b <size> Set the i/o buffer size (default is %ld)\n"
253 " -c Check ASN.1 constraints after decoding\n"
254 " -d Enable debugging (-dd is even better)\n"
255 " -n <num> Process files <num> times\n"
256 " -s <size> Set the stack usage limit (default is %d)\n"
257#ifdef JUNKTEST
258 " -J <prob> Set random junk test bit garbaging probability\n"
Lev Walkin1f12da42006-09-24 19:47:07 +0000259#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700260 , (long)suggested_bufsize, ASN__DEFAULT_STACK_MAX);
261 exit(EX_USAGE);
262 }
Lev Walkin22b54552004-10-28 13:22:54 +0000263
Lev Walkinfb35e082017-08-04 03:06:51 -0700264 ac -= optind;
265 av += optind;
Lev Walkin22b54552004-10-28 13:22:54 +0000266
Lev Walkinfb35e082017-08-04 03:06:51 -0700267 if(ac < 1) {
268 fprintf(stderr, "%s: No input files specified. "
269 "Try '-h' for more information\n",
270 av[-optind]);
271 exit(EX_USAGE);
272 }
Lev Walkin22b54552004-10-28 13:22:54 +0000273
Lev Walkinfb35e082017-08-04 03:06:51 -0700274 setvbuf(stdout, 0, _IOLBF, 0);
Lev Walkin22b54552004-10-28 13:22:54 +0000275
Lev Walkinfb35e082017-08-04 03:06:51 -0700276 for(num = 0; num < number_of_iterations; num++) {
277 int ac_i;
278 /*
279 * Process all files in turn.
280 */
281 for(ac_i = 0; ac_i < ac; ac_i++) {
282 asn_enc_rval_t erv;
283 void *structure; /* Decoded structure */
284 FILE *file = argument_to_file(av, ac_i);
285 char *name = argument_to_name(av, ac_i);
286 int first_pdu;
Lev Walkin22b54552004-10-28 13:22:54 +0000287
Lev Walkinfb35e082017-08-04 03:06:51 -0700288 for(first_pdu = 1; first_pdu || !opt_onepdu; first_pdu = 0) {
289 /*
290 * Decode the encoded structure from file.
291 */
292 structure = data_decode_from_file(pduType, file, name,
293 suggested_bufsize, first_pdu);
294 if(!structure) {
295 if(errno) {
296 /* Error message is already printed */
297 exit(EX_DATAERR);
298 } else {
299 /* EOF */
300 break;
301 }
302 }
Lev Walkin22b54552004-10-28 13:22:54 +0000303
Lev Walkinfb35e082017-08-04 03:06:51 -0700304 /* Check ASN.1 constraints */
305 if(opt_check) {
306 char errbuf[128];
307 size_t errlen = sizeof(errbuf);
308 if(asn_check_constraints(pduType, structure, errbuf, &errlen)) {
309 fprintf(stderr,
310 "%s: ASN.1 constraint "
311 "check failed: %s\n",
312 name, errbuf);
313 exit(EX_DATAERR);
314 }
315 }
Lev Walkin22b54552004-10-28 13:22:54 +0000316
Lev Walkinfb35e082017-08-04 03:06:51 -0700317 switch(oform) {
318 case OUT_NULL:
319#ifdef JUNKTEST
320 if(opt_jprob == 0.0)
Lev Walkin1f12da42006-09-24 19:47:07 +0000321#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700322 fprintf(stderr, "%s: decoded successfully\n", name);
323 break;
324 case OUT_TEXT: /* -otext */
325 asn_fprint(stdout, pduType, structure);
326 break;
327 case OUT_XER: /* -oxer */
328 if(xer_fprint(stdout, pduType, structure)) {
329 fprintf(stderr, "%s: Cannot convert %s into XML\n", name,
330 pduType->name);
331 exit(EX_UNAVAILABLE);
332 }
333 break;
334 case OUT_DER:
335 erv = der_encode(pduType, structure, write_out, stdout);
336 if(erv.encoded < 0) {
337 fprintf(stderr, "%s: Cannot convert %s into DER\n", name,
338 pduType->name);
339 exit(EX_UNAVAILABLE);
340 }
341 DEBUG("Encoded in %ld bytes of DER", (long)erv.encoded);
342 break;
343 case OUT_OER:
Lev Walkin69033802017-08-25 12:15:58 -0700344#ifdef ASN_DISABLE_OER_SUPPORT
345 erv.encoded = -1;
346#else
Lev Walkinfb35e082017-08-04 03:06:51 -0700347 erv = oer_encode(pduType, structure, write_out, stdout);
Lev Walkin69033802017-08-25 12:15:58 -0700348#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700349 if(erv.encoded < 0) {
350 fprintf(stderr, "%s: Cannot convert %s into oER\n", name,
351 pduType->name);
352 exit(EX_UNAVAILABLE);
353 }
354 DEBUG("Encoded in %ld bytes of OER", (long)erv.encoded);
355 break;
356 case OUT_PER:
Lev Walkin69033802017-08-25 12:15:58 -0700357#ifdef ASN_DISABLE_PER_SUPPORT
358 erv.encoded = -1;
359#else
Lev Walkinfb35e082017-08-04 03:06:51 -0700360 erv = uper_encode(pduType, structure, write_out, stdout);
Lev Walkin69033802017-08-25 12:15:58 -0700361#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700362 if(erv.encoded < 0) {
363 fprintf(stderr,
364 "%s: Cannot convert %s into Unaligned PER\n", name,
365 pduType->name);
366 exit(EX_UNAVAILABLE);
367 }
368 DEBUG("Encoded in %ld bits of UPER", (long)erv.encoded);
369 break;
370 }
Lev Walkind1bfea62005-11-08 03:06:16 +0000371
Lev Walkinfb35e082017-08-04 03:06:51 -0700372 ASN_STRUCT_FREE(*pduType, structure);
373 }
Lev Walkinbc691772006-09-17 11:02:53 +0000374
Lev Walkinfb35e082017-08-04 03:06:51 -0700375 if(file && file != stdin) {
376 fclose(file);
377 }
378 }
379 }
Lev Walkin22b54552004-10-28 13:22:54 +0000380
Lev Walkinfb35e082017-08-04 03:06:51 -0700381#ifdef JUNKTEST
382 if(opt_jprob > 0.0) {
383 fprintf(stderr, "Junked %f OK (%d/%d)\n",
384 opt_jprob, junk_failures, number_of_iterations);
385 }
386#endif /* JUNKTEST */
Lev Walkin1f12da42006-09-24 19:47:07 +0000387
Lev Walkinfb35e082017-08-04 03:06:51 -0700388 return 0;
Lev Walkin22b54552004-10-28 13:22:54 +0000389}
390
Lev Walkin419f6752006-09-13 04:02:00 +0000391static struct dynamic_buffer {
Lev Walkinfb35e082017-08-04 03:06:51 -0700392 uint8_t *data; /* Pointer to the data bytes */
393 size_t offset; /* Offset from the start */
394 size_t length; /* Length of meaningful contents */
395 size_t unbits; /* Unused bits in the last byte */
396 size_t allocated; /* Allocated memory for data */
397 int nreallocs; /* Number of data reallocations */
398 off_t bytes_shifted; /* Number of bytes ever shifted */
Lev Walkin419f6752006-09-13 04:02:00 +0000399} DynamicBuffer;
Lev Walkin22b54552004-10-28 13:22:54 +0000400
Lev Walkin5a621d62006-09-18 20:05:34 +0000401static void
402buffer_dump() {
Lev Walkinfb35e082017-08-04 03:06:51 -0700403 uint8_t *p = DynamicBuffer.data + DynamicBuffer.offset;
404 uint8_t *e = p + DynamicBuffer.length - (DynamicBuffer.unbits ? 1 : 0);
405 if(!opt_debug) return;
406 DEBUG("Buffer: { d=%p, o=%ld, l=%ld, u=%ld, a=%ld, s=%ld }",
407 DynamicBuffer.data,
408 (long)DynamicBuffer.offset,
409 (long)DynamicBuffer.length,
410 (long)DynamicBuffer.unbits,
411 (long)DynamicBuffer.allocated,
412 (long)DynamicBuffer.bytes_shifted);
413 for(; p < e; p++) {
414 fprintf(stderr, " %c%c%c%c%c%c%c%c",
415 ((*p >> 7) & 1) ? '1' : '0',
416 ((*p >> 6) & 1) ? '1' : '0',
417 ((*p >> 5) & 1) ? '1' : '0',
418 ((*p >> 4) & 1) ? '1' : '0',
419 ((*p >> 3) & 1) ? '1' : '0',
420 ((*p >> 2) & 1) ? '1' : '0',
421 ((*p >> 1) & 1) ? '1' : '0',
422 ((*p >> 0) & 1) ? '1' : '0');
423 }
424 if(DynamicBuffer.unbits) {
425 unsigned int shift;
426 fprintf(stderr, " ");
427 for(shift = 7; shift >= DynamicBuffer.unbits; shift--)
428 fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0');
429 fprintf(stderr, " %ld:%ld\n",
430 (long)DynamicBuffer.length - 1,
431 (long)8 - DynamicBuffer.unbits);
432 } else {
433 fprintf(stderr, " %ld\n", (long)DynamicBuffer.length);
434 }
Lev Walkin5a621d62006-09-18 20:05:34 +0000435}
436
437/*
438 * Move the buffer content left N bits, possibly joining it with
439 * preceeding content.
440 */
441static void
442buffer_shift_left(size_t offset, int bits) {
Lev Walkinfb35e082017-08-04 03:06:51 -0700443 uint8_t *ptr = DynamicBuffer.data + DynamicBuffer.offset + offset;
444 uint8_t *end = DynamicBuffer.data + DynamicBuffer.offset
445 + DynamicBuffer.length - 1;
446
447 if(!bits) return;
Lev Walkin5a621d62006-09-18 20:05:34 +0000448
Lev Walkinfb35e082017-08-04 03:06:51 -0700449 DEBUG("Shifting left %d bits off %ld (o=%ld, u=%ld, l=%ld)",
450 bits, (long)offset,
451 (long)DynamicBuffer.offset,
452 (long)DynamicBuffer.unbits,
453 (long)DynamicBuffer.length);
Lev Walkin5a621d62006-09-18 20:05:34 +0000454
Lev Walkinfb35e082017-08-04 03:06:51 -0700455 if(offset) {
456 int right;
457 right = ptr[0] >> (8 - bits);
Lev Walkin5a621d62006-09-18 20:05:34 +0000458
Lev Walkinfb35e082017-08-04 03:06:51 -0700459 DEBUG("oleft: %c%c%c%c%c%c%c%c",
460 ((ptr[-1] >> 7) & 1) ? '1' : '0',
461 ((ptr[-1] >> 6) & 1) ? '1' : '0',
462 ((ptr[-1] >> 5) & 1) ? '1' : '0',
463 ((ptr[-1] >> 4) & 1) ? '1' : '0',
464 ((ptr[-1] >> 3) & 1) ? '1' : '0',
465 ((ptr[-1] >> 2) & 1) ? '1' : '0',
466 ((ptr[-1] >> 1) & 1) ? '1' : '0',
467 ((ptr[-1] >> 0) & 1) ? '1' : '0');
Lev Walkin5a621d62006-09-18 20:05:34 +0000468
Lev Walkinfb35e082017-08-04 03:06:51 -0700469 DEBUG("oriht: %c%c%c%c%c%c%c%c",
470 ((ptr[0] >> 7) & 1) ? '1' : '0',
471 ((ptr[0] >> 6) & 1) ? '1' : '0',
472 ((ptr[0] >> 5) & 1) ? '1' : '0',
473 ((ptr[0] >> 4) & 1) ? '1' : '0',
474 ((ptr[0] >> 3) & 1) ? '1' : '0',
475 ((ptr[0] >> 2) & 1) ? '1' : '0',
476 ((ptr[0] >> 1) & 1) ? '1' : '0',
477 ((ptr[0] >> 0) & 1) ? '1' : '0');
Lev Walkin5a621d62006-09-18 20:05:34 +0000478
Lev Walkinfb35e082017-08-04 03:06:51 -0700479 DEBUG("mriht: %c%c%c%c%c%c%c%c",
480 ((right >> 7) & 1) ? '1' : '0',
481 ((right >> 6) & 1) ? '1' : '0',
482 ((right >> 5) & 1) ? '1' : '0',
483 ((right >> 4) & 1) ? '1' : '0',
484 ((right >> 3) & 1) ? '1' : '0',
485 ((right >> 2) & 1) ? '1' : '0',
486 ((right >> 1) & 1) ? '1' : '0',
487 ((right >> 0) & 1) ? '1' : '0');
Lev Walkin5a621d62006-09-18 20:05:34 +0000488
Lev Walkinfb35e082017-08-04 03:06:51 -0700489 ptr[-1] = (ptr[-1] & (0xff << bits)) | right;
Lev Walkin5a621d62006-09-18 20:05:34 +0000490
Lev Walkinfb35e082017-08-04 03:06:51 -0700491 DEBUG("after: %c%c%c%c%c%c%c%c",
492 ((ptr[-1] >> 7) & 1) ? '1' : '0',
493 ((ptr[-1] >> 6) & 1) ? '1' : '0',
494 ((ptr[-1] >> 5) & 1) ? '1' : '0',
495 ((ptr[-1] >> 4) & 1) ? '1' : '0',
496 ((ptr[-1] >> 3) & 1) ? '1' : '0',
497 ((ptr[-1] >> 2) & 1) ? '1' : '0',
498 ((ptr[-1] >> 1) & 1) ? '1' : '0',
499 ((ptr[-1] >> 0) & 1) ? '1' : '0');
500 }
Lev Walkin5a621d62006-09-18 20:05:34 +0000501
Lev Walkinfb35e082017-08-04 03:06:51 -0700502 buffer_dump();
Lev Walkin5a621d62006-09-18 20:05:34 +0000503
Lev Walkinfb35e082017-08-04 03:06:51 -0700504 for(; ptr < end; ptr++) {
505 int right = ptr[1] >> (8 - bits);
506 *ptr = (*ptr << bits) | right;
507 }
508 *ptr <<= bits;
Lev Walkin5a621d62006-09-18 20:05:34 +0000509
Lev Walkinfb35e082017-08-04 03:06:51 -0700510 DEBUG("Unbits [%d=>", (int)DynamicBuffer.unbits);
511 if(DynamicBuffer.unbits == 0) {
512 DynamicBuffer.unbits += bits;
513 } else {
514 DynamicBuffer.unbits += bits;
515 if(DynamicBuffer.unbits > 7) {
516 DynamicBuffer.unbits -= 8;
517 DynamicBuffer.length--;
518 DynamicBuffer.bytes_shifted++;
519 }
520 }
521 DEBUG("Unbits =>%d]", (int)DynamicBuffer.unbits);
Lev Walkin5a621d62006-09-18 20:05:34 +0000522
Lev Walkinfb35e082017-08-04 03:06:51 -0700523 buffer_dump();
Lev Walkin5a621d62006-09-18 20:05:34 +0000524
Lev Walkinfb35e082017-08-04 03:06:51 -0700525 DEBUG("Shifted. Now (o=%ld, u=%ld l=%ld)",
526 (long)DynamicBuffer.offset,
527 (long)DynamicBuffer.unbits,
528 (long)DynamicBuffer.length);
529
Lev Walkin5a621d62006-09-18 20:05:34 +0000530
531}
532
Lev Walkin22b54552004-10-28 13:22:54 +0000533/*
Lev Walkind1bfea62005-11-08 03:06:16 +0000534 * Ensure that the buffer contains at least this amount of free space.
Lev Walkin22b54552004-10-28 13:22:54 +0000535 */
Lev Walkin5a621d62006-09-18 20:05:34 +0000536static void add_bytes_to_buffer(const void *data2add, size_t bytes) {
Lev Walkin22b54552004-10-28 13:22:54 +0000537
Lev Walkinfb35e082017-08-04 03:06:51 -0700538 if(bytes == 0) return;
Lev Walkin5a621d62006-09-18 20:05:34 +0000539
Lev Walkinfb35e082017-08-04 03:06:51 -0700540 DEBUG("=> add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }",
541 (long)bytes,
542 (long)DynamicBuffer.offset,
543 (long)DynamicBuffer.length,
544 (long)DynamicBuffer.unbits,
545 (long)DynamicBuffer.allocated);
Lev Walkin22b54552004-10-28 13:22:54 +0000546
Lev Walkinfb35e082017-08-04 03:06:51 -0700547 if(DynamicBuffer.allocated
548 >= (DynamicBuffer.offset + DynamicBuffer.length + bytes)) {
549 DEBUG("\tNo buffer reallocation is necessary");
550 } else if(bytes <= DynamicBuffer.offset) {
551 DEBUG("\tContents shifted by %ld", DynamicBuffer.offset);
Lev Walkin22b54552004-10-28 13:22:54 +0000552
Lev Walkinfb35e082017-08-04 03:06:51 -0700553 /* Shift the buffer contents */
554 memmove(DynamicBuffer.data,
555 DynamicBuffer.data + DynamicBuffer.offset,
556 DynamicBuffer.length);
557 DynamicBuffer.bytes_shifted += DynamicBuffer.offset;
558 DynamicBuffer.offset = 0;
559 } else {
560 size_t newsize = (DynamicBuffer.allocated << 2) + bytes;
561 void *p = MALLOC(newsize);
562 if(!p) {
563 perror("malloc()");
564 exit(EX_OSERR);
565 }
566 memcpy(p,
567 DynamicBuffer.data + DynamicBuffer.offset,
568 DynamicBuffer.length);
569 FREEMEM(DynamicBuffer.data);
570 DynamicBuffer.data = (uint8_t *)p;
571 DynamicBuffer.offset = 0;
572 DynamicBuffer.allocated = newsize;
573 DynamicBuffer.nreallocs++;
574 DEBUG("\tBuffer reallocated to %ld (%d time)",
575 newsize, DynamicBuffer.nreallocs);
576 }
Lev Walkin1d9e8dd2005-12-07 05:46:03 +0000577
Lev Walkinfb35e082017-08-04 03:06:51 -0700578 memcpy(DynamicBuffer.data
579 + DynamicBuffer.offset + DynamicBuffer.length,
580 data2add, bytes);
581 DynamicBuffer.length += bytes;
582 if(DynamicBuffer.unbits) {
583 int bits = DynamicBuffer.unbits;
584 DynamicBuffer.unbits = 0;
585 buffer_shift_left(DynamicBuffer.length - bytes, bits);
586 }
Lev Walkin5a621d62006-09-18 20:05:34 +0000587
Lev Walkinfb35e082017-08-04 03:06:51 -0700588 DEBUG("<= add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }",
589 (long)bytes,
590 (long)DynamicBuffer.offset,
591 (long)DynamicBuffer.length,
592 (long)DynamicBuffer.unbits,
593 (long)DynamicBuffer.allocated);
Lev Walkin22b54552004-10-28 13:22:54 +0000594}
595
Lev Walkinc744a022006-09-15 18:33:25 +0000596static void *
Lev Walkinbc691772006-09-17 11:02:53 +0000597data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *name, ssize_t suggested_bufsize, int on_first_pdu) {
Lev Walkinfb35e082017-08-04 03:06:51 -0700598 static uint8_t *fbuf;
599 static ssize_t fbuf_size;
600 static asn_codec_ctx_t s_codec_ctx;
601 asn_codec_ctx_t *opt_codec_ctx = 0;
602 void *structure = 0;
603 asn_dec_rval_t rval;
604 size_t old_offset;
605 size_t new_offset;
606 int tolerate_eof;
607 size_t rd;
Lev Walkinc744a022006-09-15 18:33:25 +0000608
Lev Walkinfb35e082017-08-04 03:06:51 -0700609 if(!file) {
610 fprintf(stderr, "%s: %s\n", name, strerror(errno));
611 errno = EINVAL;
612 return 0;
613 }
Lev Walkin22b54552004-10-28 13:22:54 +0000614
Lev Walkinfb35e082017-08-04 03:06:51 -0700615 if(opt_stack) {
616 s_codec_ctx.max_stack_size = opt_stack;
617 opt_codec_ctx = &s_codec_ctx;
618 }
Lev Walkin22b54552004-10-28 13:22:54 +0000619
Lev Walkinfb35e082017-08-04 03:06:51 -0700620 DEBUG("Processing %s", name);
Lev Walkin22b54552004-10-28 13:22:54 +0000621
Lev Walkinfb35e082017-08-04 03:06:51 -0700622 /* prepare the file buffer */
623 if(fbuf_size != suggested_bufsize) {
624 fbuf = (uint8_t *)REALLOC(fbuf, suggested_bufsize);
625 if(!fbuf) {
626 perror("realloc()");
627 exit(EX_OSERR);
628 }
629 fbuf_size = suggested_bufsize;
630 }
Lev Walkin22b54552004-10-28 13:22:54 +0000631
Lev Walkinfb35e082017-08-04 03:06:51 -0700632 if(on_first_pdu) {
633 DynamicBuffer.offset = 0;
634 DynamicBuffer.length = 0;
635 DynamicBuffer.unbits = 0;
636 DynamicBuffer.allocated = 0;
637 DynamicBuffer.bytes_shifted = 0;
638 DynamicBuffer.nreallocs = 0;
639 }
Lev Walkinbc691772006-09-17 11:02:53 +0000640
Lev Walkinfb35e082017-08-04 03:06:51 -0700641 old_offset = DynamicBuffer.bytes_shifted + DynamicBuffer.offset;
Lev Walkin22b54552004-10-28 13:22:54 +0000642
Lev Walkinfb35e082017-08-04 03:06:51 -0700643 /* Pretend immediate EOF */
644 rval.code = RC_WMORE;
645 rval.consumed = 0;
Lev Walkind1bfea62005-11-08 03:06:16 +0000646
Lev Walkinfb35e082017-08-04 03:06:51 -0700647 for(tolerate_eof = 1; /* Allow EOF first time buffer is non-empty */
648 (rd = fread(fbuf, 1, fbuf_size, file))
649 || feof(file) == 0
650 || (tolerate_eof && DynamicBuffer.length)
651 ;) {
652 int ecbits = 0; /* Extra consumed bits in case of PER */
653 uint8_t *i_bptr;
654 size_t i_size;
Lev Walkin22b54552004-10-28 13:22:54 +0000655
Lev Walkinfb35e082017-08-04 03:06:51 -0700656 /*
657 * Copy the data over, or use the original buffer.
658 */
659 if(DynamicBuffer.allocated) {
660 /* Append new data into the existing dynamic buffer */
661 add_bytes_to_buffer(fbuf, rd);
662 i_bptr = DynamicBuffer.data + DynamicBuffer.offset;
663 i_size = DynamicBuffer.length;
664 } else {
665 i_bptr = fbuf;
666 i_size = rd;
667 }
Lev Walkin22b54552004-10-28 13:22:54 +0000668
Lev Walkinfb35e082017-08-04 03:06:51 -0700669 DEBUG("Decoding %ld bytes", (long)i_size);
Lev Walkinbc691772006-09-17 11:02:53 +0000670
Lev Walkinfb35e082017-08-04 03:06:51 -0700671#ifdef JUNKTEST
672 junk_bytes_with_probability(i_bptr, i_size, opt_jprob);
Lev Walkin1f12da42006-09-24 19:47:07 +0000673#endif
674
Lev Walkinfb35e082017-08-04 03:06:51 -0700675 switch(iform) {
676 case INP_BER:
677 rval = ber_decode(opt_codec_ctx, pduType,
678 (void **)&structure, i_bptr, i_size);
679 break;
680 case INP_OER:
Lev Walkin69033802017-08-25 12:15:58 -0700681#ifdef ASN_DISABLE_OER_SUPPORT
682 rval.code = RC_FAIL;
683 rval.consumed = 0;
684#else
Lev Walkinfb35e082017-08-04 03:06:51 -0700685 rval = oer_decode(opt_codec_ctx, pduType,
686 (void **)&structure, i_bptr, i_size);
Lev Walkin69033802017-08-25 12:15:58 -0700687#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700688 break;
689 case INP_XER:
690 rval = xer_decode(opt_codec_ctx, pduType,
691 (void **)&structure, i_bptr, i_size);
692 break;
693 case INP_PER:
Lev Walkin69033802017-08-25 12:15:58 -0700694#ifdef ASN_DISABLE_PER_SUPPORT
695 rval.code = RC_FAIL;
696 rval.consumed = 0;
697#else
Lev Walkinfb35e082017-08-04 03:06:51 -0700698 if(opt_nopad)
699 rval = uper_decode(opt_codec_ctx, pduType,
700 (void **)&structure, i_bptr, i_size, 0,
701 DynamicBuffer.unbits);
702 else
703 rval = uper_decode_complete(opt_codec_ctx, pduType,
704 (void **)&structure, i_bptr, i_size);
Lev Walkin69033802017-08-25 12:15:58 -0700705#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700706 switch(rval.code) {
707 case RC_OK:
708 /* Fall through */
709 case RC_FAIL:
710 if(opt_nopad) {
711 /* uper_decode() returns bits! */
712 /* Extra bits */
713 ecbits = rval.consumed % 8;
714 /* Convert into bytes! */
715 rval.consumed /= 8;
716 }
717 break;
718 case RC_WMORE:
719 /* PER does not support restartability */
720 ASN_STRUCT_FREE(*pduType, structure);
721 structure = 0;
722 rval.consumed = 0;
723 /* Continue accumulating data */
724 break;
725 }
726 break;
727 }
728 DEBUG("decode(%ld) consumed %ld+%db (%ld), code %d",
729 (long)DynamicBuffer.length,
730 (long)rval.consumed, ecbits, (long)i_size,
731 rval.code);
Lev Walkin22b54552004-10-28 13:22:54 +0000732
Lev Walkinfb35e082017-08-04 03:06:51 -0700733 if(DynamicBuffer.allocated == 0) {
734 /*
735 * Flush remainder into the intermediate buffer.
736 */
737 if(rval.code != RC_FAIL && rval.consumed < rd) {
738 add_bytes_to_buffer(fbuf + rval.consumed,
739 rd - rval.consumed);
740 buffer_shift_left(0, ecbits);
741 DynamicBuffer.bytes_shifted = rval.consumed;
742 rval.consumed = 0;
743 ecbits = 0;
744 }
745 }
Lev Walkin22b54552004-10-28 13:22:54 +0000746
Lev Walkinfb35e082017-08-04 03:06:51 -0700747 /*
748 * Adjust position inside the source buffer.
749 */
750 if(DynamicBuffer.allocated) {
751 DynamicBuffer.offset += rval.consumed;
752 DynamicBuffer.length -= rval.consumed;
753 } else {
754 DynamicBuffer.bytes_shifted += rval.consumed;
755 }
Lev Walkinbc691772006-09-17 11:02:53 +0000756
Lev Walkinfb35e082017-08-04 03:06:51 -0700757 switch(rval.code) {
758 case RC_OK:
759 if(ecbits) buffer_shift_left(0, ecbits);
760 DEBUG("RC_OK, finishing up with %ld+%d",
761 (long)rval.consumed, ecbits);
762 return structure;
763 case RC_WMORE:
764 DEBUG("RC_WMORE, continuing read=%ld, cons=%ld "
765 " with %ld..%ld-%ld..%ld",
766 (long)rd,
767 (long)rval.consumed,
768 (long)DynamicBuffer.offset,
769 (long)DynamicBuffer.length,
770 (long)DynamicBuffer.unbits,
771 (long)DynamicBuffer.allocated);
772 if(!rd) tolerate_eof--;
773 continue;
774 case RC_FAIL:
775 break;
776 }
777 break;
778 }
Lev Walkin22b54552004-10-28 13:22:54 +0000779
Lev Walkinfb35e082017-08-04 03:06:51 -0700780 DEBUG("Clean up partially decoded structure");
781 ASN_STRUCT_FREE(*pduType, structure);
Lev Walkin22b54552004-10-28 13:22:54 +0000782
Lev Walkinfb35e082017-08-04 03:06:51 -0700783 new_offset = DynamicBuffer.bytes_shifted + DynamicBuffer.offset;
Lev Walkinbc691772006-09-17 11:02:53 +0000784
Lev Walkinfb35e082017-08-04 03:06:51 -0700785 /*
786 * Print a message and return failure only if not EOF,
787 * unless this is our first PDU (empty file).
788 */
789 if(on_first_pdu
790 || DynamicBuffer.length
791 || new_offset - old_offset > ((iform == INP_XER)?sizeof("\r\n")-1:0)
792 ) {
Lev Walkin1f12da42006-09-24 19:47:07 +0000793
Lev Walkinfb35e082017-08-04 03:06:51 -0700794#ifdef JUNKTEST
795 /*
796 * Nothing's wrong with being unable to decode junk.
797 * Simulate EOF.
798 */
799 if(opt_jprob != 0.0) {
800 junk_failures++;
801 errno = 0;
802 return 0;
803 }
Lev Walkin1f12da42006-09-24 19:47:07 +0000804#endif
805
Lev Walkinfb35e082017-08-04 03:06:51 -0700806 DEBUG("ofp %d, no=%ld, oo=%ld, dbl=%ld",
807 on_first_pdu, (long)new_offset, (long)old_offset,
808 (long)DynamicBuffer.length);
809 fprintf(stderr, "%s: "
810 "Decode failed past byte %ld: %s\n",
811 name, (long)new_offset,
812 (rval.code == RC_WMORE)
813 ? "Unexpected end of input"
814 : "Input processing error");
815#ifndef ENOMSG
816#define ENOMSG EINVAL
Lev Walkin4bf96b92006-09-18 21:46:50 +0000817#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700818#ifndef EBADMSG
819#define EBADMSG EINVAL
Lev Walkin4bf96b92006-09-18 21:46:50 +0000820#endif
Lev Walkinfb35e082017-08-04 03:06:51 -0700821 errno = (rval.code == RC_WMORE) ? ENOMSG : EBADMSG;
822 } else {
823 /* Got EOF after a few successful PDUs */
824 errno = 0;
825 }
Lev Walkin22b54552004-10-28 13:22:54 +0000826
Lev Walkinfb35e082017-08-04 03:06:51 -0700827 return 0;
Lev Walkin22b54552004-10-28 13:22:54 +0000828}
829
Lev Walkin419f6752006-09-13 04:02:00 +0000830/* Dump the buffer out to the specified FILE */
831static int write_out(const void *buffer, size_t size, void *key) {
Lev Walkinfb35e082017-08-04 03:06:51 -0700832 FILE *fp = (FILE *)key;
833 return (fwrite(buffer, 1, size, fp) == size) ? 0 : -1;
Lev Walkin419f6752006-09-13 04:02:00 +0000834}
Lev Walkinc744a022006-09-15 18:33:25 +0000835
836static int argument_is_stdin(char *av[], int idx) {
Lev Walkinfb35e082017-08-04 03:06:51 -0700837 if(strcmp(av[idx], "-")) {
838 return 0; /* Certainly not <stdin> */
839 } else {
840 /* This might be <stdin>, unless `./program -- -` */
841 if(strcmp(av[-1], "--"))
842 return 1;
843 else
844 return 0;
845 }
Lev Walkinc744a022006-09-15 18:33:25 +0000846}
847
848static FILE *argument_to_file(char *av[], int idx) {
Lev Walkinfb35e082017-08-04 03:06:51 -0700849 return argument_is_stdin(av, idx) ? stdin : fopen(av[idx], "rb");
Lev Walkinc744a022006-09-15 18:33:25 +0000850}
851
852static char *argument_to_name(char *av[], int idx) {
Lev Walkinfb35e082017-08-04 03:06:51 -0700853 return argument_is_stdin(av, idx) ? "standard input" : av[idx];
Lev Walkinc744a022006-09-15 18:33:25 +0000854}
Lev Walkin1f12da42006-09-24 19:47:07 +0000855
Lev Walkinfb35e082017-08-04 03:06:51 -0700856#ifdef JUNKTEST
Lev Walkin1f12da42006-09-24 19:47:07 +0000857/*
858 * Fill bytes with some garbage with specified probability (more or less).
859 */
860static void
861junk_bytes_with_probability(uint8_t *buf, size_t size, double prob) {
Lev Walkinfb35e082017-08-04 03:06:51 -0700862 static int junkmode;
863 uint8_t *ptr;
864 uint8_t *end;
865 if(opt_jprob <= 0.0) return;
866 for(ptr = buf, end = ptr + size; ptr < end; ptr++) {
867 int byte = *ptr;
868 if(junkmode++ & 1) {
869 if((((double)random() / RAND_MAX) < prob))
870 byte = random() & 0xff;
871 } else {
872#define BPROB(b) ((((double)random() / RAND_MAX) < prob) ? b : 0)
873 byte ^= BPROB(0x80);
874 byte ^= BPROB(0x40);
875 byte ^= BPROB(0x20);
876 byte ^= BPROB(0x10);
877 byte ^= BPROB(0x08);
878 byte ^= BPROB(0x04);
879 byte ^= BPROB(0x02);
880 byte ^= BPROB(0x01);
881 }
882 if(byte != *ptr) {
883 DEBUG("Junk buf[%d] %02x -> %02x", ptr - buf, *ptr, byte);
884 *ptr = byte;
885 }
886 }
Lev Walkin1f12da42006-09-24 19:47:07 +0000887}
Lev Walkinfb35e082017-08-04 03:06:51 -0700888#endif /* JUNKTEST */
Lev Walkin1f12da42006-09-24 19:47:07 +0000889