All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Nasonov <alnsn-mycop@yandex.ru>
To: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: ASN.1 decoder for h323-conntrack-nat
Date: Thu, 16 Oct 2003 16:11:49 +0200	[thread overview]
Message-ID: <3F8EA725.9090000@yandex.ru> (raw)
In-Reply-To: <Pine.LNX.4.33.0310161528160.4832-100000@blackhole.kfki.hu>

Jozsef Kadlecsik wrote:

> That would be great! We cannot use code written in C++.

I'm using C++ simply because C++ has inline functions and if you put all 
these functions (with bodies) into the class scopr you don't need to 
worry about the order in which they should be placed. I can rewrite the 
generator to generate C code (the generator itself will be written in 
C++ anyway).

>[Actually, I have just discovered that the source code of the most recent
>ethereal contains ASN.1 PER/H225/H245 decoders written in C.]
>
This tool helped me a lot to understand what PER is. Hmm, I thought that 
ethereal is based on openh323 ASN.1 generator which is C++-based. I'll 
take a look at the code later. Is there any free ASN.1 decoder?
I wish I had a better code. I could implement more optimization then. 
For example, if a type after extention mark (...) doesn't have callbacks 
it could be just skiped as open type. I could also try to simplify  
parsing of fixed-length types. May be later I'll find more time to 
rewrite the code.
I forgot to mention that my code is based on 
http://iiiasn1.sourceforge.net (this project AFAIK is derived from 
openh323 decoder/encoder).

--
Alexander Nasonov

PS. Example of generated code:

  void f_MSC__MultimediaSystemControlMessage()
  {
      // CHOICE { < 4 field(s) > ,... }
      size_t len;
      unsigned char* saved_byte;
      unsigned int choice = GetBits3();
      switch(choice)
      {
        case 0:
          f_MSC__MultimediaSystemControlMessage__request();
          break;
        case 1:
          f_MSC__MultimediaSystemControlMessage__response();
          break;
        case 2:
          f_MSC__MultimediaSystemControlMessage__command();
          break;
        case 3:
          f_MSC__MultimediaSystemControlMessage__indication();
          break;
        case 4: case 5: // small number bit is 0
          choice = GetBits5() + ((choice - 4) << 5);
          SkipDataWithSemiConstrainedLength();
          break;
        default: // small number bit is 1
          UngetBits(1);
          SkipDataWithSemiConstrainedLength();
          SkipDataWithSemiConstrainedLength();
          break;
      }
  }

  reply	other threads:[~2003-10-16 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-16 13:25 ASN.1 decoder for h323-conntrack-nat Alexander Nasonov
2003-10-16 13:42 ` Jozsef Kadlecsik
2003-10-16 14:11   ` Alexander Nasonov [this message]
2003-10-17  8:02     ` Jozsef Kadlecsik
2003-10-17  9:37       ` Alexander Nasonov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F8EA725.9090000@yandex.ru \
    --to=alnsn-mycop@yandex.ru \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=netfilter-devel@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.