Skip to content

Commit bc863e3

Browse files
committed
BNER support: Add -gen-BNER option
1 parent 848bf92 commit bc863e3

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

asn1c/asn1c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ main(int ac, char **av) {
123123
asn1_compiler_flags |= A1C_GEN_PER;
124124
} else if(strcmp(optarg, "en-OER") == 0) {
125125
asn1_compiler_flags |= A1C_GEN_OER;
126+
} else if(strcmp(optarg, "en-BNER") == 0) {
127+
asn1_compiler_flags |= A1C_GEN_BNER;
126128
} else if(strcmp(optarg, "en-example") == 0) {
127129
asn1_compiler_flags |= A1C_GEN_EXAMPLE;
128130
} else if(strcmp(optarg, "en-autotools") == 0) {

libasn1compiler/asn1c_C.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,10 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
14281428
OUT("asn_struct_free_f %s_free;\n", p);
14291429
OUT("asn_struct_print_f %s_print;\n", p);
14301430
OUT("asn_constr_check_f %s_constraint;\n", p);
1431+
if(arg->flags & A1C_GEN_BNER) {
1432+
OUT("bner_type_decoder_f %s_decode_bner;\n", p);
1433+
OUT("bner_type_encoder_f %s_encode_bner;\n", p);
1434+
}
14311435
OUT("ber_type_decoder_f %s_decode_ber;\n", p);
14321436
OUT("der_type_encoder_f %s_encode_der;\n", p);
14331437
OUT("xer_type_decoder_f %s_decode_xer;\n", p);

libasn1compiler/asn1c_fdeps.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ asn1c_read_file_dependencies(arg_t *arg, const char *datadir) {
124124
&& strcmp(p, "CODEC-PER:") == 0) {
125125
activate = 0;
126126
section = FDEP_CODEC_PER;
127+
} else if((arg->flags & A1C_GEN_BNER)
128+
&& strcmp(p, "CODEC-BNER:") == 0) {
129+
activate = 1;
130+
section = FDEP_CODEC_BNER;
127131
} else {
128132
section = FDEP_IGNORE;
129133
activate = 0;

libasn1compiler/asn1c_fdeps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ typedef struct {
77
int column;
88
} asn1c_dep_filename;
99

10-
1110
/*
1211
* Format:
1312
* <observed-name> [<dependent-name> ...]
@@ -29,6 +28,7 @@ typedef struct {
2928
FDEP_COMMON_FILES = (1 << 4), /* Section for mandatory dependencies */
3029
FDEP_CODEC_OER = (1 << 5), /* Use contents only if -gen-OER */
3130
FDEP_CODEC_PER = (1 << 6), /* Use contents only if -gen-PER */
31+
FDEP_CODEC_BNER = (1 << 7), /* Use contents only if -gen-BNER */
3232
} section; /* Some file refers to it */
3333

3434
/* Whether this chain is alive and has to be present in the output */

libasn1compiler/asn1c_save.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ asn1c__save_library_makefile(arg_t *arg, const asn1c_dep_chainset *deps,
145145
safe_fprintf(
146146
mkf,
147147
"\n"
148-
"ASN_MODULE_CFLAGS=%s%s",
148+
"ASN_MODULE_CFLAGS=%s%s%s",
149+
(arg->flags & A1C_GEN_BNER) ? "-DASN_ENABLE_BNER_SUPPORT " : "",
149150
(arg->flags & A1C_GEN_OER) ? "" : "-DASN_DISABLE_OER_SUPPORT ",
150151
(arg->flags & A1C_GEN_PER) ? "" : "-DASN_DISABLE_PER_SUPPORT ");
151152

libasn1compiler/asn1compiler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ enum asn1c_flags {
9292
* Generate top-level configure.ac and Makefile.am
9393
*/
9494
A1C_GEN_AUTOTOOLS_EXAMPLE = 0x200000,
95+
/*
96+
* -gen-BNER
97+
* Generate BACnet Encoding Rules support code
98+
*/
99+
A1C_GEN_BNER = 0x400000,
95100
};
96101

97102
/*

skeletons/file-dependencies

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ per_support.h per_support.c # PER parsing
6565
per_decoder.h per_decoder.c # PER decoding support
6666
per_encoder.h per_encoder.c # PER encoding support
6767
per_opentype.h per_opentype.c # PER "open type" handling
68+
bner_support.h bner_support.c # BNER tag support
69+
bner_decoder.h bner_decoder.c # BNER decoding support
70+
bner_encoder.h bner_encoder.c # BNER encoding support
6871

6972
CONVERTER: # THIS IS A SPECIAL SECTION
7073
converter-example.c # A default name for the example transcoder
@@ -87,3 +90,16 @@ constr_SEQUENCE.h constr_SEQUENCE_oer.c
8790
constr_SET_OF.h constr_SET_OF_oer.c
8891

8992
CODEC-PER: # THIS IS A SPECIAL SECTION
93+
94+
CODEC-BNER: # THIS IS A SPECIAL SECTION
95+
constr_CHOICE.h constr_CHOICE_bner.c
96+
constr_SEQUENCE.h constr_SEQUENCE_bner.c
97+
constr_SEQUENCE_OF.h constr_SEQUENCE_OF_bner.c constr_SET_OF.h asn_SEQUENCE_OF.h asn_SET_OF.h
98+
primitive_bner.h primitive_bner.c # BNER primative support
99+
BOOLEAN_bner.c BOOLEAN.h
100+
INTEGER_bner.c INTEGER.h
101+
NativeInteger_bner.c NativeInteger.h
102+
NativeReal_bner.c NativeReal.h REAL.h
103+
NULL_bner.c NULL.h
104+
OCTET_STRING_bner.c OCTET_STRING.h
105+
REAL_bner.c REAL.h

0 commit comments

Comments
 (0)