RSPRO: don't use "default 1" for protocol version

I suspect there may be some bugs in the handling of DEFAULT values
in asn1c (or maybe I don't understand them fully?), so let's simply
make the version field a normal ASN.1 field.

Change-Id: I08077e715a901dfa5193855be7040d550f6fc2e8
laforge/bankd-fsm-mistake
Harald Welte 4 years ago
parent 52cc7db6ed
commit 293478cf76
  1. 2
      asn1/RSPRO.asn
  2. 2
      include/osmocom/rspro/RsproPDU.h
  3. 22
      src/rspro/RsproPDU.c

@ -270,7 +270,7 @@ RsproPDUchoice ::= CHOICE {
}
RsproPDU ::= SEQUENCE {
version [0] INTEGER(0..32) DEFAULT 1,
version [0] INTEGER(0..32),
tag [1] OperationTag,
msg [2] RsproPDUchoice
}

@ -22,7 +22,7 @@ extern "C" {
/* RsproPDU */
typedef struct RsproPDU {
long *version /* DEFAULT 1 */;
long version;
OperationTag_t tag;
RsproPDUchoice_t msg;

@ -31,32 +31,14 @@ memb_version_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
}
}
static int asn_DFL_2_set_1(int set_value, void **sptr) {
long *st = *sptr;
if(!st) {
if(!set_value) return -1; /* Not a default value */
st = (*sptr = CALLOC(1, sizeof(*st)));
if(!st) return -1;
}
if(set_value) {
/* Install default value 1 */
*st = 1l;
return 0;
} else {
/* Test default value 1 */
return (*st == 1);
}
}
static asn_TYPE_member_t asn_MBR_RsproPDU_1[] = {
{ ATF_POINTER, 1, offsetof(struct RsproPDU, version),
{ ATF_NOFLAGS, 0, offsetof(struct RsproPDU, version),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_NativeInteger,
memb_version_constraint_1,
0, /* PER is not compiled, use -gen-PER */
asn_DFL_2_set_1, /* DEFAULT 1 */
0,
"version"
},
{ ATF_NOFLAGS, 0, offsetof(struct RsproPDU, tag),

Loading…
Cancel
Save