[squeak-dev] Re: [Pharo-users] encoding challenge

Marcus Denker marcus.denker at inria.fr
Sat Dec 19 08:36:42 UTC 2015


Hi,

If you are interested in ASN.1, there is an implementation of that as part of the SS7 project:
CI Server is here:

	https://ci.hartl.name/job/ASN.1/

This implements a ASN.1 parser. This means you do not have to do the encoding
yourself but you can use the ASN.1 as published. Very useful when implementing protocols that
are specified using ASN.1, e.g. all the telephony stuff for mobile networks.

If it makes sense to use in this context I am not sure.

	Marcus

> On 19 Dec 2015, at 09:22, Robert Withers <robert.w.withers at gmail.com> wrote:
> 
> It turns out my problem was elsewhere. These convert just fine.
> 
> My issue is the combination of flipping the whole stack to frames and adding headers and header method calls down at the Transport layer. The session layer is actually 2 sub-layers, data on top of control. In this case, we need a data frame but no control frame, so the transport is frameless. It is blowing up on me because control messages have an artificial frame.
> 
> I will look into Asn1Der encoding of the control messages, however.
> 
> cheers,,
> robert
> 
> On 12/19/2015 01:09 AM, Robert Withers wrote:
>> A core part of communications, whether online or to persistence, is encoding, or marshalling.  Let's do an example! Thank you for your thoughtful, earnest participation, as God wills it.
>> 
>> Here are 2 methods that encode and decode a DateAndTime object, but rather poorly. I've been going without much sleep for a bit and I can't figure it out. Here is the code in hopes that some will find this an interesting exercise in team and community building. For that intention, as a beginning.  What's the best solution?
>> 
>> Let's show them how to code when given the space in the environment.  Tnks! :)
>> 
>> In class ASN1UTCTimeType..
>> 
>> encodeValue: anObject withDERStream: derStream
>> 
>>    | yy mo dd hh mm ss utcDateTime |
>>    yy :=  anObject year asString copyFrom: 3 to: 4.
>>    mo :=  anObject month asString padded: #left to: 2 with: $0.
>>    dd :=  anObject dayOfMonth asString padded: #left to: 2 with: $0.
>>    hh :=  anObject hour asString padded: #left to: 2 with: $0.
>>    mm :=  anObject minute asString padded: #left to: 2 with: $0.
>>    ss :=  anObject seconds asString padded: #left to: 2 with: $0.
>>    utcDateTime := (yy, mo, dd, hh, mm, ss, 'Z') asByteArray.
>>    derStream nextPutAll: utcDateTime.
>> 
>> 
>> 
>> decodeValueWithDERStream: derStream length: length
>> 
>>    | aUTCDateTime |
>>    aUTCDateTime := (derStream next: length) asByteArray asString.
>>    ^ (DateAndTime readFromString: (
>>        ((aUTCDateTime copyFrom: 1 to: 2) asInteger > 50 ifTrue: ['19'] ifFalse: ['20']),
>>        (aUTCDateTime copyFrom: 1 to: 2), '-',
>>        (aUTCDateTime copyFrom: 3 to: 4), '-',
>>        (aUTCDateTime copyFrom: 5 to: 6), 'T',
>>        (aUTCDateTime copyFrom: 7 to: 8), ':',
>>        (aUTCDateTime copyFrom: 9 to: 10), ':',
>>        (aUTCDateTime copyFrom: 11 to: 12)))
>>            offset: 0
>> 
>> 
> 
> -- 
> . .. .. ^,^ robert
> 



More information about the Squeak-dev mailing list