Question

I'm trying to create simple DER decoder - console application that just outputs content of given data structure (encoded in DER format, like this one).

I have problems with running this example: A ''Rectangle'' Decoder .

I'm trying to compile it with MSVC and I have problems with #include <inttypes.h> and #include <netinet/in.h>. Also type ssize_t is undefined.

Here's what I've done for now:
1. At Online ASN.1 Compiler I pasted this code into textfield:

RectangleModule1 DEFINITIONS ::=
BEGIN

Rectangle ::= SEQUENCE {
    height  INTEGER,
    width   INTEGER
}

END

2. I selected "Use native machine types" and "Generate PER support" options.
3. It "Compiled OK" so I downloaded that output .tgz
4. Created empty project int Visual Studio 2010, drag-n-dropped source files extracted from this .tgz
5. Set additional include directory to "skeletons" directory of ASN1C
6. Tried to build it.

What am I missing?

Any help would be appreciated

Was it helpful?

Solution

The problem is that code generated by ASN1C must be modified in order to compile it with MSVC and to use it in Windows environment.

  1. #include <inttypes.h> should be replaced with #define ssize_t SSIZE_T
  2. #include <netinet/in.h> should be replaced with #include <Winsock2.h>
  3. keyword inline should be removed from static functions defined in asn_internal.h

After that, everything works fine ;)

OTHER TIPS

Make sure that you have a correct ASN defintion file. Then go to link http://lionet.info/asn1c/asn1c.cgi

paste your ASN definition in the given window. Press the button "Proceed with ASN.1 compilation". If you get any compilation error rectify those. After the compilation is successful it will generate the code for your decoder. Give it a try its good.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top