mirror of https://gerrit.osmocom.org/asn1c
XER support
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@365 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
parent
cbebb81cd4
commit
39ba4c41d5
|
@ -48,7 +48,8 @@ static void
|
|||
check(int is_ok, uint8_t *buf, int size, size_t consumed) {
|
||||
T1_t t, *tp;
|
||||
ber_dec_rval_t rval;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
tp = memset(&t, 0, sizeof(t));
|
||||
|
@ -104,8 +105,12 @@ check(int is_ok, uint8_t *buf, int size, size_t consumed) {
|
|||
assert(buf1[i] == buf2[i]);
|
||||
}
|
||||
|
||||
fprintf(stderr, "=== PRINT ===\n");
|
||||
asn_fprint(stderr, &asn1_DEF_T1, tp);
|
||||
fprintf(stderr, "=== asn_fprint() ===\n");
|
||||
ret = asn_fprint(stderr, &asn1_DEF_T1, tp);
|
||||
assert(ret == 0);
|
||||
fprintf(stderr, "=== xer_fprint() ===\n");
|
||||
ret = xer_fprint(stderr, &asn1_DEF_T1, tp);
|
||||
assert(ret == 0);
|
||||
fprintf(stderr, "=== EOF ===\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -136,6 +136,7 @@ check(int is_ok, uint8_t *buf, int size, size_t consumed) {
|
|||
assert(buf_pos == sizeof(buf1_reconstr));
|
||||
|
||||
asn_fprint(stderr, &asn1_DEF_Forest, &t);
|
||||
xer_fprint(stderr, &asn1_DEF_Forest, &t);
|
||||
|
||||
asn1_DEF_Forest.free_struct(&asn1_DEF_Forest, &t, 1);
|
||||
}
|
||||
|
|
|
@ -131,6 +131,9 @@ check(T_t *tp, uint8_t *buf, int size, size_t consumed) {
|
|||
assert(strcmp(tp->a.buf, "ns") == 0);
|
||||
assert(strcmp(tp->b.choice.b1.buf, "z") == 0
|
||||
&& strcmp(tp->b.choice.b2.buf, "z") == 0);
|
||||
|
||||
asn_fprint(stderr, &asn1_DEF_T, tp);
|
||||
xer_fprint(stderr, &asn1_DEF_T, tp);
|
||||
}
|
||||
|
||||
size_t buf_pos;
|
||||
|
@ -157,7 +160,7 @@ buf_fill(const void *buffer, size_t size, void *app_key) {
|
|||
|
||||
static void
|
||||
compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
int i;
|
||||
|
||||
buf_size = cmp_buf_size + 100;
|
||||
|
@ -268,12 +271,10 @@ main(int ac, char **av) {
|
|||
|
||||
check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1));
|
||||
compare(&t, buf1_reconstr, sizeof(buf1_reconstr));
|
||||
asn_fprint(stderr, &asn1_DEF_T, &t);
|
||||
asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1);
|
||||
|
||||
check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2));
|
||||
compare(&t, buf2_reconstr, sizeof(buf2_reconstr));
|
||||
asn_fprint(stderr, &asn1_DEF_T, &t);
|
||||
asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1);
|
||||
|
||||
/* Split the buffer in parts and check decoder restartability */
|
||||
|
|
|
@ -132,10 +132,11 @@ uint8_t buf2_reconstr[] = {
|
|||
static void
|
||||
check(T_t *tp, uint8_t *buf, int size, size_t consumed) {
|
||||
ber_dec_rval_t rval;
|
||||
int ret;
|
||||
|
||||
tp = memset(tp, 0, sizeof(*tp));
|
||||
|
||||
fprintf(stderr, "Buf %p (%d)\n", buf, size);
|
||||
fprintf(stderr, "Buf %p (%d)\n", (int)buf, (int)size);
|
||||
rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size);
|
||||
fprintf(stderr, "Returned code %d, consumed %d\n",
|
||||
(int)rval.code, (int)rval.consumed);
|
||||
|
@ -143,6 +144,14 @@ check(T_t *tp, uint8_t *buf, int size, size_t consumed) {
|
|||
assert(rval.code == RC_OK);
|
||||
assert(rval.consumed == consumed);
|
||||
|
||||
fprintf(stderr, "=== asn_fprint() ===\n");
|
||||
ret = asn_fprint(stderr, &asn1_DEF_T, tp);
|
||||
assert(ret == 0);
|
||||
fprintf(stderr, "=== xer_fprint() ===\n");
|
||||
ret = xer_fprint(stderr, &asn1_DEF_T, tp);
|
||||
fprintf(stderr, "=== END ===\n");
|
||||
assert(ret == 0);
|
||||
|
||||
/*
|
||||
assert(tp->string.size == 128);
|
||||
assert(strncmp(tp->string.buf, "zz") == 0);
|
||||
|
@ -153,32 +162,33 @@ check(T_t *tp, uint8_t *buf, int size, size_t consumed) {
|
|||
|
||||
size_t buf_pos;
|
||||
size_t buf_size;
|
||||
uint8_t *buf;
|
||||
uint8_t *buffer;
|
||||
|
||||
static int
|
||||
buf_fill(const void *buffer, size_t size, void *app_key) {
|
||||
buf_fill(const void *bufp, size_t size, void *app_key) {
|
||||
|
||||
(void)app_key; /* Unused argument */
|
||||
|
||||
if(buf_pos + size > buf_size) {
|
||||
fprintf(stderr, "%d + %d > %d\n", buf_pos, (int)size, buf_size);
|
||||
fprintf(stderr, "%d + %d > %d\n",
|
||||
(int)buf_pos, (int)size, (int)buf_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(buf + buf_pos, buffer, size);
|
||||
memcpy(buffer + buf_pos, bufp, size);
|
||||
buf_pos += size;
|
||||
fprintf(stderr, " written %d (%d)\n", (int)size, buf_pos);
|
||||
fprintf(stderr, " written %d (%d)\n", (int)size, (int)buf_pos);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
int i;
|
||||
|
||||
buf_size = cmp_buf_size + 100;
|
||||
buf = alloca(buf_size);
|
||||
buffer = alloca(buf_size);
|
||||
buf_pos = 0;
|
||||
|
||||
/*
|
||||
|
@ -187,19 +197,19 @@ compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
|
|||
erval = der_encode(&asn1_DEF_T, tp, buf_fill, 0);
|
||||
assert(erval.encoded != -1);
|
||||
if(erval.encoded != cmp_buf_size) {
|
||||
printf("%d != %d\n", erval.encoded, cmp_buf_size);
|
||||
printf("%d != %d\n", (int)erval.encoded, (int)cmp_buf_size);
|
||||
}
|
||||
assert(erval.encoded == cmp_buf_size);
|
||||
for(i = 0; i < cmp_buf_size; i++) {
|
||||
if(buf[i] != cmp_buf[i]) {
|
||||
if(buffer[i] != cmp_buf[i]) {
|
||||
fprintf(stderr, "Recreated buffer content mismatch:\n");
|
||||
fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n",
|
||||
i,
|
||||
buf[i], cmp_buf[i],
|
||||
buf[i], cmp_buf[i]
|
||||
buffer[i], cmp_buf[i],
|
||||
buffer[i], cmp_buf[i]
|
||||
);
|
||||
}
|
||||
assert(buf[i] == cmp_buf[i]);
|
||||
assert(buffer[i] == cmp_buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,7 +240,7 @@ partial_read(uint8_t *buf, size_t size) {
|
|||
size_t size3 = size - size1 - size2;
|
||||
|
||||
fprintf(stderr, "\n%d:{%d, %d, %d}...\n",
|
||||
size, size1, size2, size3);
|
||||
(int)size, (int)size1, (int)size2, (int)size3);
|
||||
|
||||
memset(buf1, 0, size);
|
||||
memset(buf2, 0, size);
|
||||
|
@ -241,7 +251,7 @@ partial_read(uint8_t *buf, size_t size) {
|
|||
|
||||
tp = memset(&t, 0, sizeof(t));
|
||||
|
||||
fprintf(stderr, "=> Chunk 1 (%d):\n", size1);
|
||||
fprintf(stderr, "=> Chunk 1 (%d):\n", (int)size1);
|
||||
rval = ber_decode(&asn1_DEF_T, (void **)&tp,
|
||||
buf1, size1);
|
||||
assert(rval.code == RC_WMORE);
|
||||
|
@ -253,7 +263,7 @@ partial_read(uint8_t *buf, size_t size) {
|
|||
size2 += leftover;
|
||||
}
|
||||
|
||||
fprintf(stderr, "=> Chunk 2 (%d):\n", size2);
|
||||
fprintf(stderr, "=> Chunk 2 (%d):\n", (int)size2);
|
||||
rval = ber_decode(&asn1_DEF_T, (void **)&tp,
|
||||
buf2, size2);
|
||||
assert(rval.code == RC_WMORE);
|
||||
|
@ -265,7 +275,7 @@ partial_read(uint8_t *buf, size_t size) {
|
|||
size3 += leftover;
|
||||
}
|
||||
|
||||
fprintf(stderr, "=> Chunk 3 (%d):\n", size3);
|
||||
fprintf(stderr, "=> Chunk 3 (%d):\n", (int)size3);
|
||||
rval = ber_decode(&asn1_DEF_T, (void **)&tp,
|
||||
buf3, size3);
|
||||
assert(rval.code == RC_OK);
|
||||
|
@ -283,31 +293,26 @@ main() {
|
|||
/* Check exact buf0 */
|
||||
check(&t, buf0, sizeof(buf0), sizeof(buf0));
|
||||
compare(&t, buf0_reconstr, sizeof(buf0_reconstr));
|
||||
asn_fprint(stderr, &asn1_DEF_T, &t);
|
||||
asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1);
|
||||
|
||||
/* Check exact buf1 */
|
||||
check(&t, buf1, sizeof(buf1), sizeof(buf1));
|
||||
compare(&t, buf1_reconstr, sizeof(buf1_reconstr));
|
||||
asn_fprint(stderr, &asn1_DEF_T, &t);
|
||||
asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1);
|
||||
|
||||
/* Check slightly more than buf1 */
|
||||
check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1));
|
||||
compare(&t, buf1_reconstr, sizeof(buf1_reconstr));
|
||||
asn_fprint(stderr, &asn1_DEF_T, &t);
|
||||
asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1);
|
||||
|
||||
/* Check exact buf2 */
|
||||
check(&t, buf2, sizeof(buf2), sizeof(buf2));
|
||||
compare(&t, buf2_reconstr, sizeof(buf2_reconstr));
|
||||
asn_fprint(stderr, &asn1_DEF_T, &t);
|
||||
asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1);
|
||||
|
||||
/* Check slightly more than buf2 */
|
||||
check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2));
|
||||
compare(&t, buf2_reconstr, sizeof(buf2_reconstr));
|
||||
asn_fprint(stderr, &asn1_DEF_T, &t);
|
||||
asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1);
|
||||
|
||||
/* Split the buffer in parts and check decoder restartability */
|
||||
|
|
|
@ -29,7 +29,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
|
|||
|
||||
static int
|
||||
save_object(void *bs, asn1_TYPE_descriptor_t *td) {
|
||||
der_enc_rval_t rval; /* Return value */
|
||||
asn_enc_rval_t rval; /* Return value */
|
||||
int i;
|
||||
|
||||
rval = der_encode(td, bs, _buf_writer, 0);
|
||||
|
@ -44,6 +44,7 @@ save_object(void *bs, asn1_TYPE_descriptor_t *td) {
|
|||
buf[buf_offset++] = 123; /* Finalize with garbage */
|
||||
|
||||
asn_fprint(stderr, td, bs);
|
||||
xer_fprint(stderr, td, bs);
|
||||
|
||||
printf("OUT: [");
|
||||
for(i = 0; i < buf_offset; i++)
|
||||
|
@ -63,6 +64,7 @@ load_object(void *bs, asn1_TYPE_descriptor_t *td) {
|
|||
assert(rval.code == RC_OK);
|
||||
|
||||
asn_fprint(stderr, td, bs);
|
||||
xer_fprint(stderr, td, bs);
|
||||
|
||||
return (rval.code == RC_OK)?0:-1;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ static int asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of);
|
|||
static int _print_tag(arg_t *arg, struct asn1p_type_tag_s *tag_p);
|
||||
static int check_if_extensible(asn1p_expr_t *expr);
|
||||
static int expr_better_indirect(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int expr_as_xmlvaluelist(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int expr_elements_count(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int emit_member_table(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count);
|
||||
|
@ -156,7 +157,6 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
|
|||
asn1p_expr_t *expr = arg->expr;
|
||||
asn1p_expr_t *v;
|
||||
int elements; /* Number of elements */
|
||||
int comp_mode = 0; /* {root,ext=1,root,root,...} */
|
||||
int ext_start = -1;
|
||||
int ext_stop = -1;
|
||||
tag2el_t *tag2el = NULL;
|
||||
|
@ -183,22 +183,28 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
|
|||
/*
|
||||
* Print out the table according to which the parsing is performed.
|
||||
*/
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static asn1_TYPE_member_t asn1_MBR_%s[] = {\n", p);
|
||||
if(expr_elements_count(arg, expr)) {
|
||||
int comp_mode = 0; /* {root,ext=1,root,root,...} */
|
||||
|
||||
elements = 0;
|
||||
INDENTED(TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if((++comp_mode) == 1)
|
||||
ext_start = elements - 1;
|
||||
else
|
||||
ext_stop = elements - 1;
|
||||
continue;
|
||||
}
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
});
|
||||
OUT("};\n");
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static asn1_TYPE_member_t asn1_MBR_%s[] = {\n", p);
|
||||
|
||||
elements = 0;
|
||||
INDENTED(TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if((++comp_mode) == 1)
|
||||
ext_start = elements - 1;
|
||||
else
|
||||
ext_stop = elements - 1;
|
||||
continue;
|
||||
}
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
});
|
||||
OUT("};\n");
|
||||
} else {
|
||||
elements = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out asn1_DEF_<type>_[all_]tags[] vectors.
|
||||
|
@ -307,7 +313,6 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
|
|||
asn1p_expr_t *expr = arg->expr;
|
||||
asn1p_expr_t *v;
|
||||
int elements;
|
||||
int comp_mode = 0; /* {root,ext=1,root,root,...} */
|
||||
tag2el_t *tag2el = NULL;
|
||||
int tag2el_count = 0;
|
||||
int tags_count;
|
||||
|
@ -332,22 +337,28 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
|
|||
/*
|
||||
* Print out the table according to which the parsing is performed.
|
||||
*/
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static asn1_TYPE_member_t asn1_MBR_%s[] = {\n", p);
|
||||
if(expr_elements_count(arg, expr)) {
|
||||
int comp_mode = 0; /* {root,ext=1,root,root,...} */
|
||||
|
||||
elements = 0;
|
||||
INDENTED(TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if(comp_mode < 3) comp_mode++;
|
||||
} else {
|
||||
if(comp_mode == 1
|
||||
|| expr_better_indirect(arg, v))
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
}
|
||||
});
|
||||
OUT("};\n");
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static asn1_TYPE_member_t asn1_MBR_%s[] = {\n", p);
|
||||
|
||||
elements = 0;
|
||||
INDENTED(TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if(comp_mode < 3) comp_mode++;
|
||||
} else {
|
||||
if(comp_mode == 1
|
||||
|| expr_better_indirect(arg, v))
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
}
|
||||
});
|
||||
OUT("};\n");
|
||||
} else {
|
||||
elements = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out asn1_DEF_<type>_[all_]tags[] vectors.
|
||||
|
@ -443,12 +454,15 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
|
|||
tmp.expr = &tmp_memb;
|
||||
tmp_memb = *memb;
|
||||
tmp_memb._anonymous_type = 1;
|
||||
tmp_memb.Identifier = strdup(
|
||||
asn1c_make_identifier(0,
|
||||
expr->Identifier, "member", 0));
|
||||
assert(tmp_memb.Identifier);
|
||||
if(tmp_memb.Identifier == 0) {
|
||||
tmp_memb.Identifier = strdup(
|
||||
asn1c_make_identifier(0,
|
||||
expr->Identifier, "member", 0));
|
||||
assert(tmp_memb.Identifier);
|
||||
}
|
||||
tmp.default_cb(&tmp);
|
||||
free(tmp_memb.Identifier);
|
||||
if(tmp_memb.Identifier != memb->Identifier)
|
||||
free(tmp_memb.Identifier);
|
||||
arg->embed--;
|
||||
assert(arg->target->target == OT_TYPE_DECLS);
|
||||
} else {
|
||||
|
@ -496,11 +510,17 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
|
|||
*/
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static asn1_TYPE_member_t asn1_MBR_%s[] = {\n", p);
|
||||
|
||||
INDENTED(
|
||||
INDENT(+1);
|
||||
v = TQ_FIRST(&(expr->members));
|
||||
if(!v->Identifier) {
|
||||
v->Identifier = strdup("member");
|
||||
assert(v->Identifier);
|
||||
}
|
||||
v->_anonymous_type = 1;
|
||||
arg->embed++;
|
||||
emit_member_table(arg, v);
|
||||
);
|
||||
arg->embed--;
|
||||
INDENT(-1);
|
||||
OUT("};\n");
|
||||
|
||||
/*
|
||||
|
@ -513,6 +533,10 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
|
|||
INDENTED(
|
||||
OUT("sizeof(struct %s),\n", p);
|
||||
OUT("offsetof(struct %s, _ber_dec_ctx),\n", p);
|
||||
if(expr_as_xmlvaluelist(arg, v))
|
||||
OUT("1,\t/* XER encoding is XMLValueList */\n");
|
||||
else
|
||||
OUT("0,\t/* XER encoding is XMLDelimitedItemList */\n");
|
||||
);
|
||||
OUT("};\n");
|
||||
|
||||
|
@ -589,7 +613,6 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
|
|||
asn1p_expr_t *expr = arg->expr;
|
||||
asn1p_expr_t *v;
|
||||
int elements; /* Number of elements */
|
||||
int comp_mode = 0; /* {root,ext=1,root,root,...} */
|
||||
tag2el_t *tag2el = NULL;
|
||||
int tag2el_count = 0;
|
||||
int tags_count;
|
||||
|
@ -614,22 +637,28 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
|
|||
/*
|
||||
* Print out the table according to which the parsing is performed.
|
||||
*/
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static asn1_TYPE_member_t asn1_MBR_%s[] = {\n", p);
|
||||
if(expr_elements_count(arg, expr)) {
|
||||
int comp_mode = 0; /* {root,ext=1,root,root,...} */
|
||||
|
||||
elements = 0;
|
||||
INDENTED(TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if(comp_mode < 3) comp_mode++;
|
||||
} else {
|
||||
if(comp_mode == 1
|
||||
|| expr_better_indirect(arg, v))
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
}
|
||||
});
|
||||
OUT("};\n");
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static asn1_TYPE_member_t asn1_MBR_%s[] = {\n", p);
|
||||
|
||||
elements = 0;
|
||||
INDENTED(TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if(comp_mode < 3) comp_mode++;
|
||||
} else {
|
||||
if(comp_mode == 1
|
||||
|| expr_better_indirect(arg, v))
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
}
|
||||
});
|
||||
OUT("};\n");
|
||||
} else {
|
||||
elements = 0;
|
||||
}
|
||||
|
||||
|
||||
if(arg->embed) {
|
||||
|
@ -683,7 +712,7 @@ asn1c_lang_C_type_REFERENCE(arg_t *arg) {
|
|||
arg_t tmp;
|
||||
int ret;
|
||||
|
||||
extract = asn1f_class_access_ex(arg->asn, arg->mod,
|
||||
extract = asn1f_class_access_ex(arg->asn, arg->expr->module,
|
||||
arg->expr, ref);
|
||||
if(extract == NULL)
|
||||
return -1;
|
||||
|
@ -808,12 +837,14 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
|
|||
OUT("%s_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {\n", p);
|
||||
INDENT(+1);
|
||||
{
|
||||
asn1p_expr_t *terminal = asn1f_find_terminal_type_ex(arg->asn, arg->mod, expr);
|
||||
asn1p_expr_t *terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
char *type_name = asn1c_type_name(arg, expr, TNF_SAFE);
|
||||
OUT("td->ber_decoder = asn1_DEF_%s.ber_decoder;\n", type_name);
|
||||
OUT("td->der_encoder = asn1_DEF_%s.der_encoder;\n", type_name);
|
||||
OUT("td->free_struct = asn1_DEF_%s.free_struct;\n", type_name);
|
||||
OUT("td->print_struct = asn1_DEF_%s.print_struct;\n", type_name);
|
||||
OUT("td->ber_decoder = asn1_DEF_%s.ber_decoder;\n", type_name);
|
||||
OUT("td->der_encoder = asn1_DEF_%s.der_encoder;\n", type_name);
|
||||
OUT("td->xer_decoder = asn1_DEF_%s.xer_decoder;\n", type_name);
|
||||
OUT("td->xer_encoder = asn1_DEF_%s.xer_encoder;\n", type_name);
|
||||
if(!terminal && !tags_count) {
|
||||
OUT("/* The next four lines are here because of -fknown-extern-type */\n");
|
||||
OUT("td->tags = asn1_DEF_%s.tags;\n", type_name);
|
||||
|
@ -832,24 +863,12 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
|
|||
OUT("\n");
|
||||
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("ber_dec_rval_t\n");
|
||||
OUT("%s_decode_ber(asn1_TYPE_descriptor_t *td,\n", p);
|
||||
OUT("void\n");
|
||||
OUT("%s_free(asn1_TYPE_descriptor_t *td,\n", p);
|
||||
INDENTED(
|
||||
OUT("\tvoid **structure, void *bufptr, size_t size, int tag_mode) {\n");
|
||||
OUT("\tvoid *struct_ptr, int contents_only) {\n");
|
||||
OUT("%s_inherit_TYPE_descriptor(td);\n", p);
|
||||
OUT("return td->ber_decoder(td, structure, bufptr, size, tag_mode);\n");
|
||||
);
|
||||
OUT("}\n");
|
||||
OUT("\n");
|
||||
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("der_enc_rval_t\n");
|
||||
OUT("%s_encode_der(asn1_TYPE_descriptor_t *td,\n", p);
|
||||
INDENTED(
|
||||
OUT("\tvoid *structure, int tag_mode, ber_tlv_tag_t tag,\n");
|
||||
OUT("\tasn_app_consume_bytes_f *cb, void *app_key) {\n");
|
||||
OUT("%s_inherit_TYPE_descriptor(td);\n", p);
|
||||
OUT("return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);\n");
|
||||
OUT("td->free_struct(td, struct_ptr, contents_only);\n");
|
||||
);
|
||||
OUT("}\n");
|
||||
OUT("\n");
|
||||
|
@ -866,12 +885,36 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
|
|||
OUT("\n");
|
||||
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("void\n");
|
||||
OUT("%s_free(asn1_TYPE_descriptor_t *td,\n", p);
|
||||
OUT("ber_dec_rval_t\n");
|
||||
OUT("%s_decode_ber(asn1_TYPE_descriptor_t *td,\n", p);
|
||||
INDENTED(
|
||||
OUT("\tvoid *struct_ptr, int contents_only) {\n");
|
||||
OUT("\tvoid **structure, void *bufptr, size_t size, int tag_mode) {\n");
|
||||
OUT("%s_inherit_TYPE_descriptor(td);\n", p);
|
||||
OUT("td->free_struct(td, struct_ptr, contents_only);\n");
|
||||
OUT("return td->ber_decoder(td, structure, bufptr, size, tag_mode);\n");
|
||||
);
|
||||
OUT("}\n");
|
||||
OUT("\n");
|
||||
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("asn_enc_rval_t\n");
|
||||
OUT("%s_encode_der(asn1_TYPE_descriptor_t *td,\n", p);
|
||||
INDENTED(
|
||||
OUT("\tvoid *structure, int tag_mode, ber_tlv_tag_t tag,\n");
|
||||
OUT("\tasn_app_consume_bytes_f *cb, void *app_key) {\n");
|
||||
OUT("%s_inherit_TYPE_descriptor(td);\n", p);
|
||||
OUT("return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);\n");
|
||||
);
|
||||
OUT("}\n");
|
||||
OUT("\n");
|
||||
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("asn_enc_rval_t\n");
|
||||
OUT("%s_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,\n", p);
|
||||
INDENTED(
|
||||
OUT("\tint ilevel, enum xer_encoder_flags_e flags,\n");
|
||||
OUT("\tasn_app_consume_bytes_f *cb, void *app_key) {\n");
|
||||
OUT("%s_inherit_TYPE_descriptor(td);\n", p);
|
||||
OUT("return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);\n");
|
||||
);
|
||||
OUT("}\n");
|
||||
OUT("\n");
|
||||
|
@ -883,11 +926,12 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
|
|||
OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;", p);
|
||||
if(HIDE_INNER_DEFS) OUT(" // (Use -fall-defs-global to expose) */");
|
||||
OUT("\n");
|
||||
OUT("asn_struct_free_f %s_free;\n", p);
|
||||
OUT("asn_struct_print_f %s_print;\n", p);
|
||||
OUT("asn_constr_check_f %s_constraint;\n", p);
|
||||
OUT("ber_type_decoder_f %s_decode_ber;\n", p);
|
||||
OUT("der_type_encoder_f %s_encode_der;\n", p);
|
||||
OUT("asn_struct_print_f %s_print;\n", p);
|
||||
OUT("asn_struct_free_f %s_free;\n", p);
|
||||
OUT("xer_type_encoder_f %s_encode_xer;\n", p);
|
||||
|
||||
REDIR(OT_TYPE_DECLS);
|
||||
|
||||
|
@ -1031,7 +1075,8 @@ _add_tag2el_member(arg_t *arg, tag2el_t **tag2el, int *count, int el_no) {
|
|||
|
||||
assert(el_no >= 0);
|
||||
|
||||
ret = asn1f_fetch_outmost_tag(arg->asn, arg->mod, arg->expr, &tag, 1);
|
||||
ret = asn1f_fetch_outmost_tag(arg->asn, arg->expr->module,
|
||||
arg->expr, &tag, 1);
|
||||
if(ret == 0) {
|
||||
tag2el_t *te;
|
||||
int new_count = (*count) + 1;
|
||||
|
@ -1137,12 +1182,12 @@ emit_tags_vectors(arg_t *arg, asn1p_expr_t *expr, int *tags_count_r, int *all_ta
|
|||
*all_tags_count_r = 0;
|
||||
|
||||
/* Fetch a chain of tags */
|
||||
tags_count = asn1f_fetch_tags(arg->asn, arg->mod, expr, &tags, 0);
|
||||
tags_count = asn1f_fetch_tags(arg->asn, expr->module, expr, &tags, 0);
|
||||
if(tags_count < 0)
|
||||
return -1;
|
||||
|
||||
/* Fetch a chain of tags */
|
||||
all_tags_count = asn1f_fetch_tags(arg->asn, arg->mod, expr,
|
||||
all_tags_count = asn1f_fetch_tags(arg->asn, expr->module, expr,
|
||||
&all_tags, AFT_FULL_COLLECT);
|
||||
if(all_tags_count < 0) {
|
||||
if(tags) free(tags);
|
||||
|
@ -1207,7 +1252,7 @@ expr_elements_count(arg_t *arg, asn1p_expr_t *expr) {
|
|||
asn1p_expr_t *v;
|
||||
int elements = 0;
|
||||
|
||||
topmost_parent = asn1f_find_terminal_type_ex(arg->asn, arg->mod, expr);
|
||||
topmost_parent = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
if(!topmost_parent) return 0;
|
||||
|
||||
if(!(topmost_parent->expr_type & ASN_CONSTR_MASK))
|
||||
|
@ -1254,15 +1299,15 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
|
|||
} else {
|
||||
OUT("0, ");
|
||||
}
|
||||
if(expr->Identifier) {
|
||||
if(expr->_anonymous_type) {
|
||||
assert(arg->expr->expr_type == ASN_CONSTR_SET_OF
|
||||
|| arg->expr->expr_type == ASN_CONSTR_SEQUENCE_OF);
|
||||
OUT("0,\n");
|
||||
} else {
|
||||
OUT("offsetof(struct %s, ", MKID(arg->expr->Identifier));
|
||||
if(arg->expr->expr_type == ASN_CONSTR_CHOICE
|
||||
&& (!UNNAMED_UNIONS)) OUT("choice.");
|
||||
OUT("%s),\n", MKID(expr->Identifier));
|
||||
} else {
|
||||
assert(arg->expr->expr_type == ASN_CONSTR_SET_OF
|
||||
|| arg->expr->expr_type == ASN_CONSTR_SEQUENCE_OF);
|
||||
OUT("0,\n");
|
||||
}
|
||||
INDENT(+1);
|
||||
if(C99_MODE) OUT(".tag = ");
|
||||
|
@ -1286,9 +1331,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
|
|||
OUT("0,\n");
|
||||
}
|
||||
if(C99_MODE) OUT(".type = ");
|
||||
if((expr->expr_type & ASN_CONSTR_MASK)
|
||||
&& (arg->expr->expr_type == ASN_CONSTR_SEQUENCE_OF
|
||||
|| arg->expr->expr_type == ASN_CONSTR_SET_OF)) {
|
||||
if(expr->_anonymous_type && (expr->expr_type & ASN_CONSTR_MASK)) {
|
||||
OUT("(void *)&asn1_DEF_%s_member,\n",
|
||||
MKID(arg->expr->Identifier));
|
||||
} else if(expr->expr_type & ASN_CONSTR_MASK) {
|
||||
|
@ -1301,7 +1344,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
|
|||
if(C99_MODE) OUT(".memb_constraints = ");
|
||||
if(expr->constraints) {
|
||||
char *id = MKID(expr->Identifier);
|
||||
if(!expr->Identifier)
|
||||
if(expr->_anonymous_type && !strcmp(expr->Identifier, "member"))
|
||||
id = asn1c_type_name(arg, expr, TNF_SAFE);
|
||||
OUT("memb_%s_%d_constraint,\n", id,
|
||||
++global_memb_unique);
|
||||
|
@ -1309,7 +1352,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
|
|||
OUT("0,\t/* Defer to actual type */\n");
|
||||
}
|
||||
if(C99_MODE) OUT(".name = ");
|
||||
OUT("\"%s\"\n", expr->Identifier ? expr->Identifier : "");
|
||||
OUT("\"%s\"\n", expr->_anonymous_type ? "" : expr->Identifier);
|
||||
OUT("},\n");
|
||||
INDENT(-1);
|
||||
|
||||
|
@ -1319,10 +1362,10 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
|
|||
save_target = arg->target->target;
|
||||
REDIR(OT_CODE);
|
||||
|
||||
if(expr->Identifier)
|
||||
p = MKID(expr->Identifier);
|
||||
else
|
||||
if(expr->_anonymous_type && !strcmp(expr->Identifier, "member"))
|
||||
p = asn1c_type_name(arg, expr, TNF_SAFE);
|
||||
else
|
||||
p = MKID(expr->Identifier);
|
||||
OUT("static int\n");
|
||||
OUT("memb_%s_%d_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,\n", p, global_memb_unique);
|
||||
INDENT(+1);
|
||||
|
@ -1357,11 +1400,13 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
|
|||
p = asn1c_type_name(arg, arg->expr, TNF_SAFE);
|
||||
}
|
||||
|
||||
OUT("%s_free,\n", p);
|
||||
OUT("%s_print,\n", p);
|
||||
OUT("%s_constraint,\n", p);
|
||||
OUT("%s_decode_ber,\n", p);
|
||||
OUT("%s_encode_der,\n", p);
|
||||
OUT("%s_print,\n", p);
|
||||
OUT("%s_free,\n", p);
|
||||
OUT("0, /* Not implemented yet */\n");
|
||||
OUT("%s_encode_xer,\n", p);
|
||||
|
||||
p = MKID(expr->Identifier);
|
||||
|
||||
|
@ -1468,7 +1513,24 @@ expr_better_indirect(arg_t *arg, asn1p_expr_t *expr) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, arg->mod, expr);
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
|
||||
return (terminal == top_parent);
|
||||
}
|
||||
|
||||
static int
|
||||
expr_as_xmlvaluelist(arg_t *arg, asn1p_expr_t *expr) {
|
||||
expr = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
if(!expr) return 0;
|
||||
|
||||
/* X.680, 25.5, Table 5 */
|
||||
switch(expr->expr_type) {
|
||||
case ASN_CONSTR_CHOICE:
|
||||
case ASN_BASIC_BOOLEAN:
|
||||
case ASN_BASIC_ENUMERATED:
|
||||
case ASN_BASIC_NULL:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,20 @@
|
|||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <ANY.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
asn1_TYPE_descriptor_t asn1_DEF_ANY = {
|
||||
"ANY",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print,
|
||||
asn_generic_no_constraint,
|
||||
OCTET_STRING_decode_ber,
|
||||
OCTET_STRING_encode_der,
|
||||
OCTET_STRING_print,
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
ANY_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
0, 0, 0, 0,
|
||||
-1, /* Both ways are fine (primitive and constructed) */
|
||||
|
@ -21,6 +24,23 @@ asn1_TYPE_descriptor_t asn1_DEF_ANY = {
|
|||
};
|
||||
|
||||
|
||||
asn_enc_rval_t
|
||||
ANY_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
(void)cb;
|
||||
(void)app_key;
|
||||
|
||||
/*
|
||||
* XER-encoding of ANY type is not supported.
|
||||
*/
|
||||
|
||||
_ASN_ENCODE_FAILED;
|
||||
}
|
||||
|
||||
struct _callback_arg {
|
||||
uint8_t *buffer;
|
||||
size_t offset;
|
||||
|
@ -32,7 +52,7 @@ static int ANY__consume_bytes(const void *buffer, size_t size, void *key);
|
|||
int
|
||||
ANY_fromType(ANY_t *st, asn1_TYPE_descriptor_t *td, void *sptr) {
|
||||
struct _callback_arg arg;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
if(!st || !td) {
|
||||
errno = EINVAL;
|
||||
|
@ -53,7 +73,7 @@ ANY_fromType(ANY_t *st, asn1_TYPE_descriptor_t *td, void *sptr) {
|
|||
if(arg.buffer) FREEMEM(arg.buffer);
|
||||
return -1;
|
||||
}
|
||||
assert(erval.encoded == arg.offset);
|
||||
assert((size_t)erval.encoded == arg.offset);
|
||||
|
||||
if(st->buf) FREEMEM(st->buf);
|
||||
st->buf = arg.buffer;
|
||||
|
|
|
@ -17,10 +17,11 @@ typedef struct ANY {
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_ANY;
|
||||
|
||||
asn_struct_free_f ANY_free;
|
||||
asn_struct_print_f ANY_print;
|
||||
ber_type_decoder_f ANY_decode_ber;
|
||||
der_type_encoder_f ANY_encode_der;
|
||||
asn_struct_print_f ANY_print;
|
||||
asn_struct_free_f ANY_free;
|
||||
xer_type_encoder_f ANY_encode_xer;
|
||||
|
||||
/******************************
|
||||
* Handy conversion routines. *
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <BIT_STRING.h>
|
||||
|
||||
/*
|
||||
|
@ -12,11 +13,13 @@ static ber_tlv_tag_t asn1_DEF_BIT_STRING_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_BIT_STRING = {
|
||||
"BIT STRING",
|
||||
OCTET_STRING_free, /* Implemented in terms of OCTET STRING */
|
||||
BIT_STRING_print,
|
||||
BIT_STRING_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
BIT_STRING_print,
|
||||
OCTET_STRING_free, /* Implemented in terms of OCTET STRING */
|
||||
0, /* Not implemented yet */
|
||||
BIT_STRING_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_BIT_STRING_tags,
|
||||
sizeof(asn1_DEF_BIT_STRING_tags)
|
||||
|
@ -61,6 +64,66 @@ BIT_STRING_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *_bit_pattern[16] = {
|
||||
"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111",
|
||||
"1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"
|
||||
};
|
||||
|
||||
asn_enc_rval_t
|
||||
BIT_STRING_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
char scratch[128];
|
||||
char *p = scratch;
|
||||
char *scend = scratch + (sizeof(scratch) - 10);
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
uint8_t *buf;
|
||||
uint8_t *end;
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
buf = st->buf;
|
||||
end = buf + st->size - 1; /* Last byte is special */
|
||||
|
||||
/*
|
||||
* Binary dump
|
||||
*/
|
||||
for(buf++; buf < end; buf++) {
|
||||
int v = *buf;
|
||||
int nline = (flags & XER_F_CANONICAL)
|
||||
?0:((((buf - st->buf) - 1) % 16) == 0);
|
||||
if(p >= scend || nline) {
|
||||
er.encoded += p - scratch;
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
p = scratch;
|
||||
if(nline) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
}
|
||||
memcpy(p + 0, _bit_pattern[v >> 4], 4);
|
||||
memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
|
||||
p += 8;
|
||||
}
|
||||
|
||||
er.encoded += p - scratch;
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
|
||||
if(buf < end + 1) {
|
||||
int v = *buf;
|
||||
int mbit = st->buf[0]; /* bits to skip from the right */
|
||||
int i;
|
||||
for(i = 7; i >= mbit; i--)
|
||||
*p++ = (v & (1 << i)) ? '1' : '0';
|
||||
er.encoded += p - scratch;
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
}
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* BIT STRING specific contents printer.
|
||||
*/
|
||||
|
@ -99,6 +162,7 @@ BIT_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
*p++ = h2c[*buf & 0x0F];
|
||||
*p++ = 0x20;
|
||||
}
|
||||
if(p > scratch) p--; /* Eat the tailing space */
|
||||
|
||||
/* Dump the incomplete 16-bytes row */
|
||||
return cb(scratch, p - scratch, app_key);
|
||||
|
|
|
@ -14,5 +14,6 @@ extern asn1_TYPE_descriptor_t asn1_DEF_BIT_STRING;
|
|||
|
||||
asn_struct_print_f BIT_STRING_print; /* Human-readable output */
|
||||
asn_constr_check_f BIT_STRING_constraint;
|
||||
xer_type_encoder_f BIT_STRING_encode_xer;
|
||||
|
||||
#endif /* _BIT_STRING_H_ */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <BMPString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_BMPString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_BMPString = {
|
||||
"BMPString",
|
||||
OCTET_STRING_free, /* Implemented in terms of OCTET STRING */
|
||||
BMPString_print,
|
||||
asn_generic_no_constraint, /* No constraint by default */
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
BMPString_print,
|
||||
OCTET_STRING_free, /* -//- */
|
||||
0, /* Not implemented yet */
|
||||
BMPString_encode_xer, /* Conver to UTF8 */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_BMPString_tags,
|
||||
sizeof(asn1_DEF_BMPString_tags)
|
||||
|
@ -33,27 +36,22 @@ asn1_TYPE_descriptor_t asn1_DEF_BMPString = {
|
|||
/*
|
||||
* BMPString specific contents printer.
|
||||
*/
|
||||
int
|
||||
BMPString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
static ssize_t
|
||||
BMPString__dump(const BMPString_t *st,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
uint16_t *wchar;
|
||||
uint16_t *wend;
|
||||
char scratch[128]; /* Scratchpad buffer */
|
||||
char *p;
|
||||
char *p = scratch;
|
||||
ssize_t wrote = 0;
|
||||
uint8_t *ch;
|
||||
uint8_t *end;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf) return cb("<absent>", 8, app_key);
|
||||
|
||||
wchar = (uint16_t *)st->buf;
|
||||
wend = (uint16_t *)(st->buf + st->size);
|
||||
for(p = scratch; wchar < wend; wchar++) {
|
||||
uint16_t wc = (((uint8_t *)wchar)[0] << 8)
|
||||
| ((uint8_t *)wchar)[1]; /* 2 bytes */
|
||||
ch = st->buf;
|
||||
end = (st->buf + st->size);
|
||||
for(end--; ch < end; ch += 2) {
|
||||
uint16_t wc = (ch[0] << 8) | ch[1]; /* 2 bytes */
|
||||
if(sizeof(scratch) - (p - scratch) < 3) {
|
||||
if(cb(scratch, p - scratch, app_key))
|
||||
wrote += p - scratch;
|
||||
if(cb(scratch, p - scratch, app_key) < 0)
|
||||
return -1;
|
||||
p = scratch;
|
||||
}
|
||||
|
@ -69,5 +67,45 @@ BMPString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
}
|
||||
}
|
||||
|
||||
return cb(scratch, p - scratch, app_key);
|
||||
wrote += p - scratch;
|
||||
if(cb(scratch, p - scratch, app_key) < 0)
|
||||
return -1;
|
||||
|
||||
return wrote;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
BMPString_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = BMPString__dump(st, cb, app_key);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
BMPString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf) return cb("<absent>", 8, app_key);
|
||||
|
||||
if(BMPString__dump(st, cb, app_key) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _BMPString_H_
|
||||
|
@ -13,5 +13,6 @@ typedef OCTET_STRING_t BMPString_t; /* Implemented in terms of OCTET STRING */
|
|||
extern asn1_TYPE_descriptor_t asn1_DEF_BMPString;
|
||||
|
||||
asn_struct_print_f BMPString_print; /* Human-readable output */
|
||||
xer_type_encoder_f BMPString_encode_xer;
|
||||
|
||||
#endif /* _BMPString_H_ */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <BOOLEAN.h>
|
||||
|
||||
/*
|
||||
|
@ -12,11 +13,13 @@ static ber_tlv_tag_t asn1_DEF_BOOLEAN_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN = {
|
||||
"BOOLEAN",
|
||||
BOOLEAN_free,
|
||||
BOOLEAN_print,
|
||||
asn_generic_no_constraint,
|
||||
BOOLEAN_decode_ber,
|
||||
BOOLEAN_encode_der,
|
||||
BOOLEAN_print,
|
||||
BOOLEAN_free,
|
||||
0, /* Not implemented yet */
|
||||
BOOLEAN_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_BOOLEAN_tags,
|
||||
sizeof(asn1_DEF_BOOLEAN_tags) / sizeof(asn1_DEF_BOOLEAN_tags[0]),
|
||||
|
@ -93,11 +96,11 @@ BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
return rval;
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
BOOLEAN_encode_der(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)sptr;
|
||||
|
||||
erval.encoded = der_write_tags(td, 1, tag_mode, tag, cb, app_key);
|
||||
|
@ -126,6 +129,29 @@ BOOLEAN_encode_der(asn1_TYPE_descriptor_t *td, void *sptr,
|
|||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
BOOLEAN_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!st) _ASN_ENCODE_FAILED;
|
||||
|
||||
if(*st) {
|
||||
_ASN_CALLBACK("<true/>", 7);
|
||||
er.encoded = 7;
|
||||
} else {
|
||||
_ASN_CALLBACK("<false/>", 8);
|
||||
er.encoded = 8;
|
||||
}
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
BOOLEAN_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -16,9 +16,10 @@ typedef int BOOLEAN_t;
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN;
|
||||
|
||||
asn_struct_free_f BOOLEAN_free;
|
||||
asn_struct_print_f BOOLEAN_print;
|
||||
ber_type_decoder_f BOOLEAN_decode_ber;
|
||||
der_type_encoder_f BOOLEAN_encode_der;
|
||||
asn_struct_print_f BOOLEAN_print;
|
||||
asn_struct_free_f BOOLEAN_free;
|
||||
xer_type_encoder_f BOOLEAN_encode_xer;
|
||||
|
||||
#endif /* _BOOLEAN_H_ */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <ENUMERATED.h>
|
||||
|
||||
/*
|
||||
|
@ -12,11 +13,13 @@ static ber_tlv_tag_t asn1_DEF_ENUMERATED_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_ENUMERATED = {
|
||||
"ENUMERATED",
|
||||
INTEGER_free, /* Implemented in terms of INTEGER */
|
||||
INTEGER_print, /* Implemented in terms of INTEGER */
|
||||
asn_generic_no_constraint,
|
||||
INTEGER_decode_ber, /* Implemented in terms of INTEGER */
|
||||
INTEGER_encode_der, /* Implemented in terms of INTEGER */
|
||||
INTEGER_print, /* Implemented in terms of INTEGER */
|
||||
INTEGER_free, /* Implemented in terms of INTEGER */
|
||||
0, /* Not implemented yet */
|
||||
INTEGER_encode_xer, /* Implemented in terms of INTEGER */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_ENUMERATED_tags,
|
||||
sizeof(asn1_DEF_ENUMERATED_tags) / sizeof(asn1_DEF_ENUMERATED_tags[0]),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <GeneralString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_GeneralString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_GeneralString = {
|
||||
"GeneralString",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
asn_generic_unknown_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer, /* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_GeneralString_tags,
|
||||
sizeof(asn1_DEF_GeneralString_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <GeneralizedTime.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
@ -113,11 +114,13 @@ static ber_tlv_tag_t asn1_DEF_GeneralizedTime_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime = {
|
||||
"GeneralizedTime",
|
||||
OCTET_STRING_free,
|
||||
GeneralizedTime_print,
|
||||
GeneralizedTime_constraint, /* Check validity of time */
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
GeneralizedTime_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
GeneralizedTime_print,
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
GeneralizedTime_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_GeneralizedTime_tags,
|
||||
sizeof(asn1_DEF_GeneralizedTime_tags)
|
||||
|
@ -153,12 +156,12 @@ GeneralizedTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
GeneralizedTime_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
GeneralizedTime_t *st = (GeneralizedTime_t *)ptr;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
/* If not canonical DER, re-encode into canonical DER. */
|
||||
if(st->size && st->buf[st->size-1] != 'Z') {
|
||||
|
@ -194,6 +197,36 @@ GeneralizedTime_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
GeneralizedTime_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
OCTET_STRING_t st;
|
||||
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
char buf[32];
|
||||
struct tm tm;
|
||||
ssize_t ret;
|
||||
|
||||
errno = EPERM;
|
||||
if(asn_GT2time((GeneralizedTime_t *)sptr, &tm, 1) == -1
|
||||
&& errno != EPERM)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
ret = snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ",
|
||||
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
assert(ret > 0 && ret < (int)sizeof(buf));
|
||||
|
||||
st.buf = (uint8_t *)buf;
|
||||
st.size = ret;
|
||||
sptr = &st;
|
||||
}
|
||||
|
||||
return OCTET_STRING_encode_xer_ascii(td, sptr, ilevel, flags,
|
||||
cb, app_key);
|
||||
}
|
||||
|
||||
int
|
||||
GeneralizedTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -12,9 +12,10 @@ typedef OCTET_STRING_t GeneralizedTime_t; /* Implemented using OCTET STRING */
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime;
|
||||
|
||||
asn_struct_print_f GeneralizedTime_print;
|
||||
asn_constr_check_f GeneralizedTime_constraint;
|
||||
der_type_encoder_f GeneralizedTime_encode_der;
|
||||
asn_struct_print_f GeneralizedTime_print;
|
||||
xer_type_encoder_f GeneralizedTime_encode_xer;
|
||||
|
||||
/***********************
|
||||
* Some handy helpers. *
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <GraphicString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_GraphicString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_GraphicString = {
|
||||
"GraphicString",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
asn_generic_unknown_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer, /* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_GraphicString_tags,
|
||||
sizeof(asn1_DEF_GraphicString_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <IA5String.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_IA5String_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_IA5String = {
|
||||
"IA5String",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
IA5String_constraint, /* Constraint on the alphabet */
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer_ascii,/* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_IA5String_tags,
|
||||
sizeof(asn1_DEF_IA5String_tags)
|
||||
|
@ -63,3 +66,4 @@ IA5String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <INTEGER.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
@ -14,11 +15,13 @@ static ber_tlv_tag_t asn1_DEF_INTEGER_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_INTEGER = {
|
||||
"INTEGER",
|
||||
INTEGER_free,
|
||||
INTEGER_print,
|
||||
asn_generic_no_constraint,
|
||||
INTEGER_decode_ber,
|
||||
INTEGER_encode_der,
|
||||
INTEGER_print,
|
||||
INTEGER_free,
|
||||
0, /* Not implemented yet */
|
||||
INTEGER_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_INTEGER_tags,
|
||||
sizeof(asn1_DEF_INTEGER_tags) / sizeof(asn1_DEF_INTEGER_tags[0]),
|
||||
|
@ -100,11 +103,11 @@ INTEGER_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* Encode INTEGER type using DER.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
INTEGER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
INTEGER_t *st = (INTEGER_t *)ptr;
|
||||
|
||||
ASN_DEBUG("%s %s as INTEGER (tm=%d)",
|
||||
|
@ -185,24 +188,19 @@ INTEGER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
/*
|
||||
* INTEGER specific human-readable output.
|
||||
*/
|
||||
int
|
||||
INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
static ssize_t
|
||||
INTEGER__dump(const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
char scratch[32]; /* Enough for 64-bit integer */
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
uint8_t *buf = st->buf;
|
||||
uint8_t *buf_end = st->buf + st->size;
|
||||
signed long accum;
|
||||
ssize_t wrote = 0;
|
||||
char *p;
|
||||
int ret;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st && !st->buf) return cb("<absent>", 8, app_key);
|
||||
|
||||
if(st->size == 0)
|
||||
return cb("0", 1, app_key);
|
||||
if(st->size == 0) {
|
||||
return (cb("0", 1, app_key) < 0) ? -1 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Advance buf pointer until the start of the value's body.
|
||||
|
@ -226,7 +224,7 @@ INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
accum = (accum << 8) | *buf;
|
||||
ret = snprintf(scratch, sizeof(scratch), "%ld", accum);
|
||||
assert(ret > 0 && ret < (int)sizeof(scratch));
|
||||
return cb(scratch, ret, app_key);
|
||||
return (cb(scratch, ret, app_key) < 0) ? -1 : ret;
|
||||
}
|
||||
|
||||
/* Output in the long xx:yy:zz... format */
|
||||
|
@ -235,8 +233,9 @@ INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
static const char *h2c = "0123456789ABCDEF";
|
||||
if((p - scratch) >= (ssize_t)(sizeof(scratch) - 4)) {
|
||||
/* Flush buffer */
|
||||
if(cb(scratch, p - scratch, app_key))
|
||||
if(cb(scratch, p - scratch, app_key) < 0)
|
||||
return -1;
|
||||
wrote += p - scratch;
|
||||
p = scratch;
|
||||
}
|
||||
*p++ = h2c[*buf >> 4];
|
||||
|
@ -246,7 +245,43 @@ INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
if(p != scratch)
|
||||
p--; /* Remove the last ':' */
|
||||
|
||||
return cb(scratch, p - scratch, app_key);
|
||||
wrote += p - scratch;
|
||||
return (cb(scratch, p - scratch, app_key) < 0) ? -1 : wrote;
|
||||
}
|
||||
|
||||
/*
|
||||
* INTEGER specific human-readable output.
|
||||
*/
|
||||
int
|
||||
INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
|
||||
(void)td;
|
||||
(void)ilevel;
|
||||
|
||||
if(!st && !st->buf) return cb("<absent>", 8, app_key);
|
||||
|
||||
return (INTEGER__dump(st, cb, app_key) < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
INTEGER_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!st && !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = INTEGER__dump(st, cb, app_key);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -14,10 +14,11 @@ typedef struct INTEGER {
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_INTEGER;
|
||||
|
||||
asn_struct_free_f INTEGER_free;
|
||||
asn_struct_print_f INTEGER_print;
|
||||
ber_type_decoder_f INTEGER_decode_ber;
|
||||
der_type_encoder_f INTEGER_encode_der;
|
||||
asn_struct_print_f INTEGER_print;
|
||||
asn_struct_free_f INTEGER_free;
|
||||
xer_type_encoder_f INTEGER_encode_xer;
|
||||
|
||||
/***********************************
|
||||
* Some handy conversion routines. *
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <ISO646String.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_ISO646String_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_ISO646String = {
|
||||
"ISO646String",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
VisibleString_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer_ascii,/* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_ISO646String_tags,
|
||||
sizeof(asn1_DEF_ISO646String_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <NULL.h>
|
||||
#include <BOOLEAN.h> /* Implemented in terms of BOOLEAN type */
|
||||
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_NULL_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_NULL = {
|
||||
"NULL",
|
||||
BOOLEAN_free,
|
||||
NULL_print,
|
||||
asn_generic_no_constraint,
|
||||
BOOLEAN_decode_ber, /* Implemented in terms of BOOLEAN */
|
||||
NULL_encode_der, /* Special handling of DER encoding */
|
||||
NULL_print,
|
||||
BOOLEAN_free,
|
||||
0, /* Not implemented yet */
|
||||
NULL_encode_xer, /* Special handling of DER encoding */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_NULL_tags,
|
||||
sizeof(asn1_DEF_NULL_tags) / sizeof(asn1_DEF_NULL_tags[0]),
|
||||
|
@ -28,21 +31,40 @@ asn1_TYPE_descriptor_t asn1_DEF_NULL = {
|
|||
0 /* No specifics */
|
||||
};
|
||||
|
||||
der_enc_rval_t
|
||||
NULL_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
||||
asn_enc_rval_t
|
||||
NULL_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
erval.encoded = der_write_tags(sd, 0, tag_mode, tag, cb, app_key);
|
||||
erval.encoded = der_write_tags(td, 0, tag_mode, tag, cb, app_key);
|
||||
if(erval.encoded == -1) {
|
||||
erval.failed_type = sd;
|
||||
erval.failed_type = td;
|
||||
erval.structure_ptr = ptr;
|
||||
}
|
||||
|
||||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NULL_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)td;
|
||||
(void)sptr;
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
(void)cb;
|
||||
(void)app_key;
|
||||
|
||||
/* XMLNullValue is empty */
|
||||
er.encoded = 0;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
NULL_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -15,7 +15,8 @@ typedef int NULL_t;
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_NULL;
|
||||
|
||||
der_type_encoder_f NULL_encode_der;
|
||||
asn_struct_print_f NULL_print;
|
||||
der_type_encoder_f NULL_encode_der;
|
||||
xer_type_encoder_f NULL_encode_xer;
|
||||
|
||||
#endif /* NULL_H */
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* implementation deals with the standard (machine-specific) representation
|
||||
* of them instead of using the platform-independent buffer.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <NativeEnumerated.h>
|
||||
|
||||
/*
|
||||
|
@ -19,11 +20,13 @@ static ber_tlv_tag_t asn1_DEF_NativeEnumerated_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_NativeEnumerated = {
|
||||
"ENUMERATED", /* The ASN.1 type is still ENUMERATED */
|
||||
NativeInteger_free,
|
||||
NativeInteger_print,
|
||||
asn_generic_no_constraint,
|
||||
NativeInteger_decode_ber,
|
||||
NativeInteger_encode_der,
|
||||
NativeInteger_print,
|
||||
NativeInteger_free,
|
||||
0, /* Not implemented yet */
|
||||
NativeInteger_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_NativeEnumerated_tags,
|
||||
sizeof(asn1_DEF_NativeEnumerated_tags) / sizeof(asn1_DEF_NativeEnumerated_tags[0]),
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* implementation deals with the standard (machine-specific) representation
|
||||
* of them instead of using the platform-independent buffer.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <NativeInteger.h>
|
||||
#include <INTEGER.h>
|
||||
#include <assert.h>
|
||||
|
@ -21,11 +22,13 @@ static ber_tlv_tag_t asn1_DEF_NativeInteger_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_NativeInteger = {
|
||||
"INTEGER", /* The ASN.1 type is still INTEGER */
|
||||
NativeInteger_free,
|
||||
NativeInteger_print,
|
||||
asn_generic_no_constraint,
|
||||
NativeInteger_decode_ber,
|
||||
NativeInteger_encode_der,
|
||||
NativeInteger_print,
|
||||
NativeInteger_free,
|
||||
0, /* Not implemented yet */
|
||||
NativeInteger_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_NativeInteger_tags,
|
||||
sizeof(asn1_DEF_NativeInteger_tags) / sizeof(asn1_DEF_NativeInteger_tags[0]),
|
||||
|
@ -127,17 +130,17 @@ NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* Encode the NativeInteger using the standard INTEGER type DER encoder.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
NativeInteger_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
unsigned int Int = *(unsigned int *)ptr; /* Disable sign ext. */
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
INTEGER_t tmp;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN /* Opportunistic optimization */
|
||||
|
||||
tmp.buf = ∬
|
||||
tmp.buf = (uint8_t *)∬
|
||||
tmp.size = sizeof(Int);
|
||||
|
||||
#else /* Works even if WORDS_BIGENDIAN is not set where should've been */
|
||||
|
@ -161,6 +164,27 @@ NativeInteger_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NativeInteger_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
char scratch[32]; /* Enough for 64-bit int */
|
||||
asn_enc_rval_t er;
|
||||
const int *Int = (const int *)sptr;
|
||||
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!Int) _ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = snprintf(scratch, sizeof(scratch), "%d", *Int);
|
||||
if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch)
|
||||
|| cb(scratch, er.encoded, app_key) < 0)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
/*
|
||||
* INTEGER specific human-readable output.
|
||||
*/
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_NativeInteger;
|
||||
|
||||
asn_struct_free_f NativeInteger_free;
|
||||
asn_struct_print_f NativeInteger_print;
|
||||
ber_type_decoder_f NativeInteger_decode_ber;
|
||||
der_type_encoder_f NativeInteger_encode_der;
|
||||
asn_struct_print_f NativeInteger_print;
|
||||
asn_struct_free_f NativeInteger_free;
|
||||
xer_type_encoder_f NativeInteger_encode_xer;
|
||||
|
||||
#endif /* _NativeInteger_H_ */
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* implementation deals with the standard (machine-specific) representation
|
||||
* of them instead of using the platform-independent buffer.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <NativeReal.h>
|
||||
#include <INTEGER.h>
|
||||
#include <REAL.h>
|
||||
|
@ -22,11 +23,13 @@ static ber_tlv_tag_t asn1_DEF_NativeReal_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_NativeReal = {
|
||||
"REAL", /* The ASN.1 type is still REAL */
|
||||
NativeReal_free,
|
||||
NativeReal_print,
|
||||
asn_generic_no_constraint,
|
||||
NativeReal_decode_ber,
|
||||
NativeReal_encode_der,
|
||||
NativeReal_print,
|
||||
NativeReal_free,
|
||||
0, /* Not implemented yet */
|
||||
NativeReal_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_NativeReal_tags,
|
||||
sizeof(asn1_DEF_NativeReal_tags) / sizeof(asn1_DEF_NativeReal_tags[0]),
|
||||
|
@ -116,12 +119,12 @@ NativeReal_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* Encode the NativeReal using the standard REAL type DER encoder.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
NativeReal_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
double Dbl = *(const double *)ptr;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
REAL_t tmp;
|
||||
|
||||
if(asn1_double2REAL(&tmp, Dbl)) {
|
||||
|
@ -140,6 +143,25 @@ NativeReal_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
return erval;
|
||||
}
|
||||
|
||||
|
||||
asn_enc_rval_t
|
||||
NativeReal_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const double *Dbl = (const double *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
double d;
|
||||
|
||||
(void)ilevel;
|
||||
|
||||
if(!Dbl) _ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = REAL__dump(d, flags & XER_F_CANONICAL, cb, app_key);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
/*
|
||||
* REAL specific human-readable output.
|
||||
*/
|
||||
|
@ -147,32 +169,13 @@ int
|
|||
NativeReal_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const double *Dbl = (const double *)sptr;
|
||||
char scratch[64];
|
||||
int ret;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(Dbl) {
|
||||
char *p = scratch;
|
||||
int buf_size = sizeof(scratch);
|
||||
for(;;) {
|
||||
ret = snprintf(p, buf_size, "%f", *Dbl);
|
||||
if(ret >= 0 && ret < buf_size) {
|
||||
ret = cb(p, ret, app_key);
|
||||
if(p != scratch) free(p);
|
||||
return ret;
|
||||
} else {
|
||||
if(p != scratch) free(p);
|
||||
}
|
||||
if(ret < 0) buf_size <<= 2; /* Old libc. */
|
||||
else buf_size = ret + 1;
|
||||
(void *)p = MALLOC(ret);
|
||||
if(!p) return -1;
|
||||
}
|
||||
} else {
|
||||
return cb("<absent>", 8, app_key);
|
||||
}
|
||||
if(!Dbl) return cb("<absent>", 8, app_key);
|
||||
|
||||
return (REAL__dump(*Dbl, 0, cb, app_key) < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_NativeReal;
|
||||
|
||||
asn_struct_free_f NativeReal_free;
|
||||
asn_struct_print_f NativeReal_print;
|
||||
ber_type_decoder_f NativeReal_decode_ber;
|
||||
der_type_encoder_f NativeReal_encode_der;
|
||||
asn_struct_print_f NativeReal_print;
|
||||
asn_struct_free_f NativeReal_free;
|
||||
xer_type_encoder_f NativeReal_encode_xer;
|
||||
|
||||
#endif /* ASN_TYPE_NativeReal_H */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <NumericString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_NumericString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_NumericString = {
|
||||
"NumericString",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
NumericString_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer_ascii,/* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_NumericString_tags,
|
||||
sizeof(asn1_DEF_NumericString_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <OBJECT_IDENTIFIER.h>
|
||||
#include <limits.h> /* for CHAR_BIT */
|
||||
#include <assert.h>
|
||||
|
@ -15,11 +16,13 @@ static ber_tlv_tag_t asn1_DEF_OBJECT_IDENTIFIER_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER = {
|
||||
"OBJECT IDENTIFIER",
|
||||
INTEGER_free,
|
||||
OBJECT_IDENTIFIER_print,
|
||||
OBJECT_IDENTIFIER_constraint,
|
||||
INTEGER_decode_ber, /* Implemented in terms of INTEGER type */
|
||||
OBJECT_IDENTIFIER_encode_der,
|
||||
OBJECT_IDENTIFIER_print,
|
||||
INTEGER_free,
|
||||
0, /* Not implemented yet */
|
||||
OBJECT_IDENTIFIER_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_OBJECT_IDENTIFIER_tags,
|
||||
sizeof(asn1_DEF_OBJECT_IDENTIFIER_tags)
|
||||
|
@ -36,11 +39,11 @@ asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER = {
|
|||
/*
|
||||
* Encode OBJECT IDENTIFIER type using DER.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
OBJECT_IDENTIFIER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)ptr;
|
||||
|
||||
ASN_DEBUG("%s %s as OBJECT IDENTIFIER (tm=%d)",
|
||||
|
@ -57,10 +60,8 @@ OBJECT_IDENTIFIER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
}
|
||||
|
||||
if(cb && st->buf) {
|
||||
ssize_t ret;
|
||||
|
||||
ret = cb(st->buf, st->size, app_key);
|
||||
if(ret == -1) {
|
||||
int ret = cb(st->buf, st->size, app_key);
|
||||
if(ret < 0) {
|
||||
erval.encoded = -1;
|
||||
erval.failed_type = sd;
|
||||
erval.structure_ptr = ptr;
|
||||
|
@ -215,9 +216,8 @@ OBJECT_IDENTIFIER_get_single_arc(uint8_t *arcbuf, unsigned int arclen, signed in
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add,
|
||||
ssize_t
|
||||
OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
char scratch[64]; /* Conservative estimate */
|
||||
unsigned long accum; /* Bits accumulator */
|
||||
|
@ -228,36 +228,42 @@ OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add,
|
|||
return -1;
|
||||
|
||||
if(accum) {
|
||||
ssize_t len;
|
||||
|
||||
/* Fill the scratch buffer in reverse. */
|
||||
p = scratch + sizeof(scratch);
|
||||
for(; accum; accum /= 10)
|
||||
*(--p) = (char)(accum % 10) + 0x30;
|
||||
*(--p) = (char)(accum % 10) + 0x30; /* Put a digit */
|
||||
|
||||
return cb(p, sizeof(scratch) - (p - scratch), app_key);
|
||||
len = sizeof(scratch) - (p - scratch);
|
||||
if(cb(p, len, app_key) < 0)
|
||||
return -1;
|
||||
return len;
|
||||
} else {
|
||||
*scratch = 0x30;
|
||||
return cb(scratch, 1, app_key);
|
||||
if(cb(scratch, 1, app_key) < 0)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
OBJECT_IDENTIFIER_print(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
||||
if(OBJECT_IDENTIFIER__dump_arc(arcbuf, arclen, add, cb, app_key) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
OBJECT_IDENTIFIER__dump_body(const OBJECT_IDENTIFIER_t *st, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
ssize_t wrote_len = 0;
|
||||
int startn;
|
||||
int add = 0;
|
||||
int i;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf)
|
||||
return cb("<absent>", 8, app_key);
|
||||
|
||||
/* Dump preamble */
|
||||
if(cb("{ ", 2, app_key))
|
||||
return -1;
|
||||
|
||||
for(i = 0, startn = 0; i < st->size; i++) {
|
||||
uint8_t b = st->buf[i];
|
||||
if((b & 0x80)) /* Continuation expected */
|
||||
|
@ -269,30 +275,71 @@ OBJECT_IDENTIFIER_print(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
if(i) {
|
||||
add = -80;
|
||||
if(cb("2", 1, app_key)) return -1;
|
||||
if(cb("2", 1, app_key) < 0) return -1;
|
||||
} else if(b <= 39) {
|
||||
add = 0;
|
||||
if(cb("0", 1, app_key)) return -1;
|
||||
if(cb("0", 1, app_key) < 0) return -1;
|
||||
} else if(b < 79) {
|
||||
add = -40;
|
||||
if(cb("1", 1, app_key)) return -1;
|
||||
if(cb("1", 1, app_key) < 0) return -1;
|
||||
} else {
|
||||
add = -80;
|
||||
if(cb("2", 1, app_key)) return -1;
|
||||
if(cb("2", 1, app_key) < 0) return -1;
|
||||
}
|
||||
wrote_len += 1;
|
||||
}
|
||||
|
||||
if(cb(" ", 1, app_key)) /* Separate arcs */
|
||||
if(cb(".", 1, app_key) < 0) /* Separate arcs */
|
||||
return -1;
|
||||
|
||||
if(OBJECT_IDENTIFIER_print_arc(&st->buf[startn],
|
||||
i - startn + 1, add,
|
||||
cb, app_key))
|
||||
return -1;
|
||||
add = OBJECT_IDENTIFIER__dump_arc(&st->buf[startn],
|
||||
i - startn + 1, add, cb, app_key);
|
||||
if(add < 0) return -1;
|
||||
wrote_len += 1 + add;
|
||||
startn = i + 1;
|
||||
add = 0;
|
||||
}
|
||||
|
||||
return wrote_len;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OBJECT_IDENTIFIER_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = OBJECT_IDENTIFIER__dump_body(st, cb, app_key);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
OBJECT_IDENTIFIER_print(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf)
|
||||
return cb("<absent>", 8, app_key);
|
||||
|
||||
/* Dump preamble */
|
||||
if(cb("{ ", 2, app_key))
|
||||
return -1;
|
||||
|
||||
if(OBJECT_IDENTIFIER__dump_body(st, cb, app_key) < 0)
|
||||
return -1;
|
||||
|
||||
return cb(" }", 2, app_key);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ typedef INTEGER_t OBJECT_IDENTIFIER_t; /* Implemented in terms of INTEGER */
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER;
|
||||
|
||||
der_type_encoder_f OBJECT_IDENTIFIER_encode_der;
|
||||
asn_constr_check_f OBJECT_IDENTIFIER_constraint;
|
||||
asn_struct_print_f OBJECT_IDENTIFIER_print;
|
||||
asn_constr_check_f OBJECT_IDENTIFIER_constraint;
|
||||
der_type_encoder_f OBJECT_IDENTIFIER_encode_der;
|
||||
xer_type_encoder_f OBJECT_IDENTIFIER_encode_xer;
|
||||
|
||||
/**********************************
|
||||
* Some handy conversion routines *
|
||||
|
@ -27,6 +28,10 @@ int OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen,
|
|||
int add, /* Arbitrary offset, required to process the first two arcs */
|
||||
asn_app_consume_bytes_f *cb, void *app_key);
|
||||
|
||||
/* Same as above, but returns the number of written digits, instead of 0 */
|
||||
ssize_t OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add,
|
||||
asn_app_consume_bytes_f *cb, void *app_key);
|
||||
|
||||
/*
|
||||
* This function fills an (_arcs) array with OBJECT IDENTIFIER arcs
|
||||
* up to specified (_arc_slots) elements.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <OCTET_STRING.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
@ -14,11 +15,13 @@ static ber_tlv_tag_t asn1_DEF_OCTET_STRING_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING = {
|
||||
"OCTET STRING",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print, /* non-ascii stuff, generally */
|
||||
asn_generic_no_constraint,
|
||||
OCTET_STRING_decode_ber,
|
||||
OCTET_STRING_encode_der,
|
||||
OCTET_STRING_print, /* non-ascii stuff, generally */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_OCTET_STRING_tags,
|
||||
sizeof(asn1_DEF_OCTET_STRING_tags)
|
||||
|
@ -440,11 +443,11 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* Encode OCTET STRING type using DER.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)ptr;
|
||||
int add_byte = 0;
|
||||
int is_bit_str = (td->specifics == (void *)-1);
|
||||
|
@ -514,6 +517,84 @@ OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
static const char *h2c = "0123456789ABCDEF";
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
char scratch[16 * 3 + 4];
|
||||
char *p = scratch;
|
||||
uint8_t *buf;
|
||||
uint8_t *end;
|
||||
size_t i;
|
||||
|
||||
if(!st || !st->buf) {
|
||||
er.encoded = -1;
|
||||
er.failed_type = td;
|
||||
er.structure_ptr = sptr;
|
||||
return er;
|
||||
}
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
/*
|
||||
* Dump the contents of the buffer in hexadecimal.
|
||||
*/
|
||||
buf = st->buf;
|
||||
end = buf + st->size;
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
char *scend = scratch + (sizeof(scratch) - 2);
|
||||
for(; buf < end; buf++) {
|
||||
if(p >= scend) {
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
er.encoded += p - scratch;
|
||||
p = scratch;
|
||||
}
|
||||
*p++ = h2c[(*buf >> 4) & 0x0F];
|
||||
*p++ = h2c[*buf & 0x0F];
|
||||
}
|
||||
} else {
|
||||
for(i = 0; buf < end; buf++, i++) {
|
||||
if(!(i % 16) && (i || st->size > 16)) {
|
||||
_ASN_CALLBACK(scratch, p-scratch);
|
||||
er.encoded += (p-scratch);
|
||||
p = scratch;
|
||||
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||
}
|
||||
*p++ = h2c[(*buf >> 4) & 0x0F];
|
||||
*p++ = h2c[*buf & 0x0F];
|
||||
*p++ = 0x20;
|
||||
}
|
||||
if(i) p--; /* Remove the tail space */
|
||||
}
|
||||
|
||||
_ASN_CALLBACK(scratch, p-scratch); /* Dump the rest */
|
||||
er.encoded += p - scratch;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_xer_ascii(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel; /* Unused argument */
|
||||
(void)flags; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
_ASN_CALLBACK(st->buf, st->size);
|
||||
er.encoded = st->size;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
@ -524,7 +605,7 @@ OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
uint8_t *buf;
|
||||
uint8_t *end;
|
||||
size_t i;
|
||||
int ret;
|
||||
int lvl;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
|
||||
|
@ -540,14 +621,15 @@ OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
if(cb(scratch, p - scratch, app_key)
|
||||
|| cb("\n", 1, app_key))
|
||||
return -1;
|
||||
for(ret = 0; ret < ilevel; ret++)
|
||||
for(lvl = 0; lvl < ilevel; lvl++)
|
||||
cb(" ", 1, app_key);
|
||||
p = scratch;
|
||||
}
|
||||
*p++ = h2c[(*buf >> 4) & 0x0F];
|
||||
*p++ = h2c[*buf & 0x0F];
|
||||
*p++ = ' ';
|
||||
*p++ = 0x20;
|
||||
}
|
||||
if(i) p--; /* Remove the tail space */
|
||||
|
||||
return cb(scratch, p - scratch, app_key);
|
||||
}
|
||||
|
|
|
@ -16,11 +16,13 @@ typedef struct OCTET_STRING {
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING;
|
||||
|
||||
ber_type_decoder_f OCTET_STRING_decode_ber;
|
||||
der_type_encoder_f OCTET_STRING_encode_der;
|
||||
asn_struct_free_f OCTET_STRING_free;
|
||||
asn_struct_print_f OCTET_STRING_print;
|
||||
asn_struct_print_f OCTET_STRING_print_ascii;
|
||||
asn_struct_free_f OCTET_STRING_free;
|
||||
ber_type_decoder_f OCTET_STRING_decode_ber;
|
||||
der_type_encoder_f OCTET_STRING_encode_der;
|
||||
xer_type_encoder_f OCTET_STRING_encode_xer;
|
||||
xer_type_encoder_f OCTET_STRING_encode_xer_ascii;
|
||||
|
||||
/***********************************
|
||||
* Some handy conversion routines. *
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <ObjectDescriptor.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_ObjectDescriptor_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_ObjectDescriptor = {
|
||||
"ObjectDescriptor",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print_ascii, /* Treat as ASCII subset (it's not) */
|
||||
asn_generic_unknown_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print_ascii, /* Treat as ASCII subset (it's not) */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer_ascii,/* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_ObjectDescriptor_tags,
|
||||
sizeof(asn1_DEF_ObjectDescriptor_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <PrintableString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_PrintableString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_PrintableString = {
|
||||
"PrintableString",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
PrintableString_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer_ascii,/* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_PrintableString_tags,
|
||||
sizeof(asn1_DEF_PrintableString_tags)
|
||||
|
|
107
skeletons/REAL.c
107
skeletons/REAL.c
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <REAL.h>
|
||||
#include <INTEGER.h>
|
||||
#include <stdlib.h> /* for strtod(3) */
|
||||
|
@ -29,11 +30,13 @@ static ber_tlv_tag_t asn1_DEF_REAL_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_REAL = {
|
||||
"REAL",
|
||||
INTEGER_free,
|
||||
REAL_print,
|
||||
asn_generic_no_constraint,
|
||||
INTEGER_decode_ber, /* Implemented in terms of INTEGER type */
|
||||
INTEGER_encode_der,
|
||||
REAL_print,
|
||||
INTEGER_free,
|
||||
0, /* Not implemented yet */
|
||||
REAL_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_REAL_tags,
|
||||
sizeof(asn1_DEF_REAL_tags) / sizeof(asn1_DEF_REAL_tags[0]),
|
||||
|
@ -44,33 +47,113 @@ asn1_TYPE_descriptor_t asn1_DEF_REAL = {
|
|||
0 /* No specifics */
|
||||
};
|
||||
|
||||
ssize_t
|
||||
REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
char local_buf[32];
|
||||
char *buf = local_buf;
|
||||
ssize_t buflen = sizeof(local_buf);
|
||||
const char *fmt = canonical?"%15E":"f";
|
||||
ssize_t ret;
|
||||
|
||||
do {
|
||||
ret = snprintf(buf, buflen, fmt, d);
|
||||
if(ret < 0) {
|
||||
buflen <<= 1;
|
||||
} else if(ret >= buflen) {
|
||||
buflen = ret + 1;
|
||||
} else {
|
||||
buflen = ret;
|
||||
break;
|
||||
}
|
||||
if(buf != local_buf) free(buf);
|
||||
(void *)buf = MALLOC(buflen);
|
||||
if(!buf) return -1;
|
||||
} while(1);
|
||||
|
||||
/*
|
||||
* Transform the "[-]d.dddE+-dd" output into "[-]d.dddE[-]d"
|
||||
*/
|
||||
if(canonical) {
|
||||
char *dot, *E;
|
||||
char *end = buf + buflen;
|
||||
|
||||
dot = (buf[0] == '-') ? (buf + 2) : (buf + 1);
|
||||
if(*dot >= 0x30) {
|
||||
errno = EINVAL;
|
||||
return -1; /* Not a dot, really */
|
||||
}
|
||||
*dot = '.'; /* Replace possible comma */
|
||||
|
||||
for(E = dot; dot < end; E++) {
|
||||
if(*E == 'E') {
|
||||
char *s = ++E;
|
||||
if(*E == '+') {
|
||||
/* Skip the "+" too */
|
||||
buflen -= 2;
|
||||
} else {
|
||||
buflen -= 1;
|
||||
s++;
|
||||
}
|
||||
E += 2;
|
||||
if(E[-1] != '0' || E > end) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
for(; E <= end; s++, E++)
|
||||
*s = *E;
|
||||
}
|
||||
}
|
||||
if(E == end) {
|
||||
errno = EINVAL;
|
||||
return -1; /* No promised E */
|
||||
}
|
||||
}
|
||||
|
||||
ret = cb(buf, buflen, app_key);
|
||||
if(buf != local_buf) free(buf);
|
||||
return (ret < 0) ? -1 : buflen;
|
||||
}
|
||||
|
||||
int
|
||||
REAL_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const REAL_t *st = (const REAL_t *)sptr;
|
||||
char buf[128];
|
||||
double d;
|
||||
int ret;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st)
|
||||
if(!st || !st->buf)
|
||||
return cb("<absent>", 8, app_key);
|
||||
|
||||
if(asn1_REAL2double(st, &d))
|
||||
return cb("<error>", 7, app_key);
|
||||
|
||||
ret = snprintf(buf, sizeof(buf), "%f", d);
|
||||
if(ret < 0 || ret >= sizeof(buf))
|
||||
return cb("<error>", 7, app_key);
|
||||
return (REAL__dump(d, 0, cb, app_key) < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
return cb(buf, ret, app_key);
|
||||
asn_enc_rval_t
|
||||
REAL_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
REAL_t *st = (REAL_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
double d;
|
||||
|
||||
(void)ilevel;
|
||||
|
||||
if(!st || !st->buf || asn1_REAL2double(st, &d))
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = REAL__dump(d, flags & XER_F_CANONICAL, cb, app_key);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
asn1_REAL2double(const REAL_t *st, double *dbl_value) {
|
||||
unsigned long octv;
|
||||
unsigned int octv;
|
||||
|
||||
if(!st || !st->buf) {
|
||||
errno = EINVAL;
|
||||
|
@ -158,7 +241,7 @@ asn1_REAL2double(const REAL_t *st, double *dbl_value) {
|
|||
sign = (octv & 0x40); /* bit 7 */
|
||||
scaleF = (octv & 0x0C) >> 2; /* bits 4 to 3 */
|
||||
|
||||
if(st->size <= (1 + (octv & 0x03))) {
|
||||
if(st->size <= (int)(1 + (octv & 0x03))) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
@ -166,7 +249,7 @@ asn1_REAL2double(const REAL_t *st, double *dbl_value) {
|
|||
if((octv & 0x03) == 0x11) {
|
||||
/* 8.5.6.4, case d) */
|
||||
elen = st->buf[1]; /* unsigned binary number */
|
||||
if(elen == 0 || st->size <= (2 + elen)) {
|
||||
if(elen == 0 || st->size <= (int)(2 + elen)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,14 @@ typedef struct REAL {
|
|||
extern asn1_TYPE_descriptor_t asn1_DEF_REAL;
|
||||
|
||||
asn_struct_print_f REAL_print;
|
||||
xer_type_encoder_f REAL_encode_xer;
|
||||
|
||||
/***********************************
|
||||
* Some handy conversion routines. *
|
||||
***********************************/
|
||||
|
||||
ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key);
|
||||
|
||||
/*
|
||||
* Convert between native double type and REAL representation (DER).
|
||||
* RETURN VALUES:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <RELATIVE-OID.h>
|
||||
#include <limits.h> /* for CHAR_BIT */
|
||||
#include <assert.h>
|
||||
|
@ -15,11 +16,13 @@ static ber_tlv_tag_t asn1_DEF_RELATIVE_OID_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID = {
|
||||
"RELATIVE-OID",
|
||||
INTEGER_free,
|
||||
RELATIVE_OID_print,
|
||||
asn_generic_no_constraint,
|
||||
INTEGER_decode_ber, /* Implemented in terms of INTEGER type */
|
||||
OBJECT_IDENTIFIER_encode_der,
|
||||
RELATIVE_OID_print,
|
||||
INTEGER_free,
|
||||
0, /* Not implemented yet */
|
||||
RELATIVE_OID_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_RELATIVE_OID_tags,
|
||||
sizeof(asn1_DEF_RELATIVE_OID_tags)
|
||||
|
@ -32,12 +35,39 @@ asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID = {
|
|||
0 /* No specifics */
|
||||
};
|
||||
|
||||
static ssize_t
|
||||
RELATIVE_OID__dump_body(const RELATIVE_OID_t *st, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
ssize_t wrote = 0;
|
||||
ssize_t ret;
|
||||
int startn;
|
||||
int i;
|
||||
|
||||
for(i = 0, startn = 0; i < st->size; i++) {
|
||||
uint8_t b = st->buf[i];
|
||||
if((b & 0x80)) /* Continuation expected */
|
||||
continue;
|
||||
if(startn) {
|
||||
/* Separate arcs */
|
||||
if(cb(".", 1, app_key) < 0)
|
||||
return -1;
|
||||
wrote++;
|
||||
}
|
||||
|
||||
ret = OBJECT_IDENTIFIER__dump_arc(&st->buf[startn],
|
||||
i - startn + 1, 0, cb, app_key);
|
||||
if(ret < 0) return -1;
|
||||
wrote += ret;
|
||||
|
||||
startn = i + 1;
|
||||
}
|
||||
|
||||
return wrote;
|
||||
}
|
||||
|
||||
int
|
||||
RELATIVE_OID_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
|
||||
int startn;
|
||||
int i;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
@ -49,21 +79,30 @@ RELATIVE_OID_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
if(cb("{ ", 2, app_key))
|
||||
return -1;
|
||||
|
||||
for(i = 0, startn = 0; i < st->size; i++) {
|
||||
uint8_t b = st->buf[i];
|
||||
if((b & 0x80)) /* Continuation expected */
|
||||
continue;
|
||||
if(startn && cb(" ", 1, app_key)) /* Separate arcs */
|
||||
return -1;
|
||||
if(OBJECT_IDENTIFIER_print_arc(&st->buf[startn],
|
||||
i - startn + 1, 0, cb, app_key))
|
||||
return -1;
|
||||
startn = i + 1;
|
||||
}
|
||||
if(RELATIVE_OID__dump_body(st, cb, app_key) < 0)
|
||||
return -1;
|
||||
|
||||
return cb(" }", 2, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
RELATIVE_OID_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
RELATIVE_OID_t *st = (RELATIVE_OID_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel; /* Unused argument */
|
||||
(void)flags; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = RELATIVE_OID__dump_body(st, cb, app_key);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
RELATIVE_OID_get_arcs(RELATIVE_OID_t *roid,
|
||||
|
|
|
@ -14,6 +14,7 @@ typedef OBJECT_IDENTIFIER_t RELATIVE_OID_t;
|
|||
extern asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID;
|
||||
|
||||
asn_struct_print_f RELATIVE_OID_print;
|
||||
xer_type_encoder_f RELATIVE_OID_encode_xer;
|
||||
|
||||
/**********************************
|
||||
* Some handy conversion routines *
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <T61String.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_T61String_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T61String = {
|
||||
"T61String",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
asn_generic_unknown_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer, /* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T61String_tags,
|
||||
sizeof(asn1_DEF_T61String_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <TeletexString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_TeletexString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_TeletexString = {
|
||||
"TeletexString",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
asn_generic_unknown_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer, /* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_TeletexString_tags,
|
||||
sizeof(asn1_DEF_TeletexString_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <UTCTime.h>
|
||||
#include <GeneralizedTime.h>
|
||||
#include <time.h>
|
||||
|
@ -18,11 +19,13 @@ static ber_tlv_tag_t asn1_DEF_UTCTime_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_UTCTime = {
|
||||
"UTCTime",
|
||||
OCTET_STRING_free,
|
||||
UTCTime_print,
|
||||
UTCTime_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
UTCTime_print,
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
UTCTime_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_UTCTime_tags,
|
||||
sizeof(asn1_DEF_UTCTime_tags)
|
||||
|
@ -58,6 +61,36 @@ UTCTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
UTCTime_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
OCTET_STRING_t st;
|
||||
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
char buf[32];
|
||||
struct tm tm;
|
||||
ssize_t ret;
|
||||
|
||||
errno = EPERM;
|
||||
if(asn_UT2time((UTCTime_t *)sptr, &tm, 1) == -1
|
||||
&& errno != EPERM)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
ret = snprintf(buf, sizeof(buf), "%02d%02d%02d%02d%02d%02dZ",
|
||||
tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
assert(ret > 0 && ret < (int)sizeof(buf));
|
||||
|
||||
st.buf = (uint8_t *)buf;
|
||||
st.size = ret;
|
||||
sptr = &st;
|
||||
}
|
||||
|
||||
return OCTET_STRING_encode_xer_ascii(td, sptr, ilevel, flags,
|
||||
cb, app_key);
|
||||
}
|
||||
|
||||
int
|
||||
UTCTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -12,8 +12,9 @@ typedef OCTET_STRING_t UTCTime_t; /* Implemented using OCTET STRING */
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_UTCTime;
|
||||
|
||||
asn_constr_check_f UTCTime_constraint;
|
||||
asn_struct_print_f UTCTime_print;
|
||||
asn_constr_check_f UTCTime_constraint;
|
||||
xer_type_encoder_f UTCTime_encode_xer;
|
||||
|
||||
/***********************
|
||||
* Some handy helpers. *
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <UTF8String.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_UTF8String_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_UTF8String = {
|
||||
"UTF8String",
|
||||
OCTET_STRING_free,
|
||||
UTF8String_print,
|
||||
UTF8String_constraint, /* Check for invalid codes, etc. */
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
UTF8String_print,
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer_ascii, /* Already in UTF-8 format */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_UTF8String_tags,
|
||||
sizeof(asn1_DEF_UTF8String_tags)
|
||||
|
|
|
@ -12,8 +12,8 @@ typedef OCTET_STRING_t UTF8String_t; /* Implemented in terms of OCTET STRING */
|
|||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_UTF8String;
|
||||
|
||||
asn_constr_check_f UTF8String_constraint;
|
||||
asn_struct_print_f UTF8String_print;
|
||||
asn_constr_check_f UTF8String_constraint;
|
||||
|
||||
/* Returns length of UTF-8 string in characters or -1 if error. */
|
||||
ssize_t UTF8String_length(const UTF8String_t *st, const char *opt_type_name,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <UniversalString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_UniversalString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_UniversalString = {
|
||||
"UniversalString",
|
||||
OCTET_STRING_free,
|
||||
UniversalString_print, /* Convert into UTF8 and print */
|
||||
asn_generic_no_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
UniversalString_print, /* Convert into UTF8 and print */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
UniversalString_encode_xer, /* Conver into UTF8 */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_UniversalString_tags,
|
||||
sizeof(asn1_DEF_UniversalString_tags)
|
||||
|
@ -31,29 +34,25 @@ asn1_TYPE_descriptor_t asn1_DEF_UniversalString = {
|
|||
};
|
||||
|
||||
|
||||
int
|
||||
UniversalString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
uint32_t *wchar;
|
||||
uint32_t *wend;
|
||||
static ssize_t
|
||||
UniversalString__dump(const UniversalString_t *st,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
char scratch[128]; /* Scratchpad buffer */
|
||||
char *p;
|
||||
char *p = scratch;
|
||||
ssize_t wrote = 0;
|
||||
uint8_t *ch;
|
||||
uint8_t *end;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf) return cb("<absent>", 8, app_key);
|
||||
|
||||
wchar = (uint32_t *)st->buf;
|
||||
wend = (uint32_t *)(st->buf + st->size);
|
||||
for(p = scratch; wchar < wend; wchar++) {
|
||||
uint32_t wc = (((uint8_t *)wchar)[0] << 24)
|
||||
| (((uint8_t *)wchar)[1] << 16)
|
||||
| (((uint8_t *)wchar)[2] << 8)
|
||||
| ((uint8_t *)wchar)[3]; /* 4 bytes */
|
||||
ch = st->buf;
|
||||
end = (st->buf + st->size);
|
||||
for(end -= 3; ch < end; ch += 4) {
|
||||
uint32_t wc = (ch[0] << 24)
|
||||
| (ch[1] << 16)
|
||||
| (ch[2] << 8)
|
||||
| ch[3]; /* 4 bytes */
|
||||
if(sizeof(scratch) - (p - scratch) < 6) {
|
||||
if(cb(scratch, p - scratch, app_key))
|
||||
wrote += p - scratch;
|
||||
if(cb(scratch, p - scratch, app_key) < 0)
|
||||
return -1;
|
||||
p = scratch;
|
||||
}
|
||||
|
@ -87,5 +86,45 @@ UniversalString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
}
|
||||
}
|
||||
|
||||
return cb(scratch, p - scratch, app_key);
|
||||
wrote += p - scratch;
|
||||
if(cb(scratch, p - scratch, app_key) < 0)
|
||||
return -1;
|
||||
|
||||
return wrote;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
UniversalString_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = UniversalString__dump(st, cb, app_key);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
UniversalString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(!st || !st->buf) return cb("<absent>", 8, app_key);
|
||||
|
||||
if(UniversalString__dump(st, cb, app_key) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _UniversalString_H_
|
||||
|
@ -13,5 +13,6 @@ typedef OCTET_STRING_t UniversalString_t; /* Implemented in terms of OCTET STRIN
|
|||
extern asn1_TYPE_descriptor_t asn1_DEF_UniversalString;
|
||||
|
||||
asn_struct_print_f UniversalString_print; /* Human-readable output */
|
||||
xer_type_encoder_f UniversalString_encode_xer;
|
||||
|
||||
#endif /* _UniversalString_H_ */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <VideotexString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_VideotexString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_VideotexString = {
|
||||
"VideotexString",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
asn_generic_unknown_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print, /* non-ascii string */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer, /* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_VideotexString_tags,
|
||||
sizeof(asn1_DEF_VideotexString_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <VisibleString.h>
|
||||
|
||||
/*
|
||||
|
@ -13,11 +14,13 @@ static ber_tlv_tag_t asn1_DEF_VisibleString_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_VisibleString = {
|
||||
"VisibleString",
|
||||
OCTET_STRING_free,
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
VisibleString_constraint,
|
||||
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
|
||||
OCTET_STRING_print_ascii, /* ASCII subset */
|
||||
OCTET_STRING_free,
|
||||
0, /* Not implemented yet */
|
||||
OCTET_STRING_encode_xer_ascii,/* Implemented in terms of OCTET STRING */
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_VisibleString_tags,
|
||||
sizeof(asn1_DEF_VisibleString_tags)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <asn_types.h> /* for MALLOC/REALLOC/FREEMEM */
|
||||
#include <asn_SEQUENCE_OF.h>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <asn_types.h> /* for MALLOC/REALLOC/FREEMEM */
|
||||
#include <asn_SET_OF.h>
|
||||
#include <errno.h>
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
/*
|
||||
* Declarations internally useful for the ASN.1 support code.
|
||||
*/
|
||||
#ifndef _ASN_INTERNAL_H_
|
||||
#define _ASN_INTERNAL_H_
|
||||
|
||||
#define ASN1C_ENVIRONMENT_VERSION 96 /* Compile-time version */
|
||||
int get_asn1c_environment_version(void); /* Run-time version */
|
||||
|
||||
#include <asn_types.h>
|
||||
#include <constr_TYPE.h>
|
||||
|
||||
#define CALLOC(nmemb, size) calloc(nmemb, size)
|
||||
#define MALLOC(size) malloc(size)
|
||||
#define REALLOC(oldptr, size) realloc(oldptr, size)
|
||||
#define FREEMEM(ptr) free(ptr)
|
||||
|
||||
/*
|
||||
* A macro for debugging the ASN.1 internals.
|
||||
* You may enable or override it.
|
||||
*/
|
||||
#ifndef ASN_DEBUG /* If debugging code is not defined elsewhere... */
|
||||
#if EMIT_ASN_DEBUG == 1 /* And it was asked to emit this code... */
|
||||
#ifdef __GNUC__
|
||||
#define ASN_DEBUG(fmt, args...) do { \
|
||||
fprintf(stderr, fmt, ##args); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while(0)
|
||||
#else /* !__GNUC__ */
|
||||
extern void ASN_DEBUG_f(const char *fmt, ...);
|
||||
#define ASN_DEBUG ASN_DEBUG_f
|
||||
#endif /* __GNUC__ */
|
||||
#else /* EMIT_ASN_DEBUG != 1 */
|
||||
#ifdef __GNUC__
|
||||
#define ASN_DEBUG(fmt, args...) ((void)0) /* Emit a no-op operator */
|
||||
#else /* __GNUC__ */
|
||||
static void ASN_DEBUG(const char *fmt, ...) { (void)fmt; };
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* EMIT_ASN_DEBUG */
|
||||
#endif /* ASN_DEBUG */
|
||||
|
||||
/*
|
||||
* Invoke the application-supplied callback and fail, if something is wrong.
|
||||
*/
|
||||
#define __ASN_E_cbc(buf, size) (cb((buf), (size), app_key) == -1)
|
||||
#define _ASN_E_CALLBACK(foo) do { \
|
||||
if(foo) _ASN_ENCODE_FAILED; \
|
||||
} while(0)
|
||||
#define _ASN_CALLBACK(buf, size) \
|
||||
_ASN_E_CALLBACK(__ASN_E_cbc(buf, size))
|
||||
#define _ASN_CALLBACK2(buf1, size1, buf2, size2) \
|
||||
_ASN_E_CALLBACK(__ASN_E_cbc(buf1, size1) || __ASN_E_cbc(buf2, size2))
|
||||
#define _ASN_CALLBACK3(buf1, size1, buf2, size2, buf3, size3) \
|
||||
_ASN_E_CALLBACK(__ASN_E_cbc(buf1, size1) \
|
||||
|| __ASN_E_cbc(buf2, size2) \
|
||||
|| __ASN_E_cbc(buf3, size3))
|
||||
|
||||
#define _i_ASN_TEXT_INDENT(nl, level) do { \
|
||||
int __level = (level); \
|
||||
int __nl = ((nl) != 0); \
|
||||
int __i; \
|
||||
if(__nl) _ASN_CALLBACK("\n", 1); \
|
||||
for(__i = 0; __i < __level; __i++) \
|
||||
_ASN_CALLBACK(" ", 4); \
|
||||
er.encoded += __nl + 4 * __level; \
|
||||
} while(0)
|
||||
|
||||
#endif /* _ASN_INTERNAL_H_ */
|
|
@ -43,11 +43,6 @@
|
|||
#define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0))
|
||||
#endif /* offsetof */
|
||||
|
||||
#define CALLOC(nmemb, size) calloc(nmemb, size)
|
||||
#define MALLOC(size) malloc(size)
|
||||
#define REALLOC(oldptr, size) realloc(oldptr, size)
|
||||
#define FREEMEM(ptr) free(ptr)
|
||||
|
||||
#ifndef MIN /* Suitable for comparing primitive types (integers) */
|
||||
#if defined(__GNUC__)
|
||||
#define MIN(a,b) ({ __typeof a _a = a; __typeof b _b = b; \
|
||||
|
@ -57,31 +52,6 @@
|
|||
#endif /* __GNUC__ */
|
||||
#endif /* MIN */
|
||||
|
||||
/*
|
||||
* A macro for debugging the ASN.1 internals.
|
||||
* You may enable or override it.
|
||||
*/
|
||||
#ifndef ASN_DEBUG /* If debugging code is not defined elsewhere... */
|
||||
#if EMIT_ASN_DEBUG == 1 /* And it was asked to emit this code... */
|
||||
#ifdef __GNUC__
|
||||
#define ASN_DEBUG(fmt, args...) do { \
|
||||
fprintf(stderr, fmt, ##args); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while(0)
|
||||
#else /* !__GNUC__ */
|
||||
extern void ASN_DEBUG_f(const char *fmt, ...);
|
||||
#define ASN_DEBUG ASN_DEBUG_f
|
||||
#endif /* __GNUC__ */
|
||||
#else /* EMIT_ASN_DEBUG != 1 */
|
||||
#ifdef __GNUC__
|
||||
#define ASN_DEBUG(fmt, args...) ((void)0) /* Emit a no-op operator */
|
||||
#else /* __GNUC__ */
|
||||
static void ASN_DEBUG(const char *fmt, ...) { (void)fmt; };
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* EMIT_ASN_DEBUG */
|
||||
#endif /* ASN_DEBUG */
|
||||
|
||||
|
||||
/*
|
||||
* Generic type of an application-defined callback to return various
|
||||
* types of data to the application.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_TYPE.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_TYPE.h>
|
||||
#include <ber_tlv_length.h>
|
||||
#include <ber_tlv_tag.h>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_TYPE.h>
|
||||
#include <ber_tlv_tag.h>
|
||||
#include <errno.h>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_CHOICE.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -348,14 +349,14 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
RETURN(RC_OK);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
CHOICE_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
|
||||
asn1_TYPE_member_t *elm; /* CHOICE element */
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
void *memb_ptr;
|
||||
size_t computed_size = 0;
|
||||
int present;
|
||||
|
@ -536,6 +537,57 @@ CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
}
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
CHOICE_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_CHOICE_specifics_t *specs=(asn1_CHOICE_specifics_t *)td->specifics;
|
||||
asn_enc_rval_t er;
|
||||
int present;
|
||||
|
||||
if(!sptr)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
/*
|
||||
* Figure out which CHOICE element is encoded.
|
||||
*/
|
||||
present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
|
||||
|
||||
if(present <= 0 || present > td->elements_count) {
|
||||
_ASN_ENCODE_FAILED;
|
||||
} else {
|
||||
asn_enc_rval_t tmper;
|
||||
asn1_TYPE_member_t *elm = &td->elements[present-1];
|
||||
void *memb_ptr;
|
||||
const char *mname = elm->name;
|
||||
unsigned int mlen = strlen(mname);
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) _ASN_ENCODE_FAILED;
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
if(!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
|
||||
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
@ -550,7 +602,7 @@ CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
|
||||
|
||||
/*
|
||||
* Free that element.
|
||||
* Print that element.
|
||||
*/
|
||||
if(present > 0 && present <= td->elements_count) {
|
||||
asn1_TYPE_member_t *elm = &td->elements[present-1];
|
||||
|
|
|
@ -31,11 +31,12 @@ typedef struct asn1_CHOICE_specifics_s {
|
|||
/*
|
||||
* A set specialized functions dealing with the CHOICE type.
|
||||
*/
|
||||
asn_struct_free_f CHOICE_free;
|
||||
asn_struct_print_f CHOICE_print;
|
||||
asn_constr_check_f CHOICE_constraint;
|
||||
ber_type_decoder_f CHOICE_decode_ber;
|
||||
der_type_encoder_f CHOICE_encode_der;
|
||||
xer_type_encoder_f CHOICE_encode_xer;
|
||||
asn_outmost_tag_f CHOICE_outmost_tag;
|
||||
asn_struct_print_f CHOICE_print;
|
||||
asn_struct_free_f CHOICE_free;
|
||||
|
||||
#endif /* _CONSTR_CHOICE_H_ */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_SEQUENCE.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -490,12 +491,12 @@ SEQUENCE_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* The DER encoder of the SEQUENCE type.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *ptr, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t computed_size = 0;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
ssize_t ret;
|
||||
int edx;
|
||||
|
||||
|
@ -544,7 +545,7 @@ SEQUENCE_encode_der(asn1_TYPE_descriptor_t *td,
|
|||
*/
|
||||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn1_TYPE_member_t *elm = &td->elements[edx];
|
||||
der_enc_rval_t tmperval;
|
||||
asn_enc_rval_t tmperval;
|
||||
void *memb_ptr;
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
|
@ -575,6 +576,50 @@ SEQUENCE_encode_der(asn1_TYPE_descriptor_t *td,
|
|||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
int edx;
|
||||
|
||||
if(!sptr)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn_enc_rval_t tmper;
|
||||
asn1_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr;
|
||||
const char *mname = elm->name;
|
||||
unsigned int mlen = strlen(mname);
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) continue; /* OPTIONAL element? */
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
||||
/* Print the member itself */
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
SEQUENCE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -31,10 +31,11 @@ typedef struct asn1_SEQUENCE_specifics_s {
|
|||
/*
|
||||
* A set specialized functions dealing with the SEQUENCE type.
|
||||
*/
|
||||
asn_struct_free_f SEQUENCE_free;
|
||||
asn_struct_print_f SEQUENCE_print;
|
||||
asn_constr_check_f SEQUENCE_constraint;
|
||||
ber_type_decoder_f SEQUENCE_decode_ber;
|
||||
der_type_encoder_f SEQUENCE_encode_der;
|
||||
asn_struct_print_f SEQUENCE_print;
|
||||
asn_struct_free_f SEQUENCE_free;
|
||||
xer_type_encoder_f SEQUENCE_encode_xer;
|
||||
|
||||
#endif /* _CONSTR_SEQUENCE_H_ */
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_SEQUENCE_OF.h>
|
||||
#include <asn_SEQUENCE_OF.h>
|
||||
|
||||
/*
|
||||
* The DER encoder of the SEQUENCE OF type.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
@ -16,7 +17,7 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
A_SEQUENCE_OF(void) *list;
|
||||
size_t computed_size = 0;
|
||||
ssize_t encoding_size = 0;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
int edx;
|
||||
|
||||
ASN_DEBUG("Estimating size of SEQUENCE OF %s", td->name);
|
||||
|
@ -82,3 +83,50 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_OF_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)td->specifics;
|
||||
asn1_TYPE_member_t *element = td->elements;
|
||||
A_SEQUENCE_OF(void) *list;
|
||||
const char *mname = specs->as_XMLValueList
|
||||
? 0 : ((*element->name) ? element->name : element->type->name);
|
||||
unsigned int mlen = mname ? strlen(mname) : 0;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
int i;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
(void *)list = sptr;
|
||||
for(i = 0; i < list->count; i++) {
|
||||
asn_enc_rval_t tmper;
|
||||
|
||||
void *memb_ptr = list->array[i];
|
||||
if(!memb_ptr) continue;
|
||||
|
||||
if(mname) {
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
}
|
||||
|
||||
tmper = element->type->xer_encoder(element->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
if(mname) {
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
er.encoded += 5;
|
||||
}
|
||||
|
||||
er.encoded += (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
* A set specialized functions dealing with the SEQUENCE OF type.
|
||||
* Implemented using SET OF.
|
||||
*/
|
||||
#define SEQUENCE_OF_free SET_OF_free
|
||||
#define SEQUENCE_OF_print SET_OF_print
|
||||
#define SEQUENCE_OF_constraint SET_OF_constraint
|
||||
#define SEQUENCE_OF_decode_ber SET_OF_decode_ber
|
||||
der_type_encoder_f SEQUENCE_OF_encode_der;
|
||||
#define SEQUENCE_OF_print SET_OF_print
|
||||
#define SEQUENCE_OF_free SET_OF_free
|
||||
xer_type_encoder_f SEQUENCE_OF_encode_xer;
|
||||
|
||||
#endif /* _CONSTR_SET_OF_H_ */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_SET.h>
|
||||
#include <assert.h> /* for assert() */
|
||||
|
||||
|
@ -430,13 +431,13 @@ SET_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* The DER encoder of the SET type.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
SET_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *ptr, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)td->specifics;
|
||||
size_t computed_size = 0;
|
||||
der_enc_rval_t my_erval;
|
||||
asn_enc_rval_t my_erval;
|
||||
int t2m_build_own = (specs->tag2el_count != td->elements_count);
|
||||
asn1_TYPE_tag2member_t *t2m;
|
||||
int t2m_count;
|
||||
|
@ -469,7 +470,7 @@ SET_encode_der(asn1_TYPE_descriptor_t *td,
|
|||
*/
|
||||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn1_TYPE_member_t *elm = &td->elements[edx];
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
void *memb_ptr;
|
||||
|
||||
/*
|
||||
|
@ -545,7 +546,7 @@ SET_encode_der(asn1_TYPE_descriptor_t *td,
|
|||
*/
|
||||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn1_TYPE_member_t *elm;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
void *memb_ptr;
|
||||
|
||||
/* Encode according to the tag order */
|
||||
|
@ -577,6 +578,52 @@ SET_encode_der(asn1_TYPE_descriptor_t *td,
|
|||
return my_erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SET_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
int edx;
|
||||
|
||||
if(!sptr)
|
||||
_ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn_enc_rval_t tmper;
|
||||
asn1_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr;
|
||||
const char *mname = elm->name;
|
||||
unsigned int mlen = strlen(elm->name);
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) continue; /* OPTIONAL element? */
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
if(!xcan)
|
||||
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
||||
/* Print the member itself */
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
|
||||
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -32,11 +32,12 @@ typedef struct asn1_SET_specifics_s {
|
|||
/*
|
||||
* A set specialized functions dealing with the SET type.
|
||||
*/
|
||||
asn_struct_free_f SET_free;
|
||||
asn_struct_print_f SET_print;
|
||||
asn_constr_check_f SET_constraint;
|
||||
ber_type_decoder_f SET_decode_ber;
|
||||
der_type_encoder_f SET_encode_der;
|
||||
asn_struct_print_f SET_print;
|
||||
asn_struct_free_f SET_free;
|
||||
xer_type_encoder_f SET_encode_xer;
|
||||
|
||||
/***********************
|
||||
* Some handy helpers. *
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_SET_OF.h>
|
||||
#include <asn_SET_OF.h>
|
||||
|
||||
|
@ -304,7 +305,7 @@ static int _el_buf_cmp(const void *ap, const void *bp) {
|
|||
/*
|
||||
* The DER encoder of the SET OF type.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
SET_OF_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
@ -316,7 +317,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
ssize_t encoding_size = 0;
|
||||
struct _el_buffer *encoded_els;
|
||||
size_t max_encoded_len = 1;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
int ret;
|
||||
int edx;
|
||||
|
||||
|
@ -444,6 +445,53 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SET_OF_encode_xer(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
asn1_SET_OF_specifics_t *specs=(asn1_SET_OF_specifics_t *)td->specifics;
|
||||
asn1_TYPE_member_t *element = td->elements;
|
||||
A_SET_OF(void) *list;
|
||||
const char *mname = specs->as_XMLValueList
|
||||
? 0 : ((*element->name) ? element->name : element->type->name);
|
||||
size_t mlen = mname ? strlen(mname) : 0;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
int i;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
(void *)list = sptr;
|
||||
for(i = 0; i < list->count; i++) {
|
||||
asn_enc_rval_t tmper;
|
||||
|
||||
void *memb_ptr = list->array[i];
|
||||
if(!memb_ptr) continue;
|
||||
|
||||
if(mname) {
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
}
|
||||
|
||||
tmper = element->type->xer_encoder(element->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
if(mname) {
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
er.encoded += 5;
|
||||
}
|
||||
|
||||
er.encoded += (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
int
|
||||
SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -13,15 +13,19 @@ typedef struct asn1_SET_OF_specifics_s {
|
|||
*/
|
||||
int struct_size; /* Size of the target structure. */
|
||||
int ctx_offset; /* Offset of the ber_dec_ctx_t member */
|
||||
|
||||
/* XER-specific stuff */
|
||||
int as_XMLValueList; /* The member type must be encoded like this */
|
||||
} asn1_SET_OF_specifics_t;
|
||||
|
||||
/*
|
||||
* A set specialized functions dealing with the SET OF type.
|
||||
*/
|
||||
asn_struct_free_f SET_OF_free;
|
||||
asn_struct_print_f SET_OF_print;
|
||||
asn_constr_check_f SET_OF_constraint;
|
||||
ber_type_decoder_f SET_OF_decode_ber;
|
||||
der_type_encoder_f SET_OF_encode_der;
|
||||
asn_struct_print_f SET_OF_print;
|
||||
asn_struct_free_f SET_OF_free;
|
||||
xer_type_encoder_f SET_OF_encode_xer;
|
||||
|
||||
#endif /* _CONSTR_SET_OF_H_ */
|
||||
|
|
|
@ -2,9 +2,15 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_TYPE.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
* Version of the ASN.1 infrastructure shipped with compiler.
|
||||
*/
|
||||
int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
|
||||
|
||||
static asn_app_consume_bytes_f _print2fp;
|
||||
|
||||
/*
|
||||
|
|
|
@ -2,19 +2,53 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _CONSTR_TYPE_H_
|
||||
#define _CONSTR_TYPE_H_
|
||||
/*
|
||||
* This file contains the declaration structure called "ASN.1 Type Definition",
|
||||
* which holds all information necessary for encoding and decoding routines.
|
||||
* This structure even contains pointer to these encoding and decoding routines
|
||||
* for each defined ASN.1 type.
|
||||
*/
|
||||
#ifndef _CONSTR_TYPE_H
|
||||
#define _CONSTR_TYPE_H
|
||||
|
||||
#include <asn_types.h> /* System-dependent types */
|
||||
|
||||
struct asn1_TYPE_descriptor_s; /* Forward declaration */
|
||||
struct asn1_TYPE_member_s; /* Forward declaration */
|
||||
|
||||
/*
|
||||
* Type of the return value of the encoding functions (der_encode, xer_encode).
|
||||
*/
|
||||
typedef struct asn_enc_rval_s {
|
||||
/*
|
||||
* Number of bytes encoded.
|
||||
* -1 indicates failure to encode the structure.
|
||||
* In this case, the members below this one are meaningful.
|
||||
*/
|
||||
ssize_t encoded;
|
||||
|
||||
/*
|
||||
* Members meaningful when (encoded == -1), for post mortem analysis.
|
||||
*/
|
||||
|
||||
/* Type which cannot be encoded */
|
||||
struct asn1_TYPE_descriptor_s *failed_type;
|
||||
|
||||
/* Pointer to the structure of that type */
|
||||
void *structure_ptr;
|
||||
} asn_enc_rval_t;
|
||||
#define _ASN_ENCODE_FAILED do { \
|
||||
asn_enc_rval_t __er = { -1, td, sptr }; \
|
||||
return __er; \
|
||||
} while(0)
|
||||
|
||||
#include <ber_tlv_length.h>
|
||||
#include <ber_tlv_tag.h>
|
||||
#include <ber_decoder.h>
|
||||
#include <der_encoder.h>
|
||||
#include <xer_encoder.h>
|
||||
#include <constraints.h>
|
||||
|
||||
struct asn1_TYPE_descriptor_s; /* Forward declaration */
|
||||
struct asn1_TYPE_member_s; /* Forward declaration */
|
||||
|
||||
/*
|
||||
* Free the structure according to its specification.
|
||||
* If (free_contents_only) is set, the wrapper structure itself (struct_ptr)
|
||||
|
@ -58,11 +92,13 @@ typedef struct asn1_TYPE_descriptor_s {
|
|||
* Generalized functions for dealing with the specific type.
|
||||
* May be directly invoked by applications.
|
||||
*/
|
||||
asn_struct_free_f *free_struct; /* Free the structure */
|
||||
asn_struct_print_f *print_struct; /* Human readable output */
|
||||
asn_constr_check_f *check_constraints; /* Constraints validator */
|
||||
ber_type_decoder_f *ber_decoder; /* Free-form BER decoder */
|
||||
der_type_encoder_f *der_encoder; /* Canonical DER encoder */
|
||||
asn_struct_print_f *print_struct; /* Human readable output */
|
||||
asn_struct_free_f *free_struct; /* Free the structure */
|
||||
int (*xer_decoder);/* PLACEHOLDER */ /* Free-form XER decoder */
|
||||
xer_type_encoder_f *xer_encoder; /* [Canonical] XER encoder */
|
||||
|
||||
/*
|
||||
* Functions used internally. Should not be used by applications.
|
||||
|
@ -129,6 +165,7 @@ typedef struct asn1_TYPE_tag2member_s {
|
|||
* RETURN VALUES:
|
||||
* 0: The structure is printed.
|
||||
* -1: Problem dumping the structure.
|
||||
* (See also xer_fprint() in xer_encoder.h)
|
||||
*/
|
||||
int asn_fprint(FILE *stream, /* Destination stream descriptor */
|
||||
asn1_TYPE_descriptor_t *td, /* ASN.1 type descriptor */
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <asn_internal.h>
|
||||
#include <constraints.h>
|
||||
#include <constr_TYPE.h>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_TYPE.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
@ -12,7 +13,7 @@ static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len,
|
|||
/*
|
||||
* The DER encoder of any type.
|
||||
*/
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
der_encode(asn1_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
|
||||
asn_app_consume_bytes_f *consume_bytes, void *app_key) {
|
||||
|
||||
|
|
|
@ -9,33 +9,10 @@
|
|||
|
||||
struct asn1_TYPE_descriptor_s; /* Forward declaration */
|
||||
|
||||
/*
|
||||
* Type of the return value of the der_encode function.
|
||||
*/
|
||||
typedef struct der_enc_rval_s {
|
||||
/*
|
||||
* Number of bytes encoded.
|
||||
* -1 indicates failure to encode the structure.
|
||||
* In this case, the members below this one are meaningful.
|
||||
*/
|
||||
ssize_t encoded;
|
||||
|
||||
/*
|
||||
* Members meaningful when (encoded == -1), for post-mortem analysis.
|
||||
*/
|
||||
|
||||
/* Type which cannot be encoded */
|
||||
struct asn1_TYPE_descriptor_s *failed_type;
|
||||
|
||||
/* Pointer to the structure of that type */
|
||||
void *structure_ptr;
|
||||
} der_enc_rval_t;
|
||||
|
||||
|
||||
/*
|
||||
* The DER encoder of any type. May be invoked by the application.
|
||||
*/
|
||||
der_enc_rval_t der_encode(struct asn1_TYPE_descriptor_s *type_descriptor,
|
||||
asn_enc_rval_t der_encode(struct asn1_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
asn_app_consume_bytes_f *consume_bytes_cb,
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
|
@ -44,7 +21,7 @@ der_enc_rval_t der_encode(struct asn1_TYPE_descriptor_s *type_descriptor,
|
|||
/*
|
||||
* Type of the generic DER encoder.
|
||||
*/
|
||||
typedef der_enc_rval_t (der_type_encoder_f)(
|
||||
typedef asn_enc_rval_t (der_type_encoder_f)(
|
||||
struct asn1_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
|
||||
|
|
|
@ -44,6 +44,7 @@ constr_SET_OF.h constr_SET_OF.c asn_SET_OF.h
|
|||
|
||||
COMMON-FILES: # This is a special section
|
||||
asn_types.h
|
||||
asn_internal.h
|
||||
OCTET_STRING.h OCTET_STRING.c # This one is used too widely
|
||||
ber_decoder.h ber_decoder.c
|
||||
ber_tlv_length.h ber_tlv_length.c
|
||||
|
@ -51,3 +52,4 @@ ber_tlv_tag.h ber_tlv_tag.c
|
|||
constr_TYPE.h constr_TYPE.c
|
||||
constraints.h constraints.c
|
||||
der_encoder.h der_encoder.c
|
||||
xer_encoder.h xer_encoder.c
|
||||
|
|
|
@ -97,9 +97,9 @@ main(int ac, char **av) {
|
|||
* Dummy function.
|
||||
*/
|
||||
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
(void)td;
|
||||
(void)ptr;
|
||||
|
@ -110,3 +110,17 @@ OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber
|
|||
|
||||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_xer_ascii(asn1_TYPE_descriptor_t *td, void *ptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
(void)td;
|
||||
(void)ptr;
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
(void)cb;
|
||||
(void)app_key;
|
||||
|
||||
return erval;
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ main(int ac, char **av) {
|
|||
* Dummy function.
|
||||
*/
|
||||
|
||||
der_enc_rval_t
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
(void)td;
|
||||
(void)ptr;
|
||||
|
@ -77,3 +77,17 @@ OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber
|
|||
|
||||
return erval;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_xer_ascii(asn1_TYPE_descriptor_t *td, void *ptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
(void)td;
|
||||
(void)ptr;
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
(void)cb;
|
||||
(void)app_key;
|
||||
|
||||
return erval;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ static void
|
|||
check(int size) {
|
||||
OCTET_STRING_t *os;
|
||||
OCTET_STRING_t *nos = 0;
|
||||
der_enc_rval_t erval;
|
||||
asn_enc_rval_t erval;
|
||||
ber_dec_rval_t rval;
|
||||
int i;
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
#include <constr_TYPE.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
* The XER encoder of any type. May be invoked by the application.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
xer_encode(asn1_TYPE_descriptor_t *td, void *sptr,
|
||||
enum xer_encoder_flags_e xer_flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er, tmper;
|
||||
const char *mname;
|
||||
size_t mlen;
|
||||
int xcan = (xer_flags & XER_F_CANONICAL) ? 1 : 2;
|
||||
|
||||
if(!td || !sptr) {
|
||||
er.encoded = -1;
|
||||
er.failed_type = td;
|
||||
er.structure_ptr = sptr;
|
||||
return er;
|
||||
}
|
||||
|
||||
mname = td->name;
|
||||
mlen = strlen(mname);
|
||||
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
||||
tmper = td->xer_encoder(td, sptr, 1, xer_flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
_ASN_CALLBACK3("</", xcan, mname, mlen, ">\n",xcan);
|
||||
|
||||
er.encoded = 2 + (2 * xcan) + (2 * mlen) + tmper.encoded;
|
||||
|
||||
return er;
|
||||
}
|
||||
|
||||
static int _print2fp(const void *buffer, size_t size, void *app_key);
|
||||
|
||||
int
|
||||
xer_fprint(FILE *stream, asn1_TYPE_descriptor_t *td, void *sptr) {
|
||||
asn_enc_rval_t er;
|
||||
|
||||
if(!stream) stream = stdout;
|
||||
if(!td || !sptr)
|
||||
return -1;
|
||||
|
||||
er = xer_encode(td, sptr, XER_F_BASIC, _print2fp, stream);
|
||||
if(er.encoded == -1)
|
||||
return -1;
|
||||
|
||||
return fflush(stream);
|
||||
}
|
||||
|
||||
static int
|
||||
_print2fp(const void *buffer, size_t size, void *app_key) {
|
||||
FILE *stream = (FILE *)app_key;
|
||||
|
||||
if(fwrite(buffer, 1, size, stream) != size)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _XER_ENCODER_H_
|
||||
#define _XER_ENCODER_H_
|
||||
|
||||
#include <constr_TYPE.h>
|
||||
|
||||
struct asn1_TYPE_descriptor_s; /* Forward declaration */
|
||||
|
||||
/* Flags used by the xer_encode() and (*xer_type_encoder_f), defined below */
|
||||
enum xer_encoder_flags_e {
|
||||
/* Mode of encoding */
|
||||
XER_F_BASIC = 0x01, /* BASIC-XER (pretty-printing) */
|
||||
XER_F_CANONICAL = 0x02, /* Canonical XER (strict rules, unreadable) */
|
||||
};
|
||||
|
||||
/*
|
||||
* The XER encoder of any type. May be invoked by the application.
|
||||
*/
|
||||
asn_enc_rval_t xer_encode(struct asn1_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
enum xer_encoder_flags_e xer_flags,
|
||||
asn_app_consume_bytes_f *consume_bytes_cb,
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
|
||||
/*
|
||||
* The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)
|
||||
* output into the chosen file pointer.
|
||||
* RETURN VALUES:
|
||||
* 0: The structure is printed.
|
||||
* -1: Problem printing the structure.
|
||||
* WARNING: No sensible errno value is returned.
|
||||
*/
|
||||
int xer_fprint(FILE *stream, struct asn1_TYPE_descriptor_s *td, void *sptr);
|
||||
|
||||
/*
|
||||
* Type of the generic XER encoder.
|
||||
*/
|
||||
typedef asn_enc_rval_t (xer_type_encoder_f)(
|
||||
struct asn1_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
int ilevel, /* Level of indentation */
|
||||
enum xer_encoder_flags_e xer_flags,
|
||||
asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
|
||||
#endif /* _XER_ENCODER_H_ */
|
|
@ -108,11 +108,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_toBeSigned_specs = {
|
|||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_toBeSigned = {
|
||||
"toBeSigned",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_toBeSigned_tags,
|
||||
sizeof(asn1_DEF_toBeSigned_tags)
|
||||
|
@ -167,11 +169,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_Certificate_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Certificate = {
|
||||
"Certificate",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Certificate_tags,
|
||||
sizeof(asn1_DEF_Certificate_tags)
|
||||
|
@ -223,14 +227,17 @@ static ber_tlv_tag_t asn1_DEF_Name_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_Name_specs = {
|
||||
sizeof(struct Name),
|
||||
offsetof(struct Name, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Name = {
|
||||
"Name",
|
||||
SEQUENCE_OF_free,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_constraint,
|
||||
SEQUENCE_OF_decode_ber,
|
||||
SEQUENCE_OF_encode_der,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Name_tags,
|
||||
sizeof(asn1_DEF_Name_tags)
|
||||
|
@ -337,14 +344,17 @@ static ber_tlv_tag_t asn1_DEF_RelativeDistinguishedName_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_RelativeDistinguishedName_specs = {
|
||||
sizeof(struct RelativeDistinguishedName),
|
||||
offsetof(struct RelativeDistinguishedName, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_RelativeDistinguishedName = {
|
||||
"RelativeDistinguishedName",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_RelativeDistinguishedName_tags,
|
||||
sizeof(asn1_DEF_RelativeDistinguishedName_tags)
|
||||
|
|
|
@ -36,14 +36,17 @@ static ber_tlv_tag_t asn1_DEF_Forest_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_Forest_specs = {
|
||||
sizeof(struct Forest),
|
||||
offsetof(struct Forest, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Forest = {
|
||||
"Forest",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Forest_tags,
|
||||
sizeof(asn1_DEF_Forest_tags)
|
||||
|
@ -113,11 +116,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_Tree_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Tree = {
|
||||
"Tree",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Tree_tags,
|
||||
sizeof(asn1_DEF_Tree_tags)
|
||||
|
@ -205,15 +210,18 @@ static ber_tlv_tag_t asn1_DEF_trees_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_trees_specs = {
|
||||
sizeof(struct trees),
|
||||
offsetof(struct trees, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_trees = {
|
||||
"trees",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_trees_tags,
|
||||
sizeof(asn1_DEF_trees_tags)
|
||||
|
@ -253,11 +261,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_anything_member_specs = {
|
|||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_anything_member = {
|
||||
"",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_anything_member_tags,
|
||||
sizeof(asn1_DEF_anything_member_tags)
|
||||
|
@ -287,15 +297,18 @@ static ber_tlv_tag_t asn1_DEF_anything_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_anything_specs = {
|
||||
sizeof(struct anything),
|
||||
offsetof(struct anything, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_anything = {
|
||||
"anything",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_anything_tags,
|
||||
sizeof(asn1_DEF_anything_tags)
|
||||
|
@ -346,11 +359,13 @@ static asn1_SET_specifics_t asn1_DEF_Stuff_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Stuff = {
|
||||
"Stuff",
|
||||
SET_free,
|
||||
SET_print,
|
||||
SET_constraint,
|
||||
SET_decode_ber,
|
||||
SET_encode_der,
|
||||
SET_print,
|
||||
SET_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Stuff_tags,
|
||||
sizeof(asn1_DEF_Stuff_tags)
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
|
||||
/*** <<< INCLUDES [Programming] >>> ***/
|
||||
|
||||
#include <Fault.h>
|
||||
#include <asn_SEQUENCE_OF.h>
|
||||
#include <constr_SEQUENCE_OF.h>
|
||||
|
||||
/*** <<< DEPS [Programming] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_Programming;
|
||||
|
||||
/*** <<< TYPE-DECLS [Programming] >>> ***/
|
||||
|
||||
|
||||
typedef struct Programming {
|
||||
A_SEQUENCE_OF(Fault_t) list;
|
||||
|
||||
/* Context for parsing across buffer boundaries */
|
||||
ber_dec_ctx_t _ber_dec_ctx;
|
||||
} Programming_t;
|
||||
|
||||
/*** <<< STAT-DEFS [Programming] >>> ***/
|
||||
|
||||
static asn1_TYPE_member_t asn1_MBR_Programming[] = {
|
||||
{ ATF_NOFLAGS, 0, 0,
|
||||
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
|
||||
.tag_mode = -1, /* IMPLICIT tag at current level */
|
||||
.type = (void *)&asn1_DEF_Fault,
|
||||
.memb_constraints = 0, /* Defer to actual type */
|
||||
.name = ""
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn1_DEF_Programming_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn1_SET_OF_specifics_t asn1_DEF_Programming_specs = {
|
||||
sizeof(struct Programming),
|
||||
offsetof(struct Programming, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Programming = {
|
||||
"Programming",
|
||||
SEQUENCE_OF_free,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_constraint,
|
||||
SEQUENCE_OF_decode_ber,
|
||||
SEQUENCE_OF_encode_der,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Programming_tags,
|
||||
sizeof(asn1_DEF_Programming_tags)
|
||||
/sizeof(asn1_DEF_Programming_tags[0]), /* 1 */
|
||||
asn1_DEF_Programming_tags, /* Same as above */
|
||||
sizeof(asn1_DEF_Programming_tags)
|
||||
/sizeof(asn1_DEF_Programming_tags[0]), /* 1 */
|
||||
1, /* Whether CONSTRUCTED */
|
||||
asn1_MBR_Programming,
|
||||
1, /* Single element */
|
||||
&asn1_DEF_Programming_specs /* Additional specs */
|
||||
};
|
||||
|
||||
|
||||
/*** <<< INCLUDES [Fault] >>> ***/
|
||||
|
||||
#include <Error.h>
|
||||
#include <asn_SET_OF.h>
|
||||
#include <constr_SET_OF.h>
|
||||
|
||||
/*** <<< DEPS [Fault] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_Fault;
|
||||
|
||||
/*** <<< TYPE-DECLS [Fault] >>> ***/
|
||||
|
||||
|
||||
typedef struct Fault {
|
||||
A_SET_OF(Error_t) list;
|
||||
|
||||
/* Context for parsing across buffer boundaries */
|
||||
ber_dec_ctx_t _ber_dec_ctx;
|
||||
} Fault_t;
|
||||
|
||||
/*** <<< STAT-DEFS [Fault] >>> ***/
|
||||
|
||||
static asn1_TYPE_member_t asn1_MBR_Fault[] = {
|
||||
{ ATF_NOFLAGS, 0, 0,
|
||||
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
|
||||
.tag_mode = 0,
|
||||
.type = (void *)&asn1_DEF_Error,
|
||||
.memb_constraints = 0, /* Defer to actual type */
|
||||
.name = ""
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn1_DEF_Fault_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
|
||||
};
|
||||
static asn1_SET_OF_specifics_t asn1_DEF_Fault_specs = {
|
||||
sizeof(struct Fault),
|
||||
offsetof(struct Fault, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Fault = {
|
||||
"Fault",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Fault_tags,
|
||||
sizeof(asn1_DEF_Fault_tags)
|
||||
/sizeof(asn1_DEF_Fault_tags[0]), /* 1 */
|
||||
asn1_DEF_Fault_tags, /* Same as above */
|
||||
sizeof(asn1_DEF_Fault_tags)
|
||||
/sizeof(asn1_DEF_Fault_tags[0]), /* 1 */
|
||||
1, /* Whether CONSTRUCTED */
|
||||
asn1_MBR_Fault,
|
||||
1, /* Single element */
|
||||
&asn1_DEF_Fault_specs /* Additional specs */
|
||||
};
|
||||
|
||||
|
||||
/*** <<< INCLUDES [Error] >>> ***/
|
||||
|
||||
#include <constr_SEQUENCE.h>
|
||||
|
||||
/*** <<< DEPS [Error] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_Error;
|
||||
|
||||
/*** <<< TYPE-DECLS [Error] >>> ***/
|
||||
|
||||
|
||||
typedef struct Error {
|
||||
/*
|
||||
* This type is extensible,
|
||||
* possible extensions are below.
|
||||
*/
|
||||
|
||||
/* Context for parsing across buffer boundaries */
|
||||
ber_dec_ctx_t _ber_dec_ctx;
|
||||
} Error_t;
|
||||
|
||||
/*** <<< STAT-DEFS [Error] >>> ***/
|
||||
|
||||
static ber_tlv_tag_t asn1_DEF_Error_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn1_TYPE_tag2member_t asn1_DEF_Error_tag2el[] = {
|
||||
};
|
||||
static asn1_SEQUENCE_specifics_t asn1_DEF_Error_specs = {
|
||||
sizeof(struct Error),
|
||||
offsetof(struct Error, _ber_dec_ctx),
|
||||
asn1_DEF_Error_tag2el,
|
||||
0, /* Count of tags in the map */
|
||||
-1, /* Start extensions */
|
||||
-1 /* Stop extensions */
|
||||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Error = {
|
||||
"Error",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Error_tags,
|
||||
sizeof(asn1_DEF_Error_tags)
|
||||
/sizeof(asn1_DEF_Error_tags[0]), /* 1 */
|
||||
asn1_DEF_Error_tags, /* Same as above */
|
||||
sizeof(asn1_DEF_Error_tags)
|
||||
/sizeof(asn1_DEF_Error_tags[0]), /* 1 */
|
||||
1, /* Whether CONSTRUCTED */
|
||||
0, 0, /* No members */
|
||||
&asn1_DEF_Error_specs /* Additional specs */
|
||||
};
|
||||
|
|
@ -44,15 +44,18 @@ static ber_tlv_tag_t asn1_DEF_collection_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = {
|
||||
sizeof(struct collection),
|
||||
offsetof(struct collection, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_collection = {
|
||||
"collection",
|
||||
SEQUENCE_OF_free,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_constraint,
|
||||
SEQUENCE_OF_decode_ber,
|
||||
SEQUENCE_OF_encode_der,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_collection_tags,
|
||||
sizeof(asn1_DEF_collection_tags)
|
||||
|
@ -99,11 +102,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T = {
|
||||
"T",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T_tags,
|
||||
sizeof(asn1_DEF_T_tags)
|
||||
|
@ -174,11 +179,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T2 = {
|
||||
"T2",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T2_tags,
|
||||
sizeof(asn1_DEF_T2_tags)
|
||||
|
|
|
@ -80,15 +80,18 @@ static ber_tlv_tag_t asn1_DEF_varsets_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_varsets_specs = {
|
||||
sizeof(struct varsets),
|
||||
offsetof(struct varsets, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_varsets = {
|
||||
"varsets",
|
||||
SEQUENCE_OF_free,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_constraint,
|
||||
SEQUENCE_OF_decode_ber,
|
||||
SEQUENCE_OF_encode_der,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_varsets_tags,
|
||||
sizeof(asn1_DEF_varsets_tags)
|
||||
|
@ -135,11 +138,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_LogLine_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_LogLine = {
|
||||
"LogLine",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_LogLine_tags,
|
||||
sizeof(asn1_DEF_LogLine_tags)
|
||||
|
@ -226,15 +231,18 @@ static ber_tlv_tag_t asn1_DEF_vparts_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_vparts_specs = {
|
||||
sizeof(struct vparts),
|
||||
offsetof(struct vparts, _ber_dec_ctx),
|
||||
1, /* XER encoding is XMLValueList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_vparts = {
|
||||
"vparts",
|
||||
SEQUENCE_OF_free,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_constraint,
|
||||
SEQUENCE_OF_decode_ber,
|
||||
SEQUENCE_OF_encode_der,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_vparts_tags,
|
||||
sizeof(asn1_DEF_vparts_tags)
|
||||
|
@ -281,11 +289,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_VariablePartSet_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_VariablePartSet = {
|
||||
"VariablePartSet",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_VariablePartSet_tags,
|
||||
sizeof(asn1_DEF_VariablePartSet_tags)
|
||||
|
@ -400,15 +410,18 @@ static ber_tlv_tag_t asn1_DEF_vset_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_vset_specs = {
|
||||
sizeof(struct vset),
|
||||
offsetof(struct vset, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_vset = {
|
||||
"vset",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_vset_tags,
|
||||
sizeof(asn1_DEF_vset_tags)
|
||||
|
@ -456,11 +469,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_vrange_specs = {
|
|||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_vrange = {
|
||||
"vrange",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_vrange_tags,
|
||||
sizeof(asn1_DEF_vrange_tags)
|
||||
|
@ -505,11 +520,13 @@ static asn1_CHOICE_specifics_t asn1_DEF_VariablePart_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_VariablePart = {
|
||||
"VariablePart",
|
||||
CHOICE_free,
|
||||
CHOICE_print,
|
||||
CHOICE_constraint,
|
||||
CHOICE_decode_ber,
|
||||
CHOICE_encode_der,
|
||||
CHOICE_print,
|
||||
CHOICE_free,
|
||||
0, /* Not implemented yet */
|
||||
CHOICE_encode_xer,
|
||||
CHOICE_outmost_tag,
|
||||
0, /* No effective tags (pointer) */
|
||||
0, /* No effective tags (count) */
|
||||
|
@ -590,15 +607,18 @@ static ber_tlv_tag_t asn1_DEF_email_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_email_specs = {
|
||||
sizeof(struct email),
|
||||
offsetof(struct email, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_email = {
|
||||
"email",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_email_tags,
|
||||
sizeof(asn1_DEF_email_tags)
|
||||
|
@ -646,11 +666,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_notify_specs = {
|
|||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_notify = {
|
||||
"notify",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_notify_tags,
|
||||
sizeof(asn1_DEF_notify_tags)
|
||||
|
@ -697,11 +719,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_ActionItem_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_ActionItem = {
|
||||
"ActionItem",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_ActionItem_tags,
|
||||
sizeof(asn1_DEF_ActionItem_tags)
|
||||
|
|
|
@ -53,15 +53,18 @@ static ber_tlv_tag_t asn1_DEF_t_member1_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_t_member1_specs = {
|
||||
sizeof(struct t_member1),
|
||||
offsetof(struct t_member1, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_t_member1 = {
|
||||
"t-member1",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_t_member1_tags,
|
||||
sizeof(asn1_DEF_t_member1_tags)
|
||||
|
@ -90,15 +93,18 @@ static ber_tlv_tag_t asn1_DEF_t_member2_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_t_member2_specs = {
|
||||
sizeof(struct t_member2),
|
||||
offsetof(struct t_member2, _ber_dec_ctx),
|
||||
0, /* XER encoding is XMLDelimitedItemList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_t_member2 = {
|
||||
"t-member2",
|
||||
SEQUENCE_OF_free,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_constraint,
|
||||
SEQUENCE_OF_decode_ber,
|
||||
SEQUENCE_OF_encode_der,
|
||||
SEQUENCE_OF_print,
|
||||
SEQUENCE_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_t_member2_tags,
|
||||
sizeof(asn1_DEF_t_member2_tags)
|
||||
|
@ -161,11 +167,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_Test_structure_1_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Test_structure_1 = {
|
||||
"Test-structure-1",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Test_structure_1_tags,
|
||||
sizeof(asn1_DEF_Test_structure_1_tags)
|
||||
|
@ -238,15 +246,18 @@ static ber_tlv_tag_t asn1_DEF_or_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_or_specs = {
|
||||
sizeof(struct or),
|
||||
offsetof(struct or, _ber_dec_ctx),
|
||||
1, /* XER encoding is XMLValueList */
|
||||
};
|
||||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_or = {
|
||||
"or",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_or_tags,
|
||||
sizeof(asn1_DEF_or_tags)
|
||||
|
@ -307,11 +318,13 @@ static asn1_CHOICE_specifics_t asn1_DEF_Choice_1_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Choice_1 = {
|
||||
"Choice-1",
|
||||
CHOICE_free,
|
||||
CHOICE_print,
|
||||
CHOICE_constraint,
|
||||
CHOICE_decode_ber,
|
||||
CHOICE_encode_der,
|
||||
CHOICE_print,
|
||||
CHOICE_free,
|
||||
0, /* Not implemented yet */
|
||||
CHOICE_encode_xer,
|
||||
CHOICE_outmost_tag,
|
||||
0, /* No effective tags (pointer) */
|
||||
0, /* No effective tags (count) */
|
||||
|
|
|
@ -100,11 +100,13 @@ static asn1_CHOICE_specifics_t asn1_DEF_e_specs = {
|
|||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_e = {
|
||||
"e",
|
||||
CHOICE_free,
|
||||
CHOICE_print,
|
||||
CHOICE_constraint,
|
||||
CHOICE_decode_ber,
|
||||
CHOICE_encode_der,
|
||||
CHOICE_print,
|
||||
CHOICE_free,
|
||||
0, /* Not implemented yet */
|
||||
CHOICE_encode_xer,
|
||||
CHOICE_outmost_tag,
|
||||
0, /* No effective tags (pointer) */
|
||||
0, /* No effective tags (count) */
|
||||
|
@ -148,11 +150,13 @@ static asn1_CHOICE_specifics_t asn1_DEF_h_specs = {
|
|||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_h = {
|
||||
"h",
|
||||
CHOICE_free,
|
||||
CHOICE_print,
|
||||
CHOICE_constraint,
|
||||
CHOICE_decode_ber,
|
||||
CHOICE_encode_der,
|
||||
CHOICE_print,
|
||||
CHOICE_free,
|
||||
0, /* Not implemented yet */
|
||||
CHOICE_encode_xer,
|
||||
CHOICE_outmost_tag,
|
||||
0, /* No effective tags (pointer) */
|
||||
0, /* No effective tags (count) */
|
||||
|
@ -213,11 +217,13 @@ static asn1_CHOICE_specifics_t asn1_DEF_b_specs = {
|
|||
static /* Use -fall-defs-global to expose */
|
||||
asn1_TYPE_descriptor_t asn1_DEF_b = {
|
||||
"b",
|
||||
CHOICE_free,
|
||||
CHOICE_print,
|
||||
CHOICE_constraint,
|
||||
CHOICE_decode_ber,
|
||||
CHOICE_encode_der,
|
||||
CHOICE_print,
|
||||
CHOICE_free,
|
||||
0, /* Not implemented yet */
|
||||
CHOICE_encode_xer,
|
||||
CHOICE_outmost_tag,
|
||||
0, /* No effective tags (pointer) */
|
||||
0, /* No effective tags (count) */
|
||||
|
@ -267,11 +273,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T = {
|
||||
"T",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T_tags,
|
||||
sizeof(asn1_DEF_T_tags)
|
||||
|
|
|
@ -11,11 +11,12 @@ typedef OCTET_STRING_t PrimitiveType_t;
|
|||
/*** <<< FUNC-DECLS [PrimitiveType] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType;
|
||||
asn_struct_free_f PrimitiveType_free;
|
||||
asn_struct_print_f PrimitiveType_print;
|
||||
asn_constr_check_f PrimitiveType_constraint;
|
||||
ber_type_decoder_f PrimitiveType_decode_ber;
|
||||
der_type_encoder_f PrimitiveType_encode_der;
|
||||
asn_struct_print_f PrimitiveType_print;
|
||||
asn_struct_free_f PrimitiveType_free;
|
||||
xer_type_encoder_f PrimitiveType_encode_xer;
|
||||
|
||||
/*** <<< CODE [PrimitiveType] >>> ***/
|
||||
|
||||
|
@ -35,29 +36,23 @@ PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
PrimitiveType_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
|
||||
td->free_struct = asn1_DEF_OCTET_STRING.free_struct;
|
||||
td->print_struct = asn1_DEF_OCTET_STRING.print_struct;
|
||||
td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_OCTET_STRING.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_OCTET_STRING.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form;
|
||||
td->elements = asn1_DEF_OCTET_STRING.elements;
|
||||
td->elements_count = asn1_DEF_OCTET_STRING.elements_count;
|
||||
td->specifics = asn1_DEF_OCTET_STRING.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
PrimitiveType_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
PrimitiveType_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
PrimitiveType_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -67,11 +62,27 @@ PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
PrimitiveType_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
PrimitiveType_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
PrimitiveType_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
PrimitiveType_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
PrimitiveType_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,11 +93,13 @@ static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = {
|
||||
"PrimitiveType",
|
||||
PrimitiveType_free,
|
||||
PrimitiveType_print,
|
||||
PrimitiveType_constraint,
|
||||
PrimitiveType_decode_ber,
|
||||
PrimitiveType_encode_der,
|
||||
PrimitiveType_print,
|
||||
PrimitiveType_free,
|
||||
0, /* Not implemented yet */
|
||||
PrimitiveType_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_PrimitiveType_tags,
|
||||
sizeof(asn1_DEF_PrimitiveType_tags)
|
||||
|
@ -146,11 +159,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = {
|
||||
"ConstructedType",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_ConstructedType_tags,
|
||||
sizeof(asn1_DEF_ConstructedType_tags)
|
||||
|
@ -177,11 +192,12 @@ typedef ConstructedType_t T_t;
|
|||
/*** <<< FUNC-DECLS [T] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T;
|
||||
asn_struct_free_f T_free;
|
||||
asn_struct_print_f T_print;
|
||||
asn_constr_check_f T_constraint;
|
||||
ber_type_decoder_f T_decode_ber;
|
||||
der_type_encoder_f T_encode_der;
|
||||
asn_struct_print_f T_print;
|
||||
asn_struct_free_f T_free;
|
||||
xer_type_encoder_f T_encode_xer;
|
||||
|
||||
/*** <<< CODE [T] >>> ***/
|
||||
|
||||
|
@ -201,29 +217,23 @@ T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
|
||||
td->free_struct = asn1_DEF_ConstructedType.free_struct;
|
||||
td->print_struct = asn1_DEF_ConstructedType.print_struct;
|
||||
td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_ConstructedType.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_ConstructedType.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
|
||||
td->elements = asn1_DEF_ConstructedType.elements;
|
||||
td->elements_count = asn1_DEF_ConstructedType.elements_count;
|
||||
td->specifics = asn1_DEF_ConstructedType.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -233,11 +243,27 @@ T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,11 +275,13 @@ static ber_tlv_tag_t asn1_DEF_T_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T = {
|
||||
"T",
|
||||
T_free,
|
||||
T_print,
|
||||
T_constraint,
|
||||
T_decode_ber,
|
||||
T_encode_der,
|
||||
T_print,
|
||||
T_free,
|
||||
0, /* Not implemented yet */
|
||||
T_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T_tags,
|
||||
sizeof(asn1_DEF_T_tags)
|
||||
|
|
|
@ -64,11 +64,13 @@ static asn1_SET_specifics_t asn1_DEF_T1_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T1 = {
|
||||
"T1",
|
||||
SET_free,
|
||||
SET_print,
|
||||
SET_constraint,
|
||||
SET_decode_ber,
|
||||
SET_encode_der,
|
||||
SET_print,
|
||||
SET_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T1_tags,
|
||||
sizeof(asn1_DEF_T1_tags)
|
||||
|
@ -148,11 +150,13 @@ static asn1_SET_specifics_t asn1_DEF_T2_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T2 = {
|
||||
"T2",
|
||||
SET_free,
|
||||
SET_print,
|
||||
SET_constraint,
|
||||
SET_decode_ber,
|
||||
SET_encode_der,
|
||||
SET_print,
|
||||
SET_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T2_tags,
|
||||
sizeof(asn1_DEF_T2_tags)
|
||||
|
@ -223,11 +227,13 @@ static asn1_CHOICE_specifics_t asn1_DEF_T3_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T3 = {
|
||||
"T3",
|
||||
CHOICE_free,
|
||||
CHOICE_print,
|
||||
CHOICE_constraint,
|
||||
CHOICE_decode_ber,
|
||||
CHOICE_encode_der,
|
||||
CHOICE_print,
|
||||
CHOICE_free,
|
||||
0, /* Not implemented yet */
|
||||
CHOICE_encode_xer,
|
||||
CHOICE_outmost_tag,
|
||||
0, /* No effective tags (pointer) */
|
||||
0, /* No effective tags (count) */
|
||||
|
@ -296,11 +302,13 @@ static asn1_CHOICE_specifics_t asn1_DEF_T4_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T4 = {
|
||||
"T4",
|
||||
CHOICE_free,
|
||||
CHOICE_print,
|
||||
CHOICE_constraint,
|
||||
CHOICE_decode_ber,
|
||||
CHOICE_encode_der,
|
||||
CHOICE_print,
|
||||
CHOICE_free,
|
||||
0, /* Not implemented yet */
|
||||
CHOICE_encode_xer,
|
||||
CHOICE_outmost_tag,
|
||||
0, /* No effective tags (pointer) */
|
||||
0, /* No effective tags (count) */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -54,11 +54,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_T1_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T1 = {
|
||||
"T1",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T1_tags,
|
||||
sizeof(asn1_DEF_T1_tags)
|
||||
|
@ -129,11 +131,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T2 = {
|
||||
"T2",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T2_tags,
|
||||
sizeof(asn1_DEF_T2_tags)
|
||||
|
|
|
@ -11,11 +11,12 @@ typedef T2_t T1_t;
|
|||
/*** <<< FUNC-DECLS [T1] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T1;
|
||||
asn_struct_free_f T1_free;
|
||||
asn_struct_print_f T1_print;
|
||||
asn_constr_check_f T1_constraint;
|
||||
ber_type_decoder_f T1_decode_ber;
|
||||
der_type_encoder_f T1_encode_der;
|
||||
asn_struct_print_f T1_print;
|
||||
asn_struct_free_f T1_free;
|
||||
xer_type_encoder_f T1_encode_xer;
|
||||
|
||||
/*** <<< CODE [T1] >>> ***/
|
||||
|
||||
|
@ -35,29 +36,23 @@ T1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T1_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T2.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T2.der_encoder;
|
||||
td->free_struct = asn1_DEF_T2.free_struct;
|
||||
td->print_struct = asn1_DEF_T2.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T2.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T2.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T2.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T2.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T2.last_tag_form;
|
||||
td->elements = asn1_DEF_T2.elements;
|
||||
td->elements_count = asn1_DEF_T2.elements_count;
|
||||
td->specifics = asn1_DEF_T2.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T1_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T1_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T1_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -67,11 +62,27 @@ T1_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T1_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T1_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T1_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T1_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,11 +104,13 @@ static ber_tlv_tag_t asn1_DEF_T1_all_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T1 = {
|
||||
"T1",
|
||||
T1_free,
|
||||
T1_print,
|
||||
T1_constraint,
|
||||
T1_decode_ber,
|
||||
T1_encode_der,
|
||||
T1_print,
|
||||
T1_free,
|
||||
0, /* Not implemented yet */
|
||||
T1_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T1_tags,
|
||||
sizeof(asn1_DEF_T1_tags)
|
||||
|
@ -123,11 +136,12 @@ typedef T3_t T2_t;
|
|||
/*** <<< FUNC-DECLS [T2] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T2;
|
||||
asn_struct_free_f T2_free;
|
||||
asn_struct_print_f T2_print;
|
||||
asn_constr_check_f T2_constraint;
|
||||
ber_type_decoder_f T2_decode_ber;
|
||||
der_type_encoder_f T2_encode_der;
|
||||
asn_struct_print_f T2_print;
|
||||
asn_struct_free_f T2_free;
|
||||
xer_type_encoder_f T2_encode_xer;
|
||||
|
||||
/*** <<< CODE [T2] >>> ***/
|
||||
|
||||
|
@ -147,29 +161,23 @@ T2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T3.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T3.der_encoder;
|
||||
td->free_struct = asn1_DEF_T3.free_struct;
|
||||
td->print_struct = asn1_DEF_T3.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T3.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T3.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T3.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T3.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T3.last_tag_form;
|
||||
td->elements = asn1_DEF_T3.elements;
|
||||
td->elements_count = asn1_DEF_T3.elements_count;
|
||||
td->specifics = asn1_DEF_T3.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T2_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T2_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T2_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -179,11 +187,27 @@ T2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T2_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T2_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T2_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T2_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -203,11 +227,13 @@ static ber_tlv_tag_t asn1_DEF_T2_all_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T2 = {
|
||||
"T2",
|
||||
T2_free,
|
||||
T2_print,
|
||||
T2_constraint,
|
||||
T2_decode_ber,
|
||||
T2_encode_der,
|
||||
T2_print,
|
||||
T2_free,
|
||||
0, /* Not implemented yet */
|
||||
T2_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T2_tags,
|
||||
sizeof(asn1_DEF_T2_tags)
|
||||
|
@ -233,11 +259,12 @@ typedef T4_t T3_t;
|
|||
/*** <<< FUNC-DECLS [T3] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T3;
|
||||
asn_struct_free_f T3_free;
|
||||
asn_struct_print_f T3_print;
|
||||
asn_constr_check_f T3_constraint;
|
||||
ber_type_decoder_f T3_decode_ber;
|
||||
der_type_encoder_f T3_encode_der;
|
||||
asn_struct_print_f T3_print;
|
||||
asn_struct_free_f T3_free;
|
||||
xer_type_encoder_f T3_encode_xer;
|
||||
|
||||
/*** <<< CODE [T3] >>> ***/
|
||||
|
||||
|
@ -257,29 +284,23 @@ T3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T4.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T4.der_encoder;
|
||||
td->free_struct = asn1_DEF_T4.free_struct;
|
||||
td->print_struct = asn1_DEF_T4.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T4.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T4.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T4.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T4.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T4.last_tag_form;
|
||||
td->elements = asn1_DEF_T4.elements;
|
||||
td->elements_count = asn1_DEF_T4.elements_count;
|
||||
td->specifics = asn1_DEF_T4.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T3_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T3_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T3_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -289,11 +310,27 @@ T3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T3_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T3_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T3_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T3_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -311,11 +348,13 @@ static ber_tlv_tag_t asn1_DEF_T3_all_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T3 = {
|
||||
"T3",
|
||||
T3_free,
|
||||
T3_print,
|
||||
T3_constraint,
|
||||
T3_decode_ber,
|
||||
T3_encode_der,
|
||||
T3_print,
|
||||
T3_free,
|
||||
0, /* Not implemented yet */
|
||||
T3_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T3_tags,
|
||||
sizeof(asn1_DEF_T3_tags)
|
||||
|
@ -341,11 +380,12 @@ typedef T5_t T4_t;
|
|||
/*** <<< FUNC-DECLS [T4] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T4;
|
||||
asn_struct_free_f T4_free;
|
||||
asn_struct_print_f T4_print;
|
||||
asn_constr_check_f T4_constraint;
|
||||
ber_type_decoder_f T4_decode_ber;
|
||||
der_type_encoder_f T4_encode_der;
|
||||
asn_struct_print_f T4_print;
|
||||
asn_struct_free_f T4_free;
|
||||
xer_type_encoder_f T4_encode_xer;
|
||||
|
||||
/*** <<< CODE [T4] >>> ***/
|
||||
|
||||
|
@ -365,29 +405,23 @@ T4_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T4_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T5.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T5.der_encoder;
|
||||
td->free_struct = asn1_DEF_T5.free_struct;
|
||||
td->print_struct = asn1_DEF_T5.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T5.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T5.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T5.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T5.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T5.last_tag_form;
|
||||
td->elements = asn1_DEF_T5.elements;
|
||||
td->elements_count = asn1_DEF_T5.elements_count;
|
||||
td->specifics = asn1_DEF_T5.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T4_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T4_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T4_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -397,11 +431,27 @@ T4_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T4_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T4_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T4_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T4_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -414,11 +464,13 @@ static ber_tlv_tag_t asn1_DEF_T4_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T4 = {
|
||||
"T4",
|
||||
T4_free,
|
||||
T4_print,
|
||||
T4_constraint,
|
||||
T4_decode_ber,
|
||||
T4_encode_der,
|
||||
T4_print,
|
||||
T4_free,
|
||||
0, /* Not implemented yet */
|
||||
T4_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T4_tags,
|
||||
sizeof(asn1_DEF_T4_tags)
|
||||
|
@ -444,11 +496,12 @@ typedef T6_t T5_t;
|
|||
/*** <<< FUNC-DECLS [T5] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T5;
|
||||
asn_struct_free_f T5_free;
|
||||
asn_struct_print_f T5_print;
|
||||
asn_constr_check_f T5_constraint;
|
||||
ber_type_decoder_f T5_decode_ber;
|
||||
der_type_encoder_f T5_encode_der;
|
||||
asn_struct_print_f T5_print;
|
||||
asn_struct_free_f T5_free;
|
||||
xer_type_encoder_f T5_encode_xer;
|
||||
|
||||
/*** <<< CODE [T5] >>> ***/
|
||||
|
||||
|
@ -468,29 +521,23 @@ T5_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T5_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T6.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T6.der_encoder;
|
||||
td->free_struct = asn1_DEF_T6.free_struct;
|
||||
td->print_struct = asn1_DEF_T6.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T6.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T6.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T6.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T6.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T6.last_tag_form;
|
||||
td->elements = asn1_DEF_T6.elements;
|
||||
td->elements_count = asn1_DEF_T6.elements_count;
|
||||
td->specifics = asn1_DEF_T6.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T5_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T5_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T5_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -500,11 +547,27 @@ T5_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T5_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T5_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T5_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T5_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -516,11 +579,13 @@ static ber_tlv_tag_t asn1_DEF_T5_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T5 = {
|
||||
"T5",
|
||||
T5_free,
|
||||
T5_print,
|
||||
T5_constraint,
|
||||
T5_decode_ber,
|
||||
T5_encode_der,
|
||||
T5_print,
|
||||
T5_free,
|
||||
0, /* Not implemented yet */
|
||||
T5_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T5_tags,
|
||||
sizeof(asn1_DEF_T5_tags)
|
||||
|
@ -546,11 +611,12 @@ typedef REAL_t T6_t;
|
|||
/*** <<< FUNC-DECLS [T6] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T6;
|
||||
asn_struct_free_f T6_free;
|
||||
asn_struct_print_f T6_print;
|
||||
asn_constr_check_f T6_constraint;
|
||||
ber_type_decoder_f T6_decode_ber;
|
||||
der_type_encoder_f T6_encode_der;
|
||||
asn_struct_print_f T6_print;
|
||||
asn_struct_free_f T6_free;
|
||||
xer_type_encoder_f T6_encode_xer;
|
||||
|
||||
/*** <<< CODE [T6] >>> ***/
|
||||
|
||||
|
@ -570,29 +636,23 @@ T6_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T6_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_REAL.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_REAL.der_encoder;
|
||||
td->free_struct = asn1_DEF_REAL.free_struct;
|
||||
td->print_struct = asn1_DEF_REAL.print_struct;
|
||||
td->ber_decoder = asn1_DEF_REAL.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_REAL.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_REAL.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_REAL.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_REAL.last_tag_form;
|
||||
td->elements = asn1_DEF_REAL.elements;
|
||||
td->elements_count = asn1_DEF_REAL.elements_count;
|
||||
td->specifics = asn1_DEF_REAL.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T6_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T6_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T6_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -602,11 +662,27 @@ T6_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T6_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T6_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T6_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T6_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -617,11 +693,13 @@ static ber_tlv_tag_t asn1_DEF_T6_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T6 = {
|
||||
"T6",
|
||||
T6_free,
|
||||
T6_print,
|
||||
T6_constraint,
|
||||
T6_decode_ber,
|
||||
T6_encode_der,
|
||||
T6_print,
|
||||
T6_free,
|
||||
0, /* Not implemented yet */
|
||||
T6_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T6_tags,
|
||||
sizeof(asn1_DEF_T6_tags)
|
||||
|
@ -647,11 +725,12 @@ typedef Ts_t T_t;
|
|||
/*** <<< FUNC-DECLS [T] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T;
|
||||
asn_struct_free_f T_free;
|
||||
asn_struct_print_f T_print;
|
||||
asn_constr_check_f T_constraint;
|
||||
ber_type_decoder_f T_decode_ber;
|
||||
der_type_encoder_f T_encode_der;
|
||||
asn_struct_print_f T_print;
|
||||
asn_struct_free_f T_free;
|
||||
xer_type_encoder_f T_encode_xer;
|
||||
|
||||
/*** <<< CODE [T] >>> ***/
|
||||
|
||||
|
@ -671,29 +750,23 @@ T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_Ts.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_Ts.der_encoder;
|
||||
td->free_struct = asn1_DEF_Ts.free_struct;
|
||||
td->print_struct = asn1_DEF_Ts.print_struct;
|
||||
td->ber_decoder = asn1_DEF_Ts.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_Ts.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_Ts.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_Ts.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_Ts.last_tag_form;
|
||||
td->elements = asn1_DEF_Ts.elements;
|
||||
td->elements_count = asn1_DEF_Ts.elements_count;
|
||||
td->specifics = asn1_DEF_Ts.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -703,11 +776,27 @@ T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -720,11 +809,13 @@ static ber_tlv_tag_t asn1_DEF_T_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T = {
|
||||
"T",
|
||||
T_free,
|
||||
T_print,
|
||||
T_constraint,
|
||||
T_decode_ber,
|
||||
T_encode_der,
|
||||
T_print,
|
||||
T_free,
|
||||
0, /* Not implemented yet */
|
||||
T_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T_tags,
|
||||
sizeof(asn1_DEF_T_tags)
|
||||
|
@ -804,11 +895,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_Ts_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Ts = {
|
||||
"Ts",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Ts_tags,
|
||||
sizeof(asn1_DEF_Ts_tags)
|
||||
|
|
|
@ -11,11 +11,12 @@ typedef T2_t T1_t;
|
|||
/*** <<< FUNC-DECLS [T1] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T1;
|
||||
asn_struct_free_f T1_free;
|
||||
asn_struct_print_f T1_print;
|
||||
asn_constr_check_f T1_constraint;
|
||||
ber_type_decoder_f T1_decode_ber;
|
||||
der_type_encoder_f T1_encode_der;
|
||||
asn_struct_print_f T1_print;
|
||||
asn_struct_free_f T1_free;
|
||||
xer_type_encoder_f T1_encode_xer;
|
||||
|
||||
/*** <<< CODE [T1] >>> ***/
|
||||
|
||||
|
@ -35,29 +36,23 @@ T1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T1_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T2.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T2.der_encoder;
|
||||
td->free_struct = asn1_DEF_T2.free_struct;
|
||||
td->print_struct = asn1_DEF_T2.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T2.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T2.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T2.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T2.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T2.last_tag_form;
|
||||
td->elements = asn1_DEF_T2.elements;
|
||||
td->elements_count = asn1_DEF_T2.elements_count;
|
||||
td->specifics = asn1_DEF_T2.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T1_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T1_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T1_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -67,11 +62,27 @@ T1_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T1_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T1_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T1_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T1_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T1_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,11 +104,13 @@ static ber_tlv_tag_t asn1_DEF_T1_all_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T1 = {
|
||||
"T1",
|
||||
T1_free,
|
||||
T1_print,
|
||||
T1_constraint,
|
||||
T1_decode_ber,
|
||||
T1_encode_der,
|
||||
T1_print,
|
||||
T1_free,
|
||||
0, /* Not implemented yet */
|
||||
T1_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T1_tags,
|
||||
sizeof(asn1_DEF_T1_tags)
|
||||
|
@ -123,11 +136,12 @@ typedef T3_t T2_t;
|
|||
/*** <<< FUNC-DECLS [T2] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T2;
|
||||
asn_struct_free_f T2_free;
|
||||
asn_struct_print_f T2_print;
|
||||
asn_constr_check_f T2_constraint;
|
||||
ber_type_decoder_f T2_decode_ber;
|
||||
der_type_encoder_f T2_encode_der;
|
||||
asn_struct_print_f T2_print;
|
||||
asn_struct_free_f T2_free;
|
||||
xer_type_encoder_f T2_encode_xer;
|
||||
|
||||
/*** <<< CODE [T2] >>> ***/
|
||||
|
||||
|
@ -147,29 +161,23 @@ T2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T3.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T3.der_encoder;
|
||||
td->free_struct = asn1_DEF_T3.free_struct;
|
||||
td->print_struct = asn1_DEF_T3.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T3.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T3.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T3.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T3.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T3.last_tag_form;
|
||||
td->elements = asn1_DEF_T3.elements;
|
||||
td->elements_count = asn1_DEF_T3.elements_count;
|
||||
td->specifics = asn1_DEF_T3.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T2_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T2_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T2_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -179,11 +187,27 @@ T2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T2_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T2_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T2_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T2_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T2_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -203,11 +227,13 @@ static ber_tlv_tag_t asn1_DEF_T2_all_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T2 = {
|
||||
"T2",
|
||||
T2_free,
|
||||
T2_print,
|
||||
T2_constraint,
|
||||
T2_decode_ber,
|
||||
T2_encode_der,
|
||||
T2_print,
|
||||
T2_free,
|
||||
0, /* Not implemented yet */
|
||||
T2_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T2_tags,
|
||||
sizeof(asn1_DEF_T2_tags)
|
||||
|
@ -233,11 +259,12 @@ typedef T4_t T3_t;
|
|||
/*** <<< FUNC-DECLS [T3] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T3;
|
||||
asn_struct_free_f T3_free;
|
||||
asn_struct_print_f T3_print;
|
||||
asn_constr_check_f T3_constraint;
|
||||
ber_type_decoder_f T3_decode_ber;
|
||||
der_type_encoder_f T3_encode_der;
|
||||
asn_struct_print_f T3_print;
|
||||
asn_struct_free_f T3_free;
|
||||
xer_type_encoder_f T3_encode_xer;
|
||||
|
||||
/*** <<< CODE [T3] >>> ***/
|
||||
|
||||
|
@ -257,29 +284,23 @@ T3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T4.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T4.der_encoder;
|
||||
td->free_struct = asn1_DEF_T4.free_struct;
|
||||
td->print_struct = asn1_DEF_T4.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T4.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T4.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T4.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T4.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T4.last_tag_form;
|
||||
td->elements = asn1_DEF_T4.elements;
|
||||
td->elements_count = asn1_DEF_T4.elements_count;
|
||||
td->specifics = asn1_DEF_T4.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T3_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T3_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T3_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -289,11 +310,27 @@ T3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T3_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T3_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T3_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T3_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T3_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -311,11 +348,13 @@ static ber_tlv_tag_t asn1_DEF_T3_all_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T3 = {
|
||||
"T3",
|
||||
T3_free,
|
||||
T3_print,
|
||||
T3_constraint,
|
||||
T3_decode_ber,
|
||||
T3_encode_der,
|
||||
T3_print,
|
||||
T3_free,
|
||||
0, /* Not implemented yet */
|
||||
T3_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T3_tags,
|
||||
sizeof(asn1_DEF_T3_tags)
|
||||
|
@ -341,11 +380,12 @@ typedef T5_t T4_t;
|
|||
/*** <<< FUNC-DECLS [T4] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T4;
|
||||
asn_struct_free_f T4_free;
|
||||
asn_struct_print_f T4_print;
|
||||
asn_constr_check_f T4_constraint;
|
||||
ber_type_decoder_f T4_decode_ber;
|
||||
der_type_encoder_f T4_encode_der;
|
||||
asn_struct_print_f T4_print;
|
||||
asn_struct_free_f T4_free;
|
||||
xer_type_encoder_f T4_encode_xer;
|
||||
|
||||
/*** <<< CODE [T4] >>> ***/
|
||||
|
||||
|
@ -365,29 +405,23 @@ T4_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T4_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T5.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T5.der_encoder;
|
||||
td->free_struct = asn1_DEF_T5.free_struct;
|
||||
td->print_struct = asn1_DEF_T5.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T5.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T5.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T5.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T5.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T5.last_tag_form;
|
||||
td->elements = asn1_DEF_T5.elements;
|
||||
td->elements_count = asn1_DEF_T5.elements_count;
|
||||
td->specifics = asn1_DEF_T5.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T4_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T4_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T4_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -397,11 +431,27 @@ T4_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T4_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T4_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T4_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T4_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T4_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -414,11 +464,13 @@ static ber_tlv_tag_t asn1_DEF_T4_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T4 = {
|
||||
"T4",
|
||||
T4_free,
|
||||
T4_print,
|
||||
T4_constraint,
|
||||
T4_decode_ber,
|
||||
T4_encode_der,
|
||||
T4_print,
|
||||
T4_free,
|
||||
0, /* Not implemented yet */
|
||||
T4_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T4_tags,
|
||||
sizeof(asn1_DEF_T4_tags)
|
||||
|
@ -444,11 +496,12 @@ typedef T6_t T5_t;
|
|||
/*** <<< FUNC-DECLS [T5] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T5;
|
||||
asn_struct_free_f T5_free;
|
||||
asn_struct_print_f T5_print;
|
||||
asn_constr_check_f T5_constraint;
|
||||
ber_type_decoder_f T5_decode_ber;
|
||||
der_type_encoder_f T5_encode_der;
|
||||
asn_struct_print_f T5_print;
|
||||
asn_struct_free_f T5_free;
|
||||
xer_type_encoder_f T5_encode_xer;
|
||||
|
||||
/*** <<< CODE [T5] >>> ***/
|
||||
|
||||
|
@ -468,29 +521,23 @@ T5_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T5_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_T6.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T6.der_encoder;
|
||||
td->free_struct = asn1_DEF_T6.free_struct;
|
||||
td->print_struct = asn1_DEF_T6.print_struct;
|
||||
td->ber_decoder = asn1_DEF_T6.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_T6.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_T6.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_T6.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_T6.last_tag_form;
|
||||
td->elements = asn1_DEF_T6.elements;
|
||||
td->elements_count = asn1_DEF_T6.elements_count;
|
||||
td->specifics = asn1_DEF_T6.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T5_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T5_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T5_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -500,11 +547,27 @@ T5_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T5_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T5_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T5_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T5_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T5_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -516,11 +579,13 @@ static ber_tlv_tag_t asn1_DEF_T5_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T5 = {
|
||||
"T5",
|
||||
T5_free,
|
||||
T5_print,
|
||||
T5_constraint,
|
||||
T5_decode_ber,
|
||||
T5_encode_der,
|
||||
T5_print,
|
||||
T5_free,
|
||||
0, /* Not implemented yet */
|
||||
T5_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T5_tags,
|
||||
sizeof(asn1_DEF_T5_tags)
|
||||
|
@ -546,11 +611,12 @@ typedef double T6_t;
|
|||
/*** <<< FUNC-DECLS [T6] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T6;
|
||||
asn_struct_free_f T6_free;
|
||||
asn_struct_print_f T6_print;
|
||||
asn_constr_check_f T6_constraint;
|
||||
ber_type_decoder_f T6_decode_ber;
|
||||
der_type_encoder_f T6_encode_der;
|
||||
asn_struct_print_f T6_print;
|
||||
asn_struct_free_f T6_free;
|
||||
xer_type_encoder_f T6_encode_xer;
|
||||
|
||||
/*** <<< CODE [T6] >>> ***/
|
||||
|
||||
|
@ -570,29 +636,23 @@ T6_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T6_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_NativeReal.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_NativeReal.der_encoder;
|
||||
td->free_struct = asn1_DEF_NativeReal.free_struct;
|
||||
td->print_struct = asn1_DEF_NativeReal.print_struct;
|
||||
td->ber_decoder = asn1_DEF_NativeReal.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_NativeReal.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_NativeReal.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_NativeReal.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_NativeReal.last_tag_form;
|
||||
td->elements = asn1_DEF_NativeReal.elements;
|
||||
td->elements_count = asn1_DEF_NativeReal.elements_count;
|
||||
td->specifics = asn1_DEF_NativeReal.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T6_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T6_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T6_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -602,11 +662,27 @@ T6_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T6_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T6_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T6_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T6_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T6_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -617,11 +693,13 @@ static ber_tlv_tag_t asn1_DEF_T6_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T6 = {
|
||||
"T6",
|
||||
T6_free,
|
||||
T6_print,
|
||||
T6_constraint,
|
||||
T6_decode_ber,
|
||||
T6_encode_der,
|
||||
T6_print,
|
||||
T6_free,
|
||||
0, /* Not implemented yet */
|
||||
T6_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T6_tags,
|
||||
sizeof(asn1_DEF_T6_tags)
|
||||
|
@ -647,11 +725,12 @@ typedef Ts_t T_t;
|
|||
/*** <<< FUNC-DECLS [T] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_T;
|
||||
asn_struct_free_f T_free;
|
||||
asn_struct_print_f T_print;
|
||||
asn_constr_check_f T_constraint;
|
||||
ber_type_decoder_f T_decode_ber;
|
||||
der_type_encoder_f T_encode_der;
|
||||
asn_struct_print_f T_print;
|
||||
asn_struct_free_f T_free;
|
||||
xer_type_encoder_f T_encode_xer;
|
||||
|
||||
/*** <<< CODE [T] >>> ***/
|
||||
|
||||
|
@ -671,29 +750,23 @@ T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
T_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_Ts.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_Ts.der_encoder;
|
||||
td->free_struct = asn1_DEF_Ts.free_struct;
|
||||
td->print_struct = asn1_DEF_Ts.print_struct;
|
||||
td->ber_decoder = asn1_DEF_Ts.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_Ts.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_Ts.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_Ts.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_Ts.last_tag_form;
|
||||
td->elements = asn1_DEF_Ts.elements;
|
||||
td->elements_count = asn1_DEF_Ts.elements_count;
|
||||
td->specifics = asn1_DEF_Ts.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
T_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
T_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
T_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -703,11 +776,27 @@ T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
T_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
T_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
T_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
T_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -720,11 +809,13 @@ static ber_tlv_tag_t asn1_DEF_T_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T = {
|
||||
"T",
|
||||
T_free,
|
||||
T_print,
|
||||
T_constraint,
|
||||
T_decode_ber,
|
||||
T_encode_der,
|
||||
T_print,
|
||||
T_free,
|
||||
0, /* Not implemented yet */
|
||||
T_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T_tags,
|
||||
sizeof(asn1_DEF_T_tags)
|
||||
|
@ -804,11 +895,13 @@ static asn1_SEQUENCE_specifics_t asn1_DEF_Ts_specs = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_Ts = {
|
||||
"Ts",
|
||||
SEQUENCE_free,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_constraint,
|
||||
SEQUENCE_decode_ber,
|
||||
SEQUENCE_encode_der,
|
||||
SEQUENCE_print,
|
||||
SEQUENCE_free,
|
||||
0, /* Not implemented yet */
|
||||
SEQUENCE_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_Ts_tags,
|
||||
sizeof(asn1_DEF_Ts_tags)
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
-- .spelio.software.asn1c.test (9363.1.5.1)
|
||||
-- .66
|
||||
|
||||
ModuleTestReferenceToSimpleType
|
||||
ModuleTestReferenceToNamedSimpleType
|
||||
{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
|
||||
spelio(9363) software(1) asn1c(5) test(1) 66 }
|
||||
DEFINITIONS IMPLICIT TAGS ::=
|
||||
BEGIN
|
||||
|
||||
T ::= SET OF SimpleType
|
||||
T ::= SET OF named SimpleType
|
||||
|
||||
SimpleType ::= ENUMERATED { one, two, three }
|
||||
|
||||
|
|
|
@ -36,14 +36,17 @@ static ber_tlv_tag_t asn1_DEF_T_tags[] = {
|
|||
static asn1_SET_OF_specifics_t asn1_DEF_T_specs = {
|
||||
sizeof(struct T),
|
||||
offsetof(struct T, _ber_dec_ctx),
|
||||
1, /* XER encoding is XMLValueList */
|
||||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_T = {
|
||||
"T",
|
||||
SET_OF_free,
|
||||
SET_OF_print,
|
||||
SET_OF_constraint,
|
||||
SET_OF_decode_ber,
|
||||
SET_OF_encode_der,
|
||||
SET_OF_print,
|
||||
SET_OF_free,
|
||||
0, /* Not implemented yet */
|
||||
SET_OF_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_T_tags,
|
||||
sizeof(asn1_DEF_T_tags)
|
||||
|
@ -78,11 +81,12 @@ typedef ENUMERATED_t SimpleType_t;
|
|||
/*** <<< FUNC-DECLS [SimpleType] >>> ***/
|
||||
|
||||
extern asn1_TYPE_descriptor_t asn1_DEF_SimpleType;
|
||||
asn_struct_free_f SimpleType_free;
|
||||
asn_struct_print_f SimpleType_print;
|
||||
asn_constr_check_f SimpleType_constraint;
|
||||
ber_type_decoder_f SimpleType_decode_ber;
|
||||
der_type_encoder_f SimpleType_encode_der;
|
||||
asn_struct_print_f SimpleType_print;
|
||||
asn_struct_free_f SimpleType_free;
|
||||
xer_type_encoder_f SimpleType_encode_xer;
|
||||
|
||||
/*** <<< CODE [SimpleType] >>> ***/
|
||||
|
||||
|
@ -102,29 +106,23 @@ SimpleType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
*/
|
||||
static void
|
||||
SimpleType_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
|
||||
td->ber_decoder = asn1_DEF_ENUMERATED.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_ENUMERATED.der_encoder;
|
||||
td->free_struct = asn1_DEF_ENUMERATED.free_struct;
|
||||
td->print_struct = asn1_DEF_ENUMERATED.print_struct;
|
||||
td->ber_decoder = asn1_DEF_ENUMERATED.ber_decoder;
|
||||
td->der_encoder = asn1_DEF_ENUMERATED.der_encoder;
|
||||
td->xer_decoder = asn1_DEF_ENUMERATED.xer_decoder;
|
||||
td->xer_encoder = asn1_DEF_ENUMERATED.xer_encoder;
|
||||
td->last_tag_form = asn1_DEF_ENUMERATED.last_tag_form;
|
||||
td->elements = asn1_DEF_ENUMERATED.elements;
|
||||
td->elements_count = asn1_DEF_ENUMERATED.elements_count;
|
||||
td->specifics = asn1_DEF_ENUMERATED.specifics;
|
||||
}
|
||||
|
||||
ber_dec_rval_t
|
||||
SimpleType_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
void
|
||||
SimpleType_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
SimpleType_inherit_TYPE_descriptor(td);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
der_enc_rval_t
|
||||
SimpleType_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
SimpleType_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -134,11 +132,27 @@ SimpleType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
|
|||
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
|
||||
}
|
||||
|
||||
void
|
||||
SimpleType_free(asn1_TYPE_descriptor_t *td,
|
||||
void *struct_ptr, int contents_only) {
|
||||
ber_dec_rval_t
|
||||
SimpleType_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **structure, void *bufptr, size_t size, int tag_mode) {
|
||||
SimpleType_inherit_TYPE_descriptor(td);
|
||||
td->free_struct(td, struct_ptr, contents_only);
|
||||
return td->ber_decoder(td, structure, bufptr, size, tag_mode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SimpleType_encode_der(asn1_TYPE_descriptor_t *td,
|
||||
void *structure, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
SimpleType_inherit_TYPE_descriptor(td);
|
||||
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SimpleType_encode_xer(asn1_TYPE_descriptor_t *td, void *structure,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
SimpleType_inherit_TYPE_descriptor(td);
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,11 +163,13 @@ static ber_tlv_tag_t asn1_DEF_SimpleType_tags[] = {
|
|||
};
|
||||
asn1_TYPE_descriptor_t asn1_DEF_SimpleType = {
|
||||
"SimpleType",
|
||||
SimpleType_free,
|
||||
SimpleType_print,
|
||||
SimpleType_constraint,
|
||||
SimpleType_decode_ber,
|
||||
SimpleType_encode_der,
|
||||
SimpleType_print,
|
||||
SimpleType_free,
|
||||
0, /* Not implemented yet */
|
||||
SimpleType_encode_xer,
|
||||
0, /* Use generic outmost tag fetcher */
|
||||
asn1_DEF_SimpleType_tags,
|
||||
sizeof(asn1_DEF_SimpleType_tags)
|
||||
|
|
Loading…
Reference in New Issue