Skip to content

Commit

Permalink
BNER: Add weak function stubs for BNER fixed encoded PDUs
Browse files Browse the repository at this point in the history
  • Loading branch information
ringlej committed Dec 1, 2017
1 parent 4b6148e commit 19e3558
Show file tree
Hide file tree
Showing 6 changed files with 979 additions and 15 deletions.
32 changes: 31 additions & 1 deletion libasn1compiler/asn1c_C.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ enum etd_spec {
};
static int emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_count, int all_tags_count, int elements_count, enum etd_spec);

static const char* bner_fixed_encoding_pdus[] = {
"BACnetPDU",
"BACnet-Confirmed-Request-PDU",
"BACnet-Unconfirmed-Request-PDU",
"BACnet-SimpleACK-PDU",
"BACnet-ComplexACK-PDU",
"BACnet-SegmentACK-PDU",
"BACnet-Error-PDU",
"BACnet-Reject-PDU",
"BACnet-Abort-PDU",
"BACnet-Confirmed-Service-Request",
"BACnet-Unconfirmed-Service-Request",
"BACnet-Confirmed-Service-ACK",
"BACnet-Error",
0
};

static int is_bner_fixed_encoding_pdu(const char *pdu_type_name) {
for (int i = 0; bner_fixed_encoding_pdus[i]; ++i) {
if(!strcmp(bner_fixed_encoding_pdus[i], pdu_type_name))
return 1;
}
return 0;
}

#define C99_MODE (!(arg->flags & A1C_NO_C99))
#define UNNAMED_UNIONS (arg->flags & A1C_UNNAMED_UNIONS)
#define HIDE_INNER_DEFS (arg->embed && !(arg->flags & A1C_ALL_DEFS_GLOBAL))
Expand Down Expand Up @@ -2980,7 +3005,12 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
if (!p2)
p2 = strdup(p);

OUT("&asn_OP_%s,\n", p2);
if(arg->flags & A1C_GEN_BNER
&& is_bner_fixed_encoding_pdu(expr->Identifier)) {
OUT("&asn_OP_%s,\n", expr_id);
} else {
OUT("&asn_OP_%s,\n", p2);
}

if(tags_count) {
OUT("asn_DEF_%s_tags_%d,\n",
Expand Down
29 changes: 15 additions & 14 deletions skeletons/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,21 @@ check_PROGRAMS = \
check-converter_c89_example

# BNER Support
libasn1cskeletons_la_SOURCES += \
bner_decoder.c bner_decoder.h \
bner_encoder.c bner_encoder.h \
bner_support.c bner_support.h \
constr_CHOICE_bner.c \
constr_SEQUENCE_bner.c \
constr_SEQUENCE_OF_bner.c \
ANY_bner.c \
BOOLEAN_bner.c \
INTEGER_bner.c \
NativeInteger_bner.c \
NativeReal_bner.c \
NULL_bner.c \
OCTET_STRING_bner.c \
libasn1cskeletons_la_SOURCES += \
bner_decoder.c bner_decoder.h \
bner_encoder.c bner_encoder.h \
bner_fixed_stubs.c bner_fixed_stubs.h \
bner_support.c bner_support.h \
constr_CHOICE_bner.c \
constr_SEQUENCE_bner.c \
constr_SEQUENCE_OF_bner.c \
ANY_bner.c \
BOOLEAN_bner.c \
INTEGER_bner.c \
NativeInteger_bner.c \
NativeReal_bner.c \
NULL_bner.c \
OCTET_STRING_bner.c \
REAL_bner.c

LDADD = -lm
Expand Down
Loading

0 comments on commit 19e3558

Please sign in to comment.