Skip to content

Commit

Permalink
upgrade: PER related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vlm committed Nov 26, 2005
1 parent 7085305 commit 59b176e
Show file tree
Hide file tree
Showing 119 changed files with 14,517 additions and 2,304 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

0.9.20: 2005-Nov-07
0.9.20: 2005-Nov-13

* SET OF CHOICE, SEQUENCE OF CHOICE and a certain named S/O types
are represented differently in XER. THIS IS AN ICOMPATIBLE CHANGE.
(Test case 70) (Severity: low; Security impact: low)
* PER implementation has started
* asn1c: Removed -ftypes88 command line option.

0.9.19: 2005-Oct-06

Expand Down
7 changes: 1 addition & 6 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
1. MAJOR:

1.1 Support for PER encoding. Requires advanced subtype constraints support,
which is already completed.
1.1 Support for PER encoding. PER decoding is already supported.

1.2 Support for Information Object Classes.
Status: Support for parsing IOCs is mostly present.
Expand All @@ -12,7 +11,3 @@ which is already completed.

2.1 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types.
Requires something from 1.2 (Information Object Classes).

3. MINOR:

3.1 Support for DEFAULT encoding and decoding, at least in INTEGER/ENUMERATED types.
15 changes: 9 additions & 6 deletions asn1c/asn1c.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ asn1c \- ASN.1 Compiler
.SH SYNOPSIS
asn1c [\fB\-E\fR [\fB-F\fR] | \fB\-P\fR | \fB\-R\fR]
[\fB\-S\fR\fIdir\fR] [\fB-X\fR]
[\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR...] [\fB\-p\fR\fIrint-\fR...]
[\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR] [\fB\-gen-\fR\fIoption\fR] [\fB\-print-\fR\fIoption\fR]
\fIinfile\fR...
.SH DESCRIPTION
asn1c compiles the ASN.1 specifications into the set of
Expand All @@ -25,7 +25,11 @@ and other encoding standards.
.br
\fB\-fall-defs-global \-fbless-SIZE \-fcompound-names \-findirect-choice
.BI "\-fknown-extern-type="<name>
\fB\-fnative-types \-fno-constraints \-fno-include-deps \-funnamed-unions \-fskeletons-copy \-ftypes88\fR
\fB\-fnative-types \-fno-constraints \-fno-include-deps \-funnamed-unions \-fskeletons-copy
.TP
\fICodecs Generation Options\fR
.br
.B \-gen-PER
.TP
\fIOutput Options\fR
.br
Expand Down Expand Up @@ -117,11 +121,10 @@ Enable unnamed unions in the definitions of target language's structures.
.TP
.B \-fskeletons-copy
Copy support files (skeletons) rather than symlink them.
.SH CODECS GENERATION OPTIONS
.TP
.B \-ftypes88
Pretend to support only ASN.1:1988 embedded types. Certain reserved words,
such as UniversalString and BMPString, become ordinary type references
and may be redefined by the specification.
.B \-gen-PER
Generate Packed Encoding Rules (PER) support code.
.SH OUTPUT OPTIONS
.TP
.B \-print-constraints
Expand Down
30 changes: 24 additions & 6 deletions asn1c/asn1c.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ main(int ac, char **av) {
/*
* Process command-line options.
*/
while((ch = getopt(ac, av, "EFf:hLPp:RS:vW:X")) != -1)
while((ch = getopt(ac, av, "EFf:g:hLPp:RS:vW:X")) != -1)
switch(ch) {
case 'E':
print_arg__print_out = 1;
Expand Down Expand Up @@ -95,21 +95,35 @@ main(int ac, char **av) {
asn1_compiler_flags |= A1C_UNNAMED_UNIONS;
} else if(strcmp(optarg, "skeletons-copy") == 0) {
asn1_compiler_flags |= A1C_SKELETONS_COPY;
} else if(strcmp(optarg, "types88") == 0) {
asn1_parser_flags |= A1P_TYPES_RESTRICT_TO_1988;
} else {
fprintf(stderr, "-f%s: Invalid argument\n", optarg);
exit(EX_USAGE);
}
break;
case 'g':
if(strcmp(optarg, "en-PER") == 0) {
asn1_compiler_flags |= A1C_GEN_PER;
} else {
fprintf(stderr, "-g%s: Invalid argument\n", optarg);
exit(EX_USAGE);
}
break;
case 'h':
usage(av[0]);
case 'P':
asn1_compiler_flags |= A1C_PRINT_COMPILED;
asn1_compiler_flags &= ~A1C_NO_C99;
break;
case 'p':
if(strcmp(optarg, "rint-constraints") == 0) {
if(strncmp(optarg, "du=", 3) == 0) {
char *pduname = optarg + 3;
if(strcmp(pduname, "auto")) {
fprintf(stderr, "-pdu=%s: expected -pdu=auto\n",
pduname);
exit(EX_USAGE);
}
asn1_compiler_flags |= A1C_PDU_AUTO;
} else if(strcmp(optarg, "rint-constraints") == 0) {
asn1_printer_flags |= APF_DEBUG_CONSTRAINTS;
} else if(strcmp(optarg, "rint-lines") == 0) {
asn1_printer_flags |= APF_LINE_COMMENTS;
Expand Down Expand Up @@ -250,7 +264,8 @@ main(int ac, char **av) {
/*
* Make sure the skeleton directory is out there.
*/
if(skeletons_dir == NULL) {
if((asn1_compiler_flags & A1C_OMIT_SUPPORT_CODE) == 0
&& skeletons_dir == NULL) {
struct stat sb;
skeletons_dir = DATADIR;
if((av[-optind][0] == '.' || av[-optind][1] == '/')
Expand Down Expand Up @@ -326,7 +341,10 @@ usage(const char *av0) {
" -fno-include-deps Do not generate courtesy #includes for dependencies\n"
" -funnamed-unions Enable unnamed unions in structures\n"
" -fskeletons-copy Force copying the support files\n"
" -ftypes88 Pretend to support only ASN.1:1988 embedded types\n"
"\n"

" -gen-PER Generate PER support code\n"
" -pdu=auto Generate PDU table (discover PDUs automatically)\n"
"\n"

" -print-constraints Explain subtype constraints (debug)\n"
Expand Down
4 changes: 2 additions & 2 deletions asn1c/tests/check-25.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ check(int is_ok, uint8_t *buf, int size, size_t consumed) {
assert(rval.code == RC_OK);
assert(rval.consumed == consumed);

assert(strcmp(t.e->buf, "xyz") == 0);
assert(strcmp(t.f->buf, "love_it") == 0);
assert(strcmp((char *)t.e->buf, "xyz") == 0);
assert(strcmp((char *)t.f->buf, "love_it") == 0);

assert(t.g->size == 2);
assert(t.g->bits_unused == 2);
Expand Down
8 changes: 6 additions & 2 deletions asn1c/tests/check-70.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
b = buf + buf_offset;
bend = b + size;
fprintf(stderr, "=> [");
for(; b < bend; b++)
fprintf(stderr, "%c", *b);
for(; b < bend; b++) {
if(*b >= 32 && *b < 127 && *b != '%')
fprintf(stderr, "%c", *b);
else
fprintf(stderr, "%%02x", *b);
}
fprintf(stderr, "]:%ld\n", (long)size);
buf_offset += size;
return 0;
Expand Down
Loading

0 comments on commit 59b176e

Please sign in to comment.