Reputation: 1009
I came to know about http://cgit.osmocom.org/libosmo-asn1-tcap/ and could compile the library.
I am doing simple experiments with asn.1. I have following TCAP data (begin): (hexdump of the data follows):
0x000000: 62 6b 48 04 40 f0 fa 2f bkH.@../
0x000008: 6b 43 28 41 06 07 00 11 kC(A....
0x000010: 86 05 01 01 01 a0 36 60 ......6`
0x000018: 34 80 02 07 80 a1 09 06 4.......
0x000020: 07 04 00 00 01 00 13 02 ........
0x000028: be 23 28 21 06 07 04 00 .#(!....
0x000030: 00 01 01 01 01 a0 16 a0 ........
0x000038: 14 80 09 96 74 00 34 00 ....t.4.
0x000040: 46 20 56 f4 81 07 91 88 F V.....
0x000048: 10 05 51 89 00 6c 1e a1 ..Q..l..
0x000050: 1c 02 01 80 02 01 3b 30 ......;0
0x000058: 14 04 01 0f 04 05 aa 5a .......Z
0x000060: ac 36 02 80 08 91 88 10 .6......
0x000068: 35 64 91 59 f5 5d.Y.
0x62 is tcap 'begin'. Length of the data follows in the next byte. Now I have following code to decode the data. But not working:
#include <TCMessage.h>
void tcap_decode(const void *buf, size_t len)
{
asn_dec_rval_t rval;
TCMessage_t *pdu = 0;
rval = asn_DEF_TCMessage.ber_decoder(0,
&asn_DEF_TCMessage,
(void **) &pdu,
buf, len, 0);
if (rval.code == RC_OK) {
fprintf(stderr, "Decoded successfully\n");
} else {
/* Free partially decoded data */
fprintf(stderr, "Decode failed, Freeing partially parased data structure\n");
}
asn_DEF_TCMessage.free_struct(&asn_DEF_TCMessage, pdu, 0);
}
Please suggest what I can do to make the decoder work correctly. I tried many ways, for example, skipping two bytes (type+length) but no luck. I am not sure if the problem is in the libosmo-asn1-tcap.
Thanks in advance.
Upvotes: 0
Views: 172
Reputation: 1009
After all night trying various ways I could figure out the problem. The problem was the broken tcap.asn in the libosmo-asn1-tcap. I fixed the broken references and recompiled and things worked. To find out the problem I enabled debugging in libasn1c and that showed where it would stop decoding. Happy hacking.
Upvotes: 1