ASN1 BER bit string encoding

View: New views
2 Messages — Rating Filter:   Alert me  

ASN1 BER bit string encoding

by Anders Nygren :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
When encoding a bit string, that has a size constraint that is a
range, and the value to encode
is given using 'named bits', the encoded value always contains the
maximum number of bits.
This is a little inefficient since it forces the transmission of more
bits that necessary.

This is not a real problem, except that we have to communicate with a
node that rejects the
message if the encoded bit string contains more than the minimum number of bits.

Also it might be a good idea to change lists:sort to lists:usort in
asn1rt_ber_bin:get_all_bitposes/3 in order to not getting an error if
the same named bit
is specified more than once/

/Anders

[asn1rt_berbin.patch]

diff otp_src_R13B02-1/lib/asn1/src//asn1rt_ber_bin.erl otp_src_R13B02-1_my/lib/asn1/src//asn1rt_ber_bin.erl
1268c1268,1269
< BitList = make_and_set_list(Max, ToSetPos, 0),
---
> BitsToEnc=lists:min([Max,lists:max([_Min,lists:last(ToSetPos)+1])]),
> BitList = make_and_set_list(BitsToEnc, ToSetPos, 0),
Only in otp_src_R13B02-1_my/lib/asn1/src/: asn1rt_ber_bin.erl~



________________________________________________________________
erlang-patches mailing list. See http://www.erlang.org/faq.html
erlang-patches (at) erlang.org

Re: ASN1 BER bit string encoding

by Anders Nygren :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 2, 2009 at 10:21 AM, Anders Nygren <anders.nygren@...> wrote:

> Hi
> When encoding a bit string, that has a size constraint that is a
> range, and the value to encode
> is given using 'named bits', the encoded value always contains the
> maximum number of bits.
> This is a little inefficient since it forces the transmission of more
> bits that necessary.
>
> This is not a real problem, except that we have to communicate with a
> node that rejects the
> message if the encoded bit string contains more than the minimum number of bits.
>
> Also it might be a good idea to change lists:sort to lists:usort in
> asn1rt_ber_bin:get_all_bitposes/3 in order to not getting an error if
> the same named bit
> is specified more than once/
>
> /Anders
>

Hi
I just want to check if there are any comments on this.

/Anders

________________________________________________________________
erlang-patches mailing list. See http://www.erlang.org/faq.html
erlang-patches (at) erlang.org