0

Am learning on to understand ASN.1 Rectangle encode program.

Currently the program given on the website is printing in XML format and generated ber file. I wanted to print/read the PDU in hex encoded format (hexdump). Initially, I tried opening the test.ber file using an editor. But not opening properly.

I found uper_encoder does the job, and it's parameters are same as ber_encode same parameters. The compilation is also success cc -g -I. -o rencode.x *.c but on executing. Program fails with error Couldn't encode rectangle at function uper_encode as it returns -1.

ec = uper_encode (&asn_DEF_Rectangle, rectangle, write_out, fp)

Could I get some help in printing them in hex format.

Gopi
  • 340
  • 4
  • 12

1 Answers1

1

@Gopi,

With the caveat I have no experience with Lev Walkin's ASN.1 compiler, there are a couple of issues you're probably having:

  1. Hex dumping means decoding, not encoding, but you are trying to use uper_encode instead.

  2. The test.ber file is BER-encoded, but you are using a PER function to try to dump it out.

I can't help you with using the code, but you need to use something like ber_decode (or whatever the equivalent is) to decode the data; then you can create a hex dump from the decoded bytes.

Ethan
  • 252
  • 2
  • 8