Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DOCSIS-ConfigFile CPAN distribution.

Report information
The Basics
Id: 70882
Status: resolved
Priority: 0/
Queue: DOCSIS-ConfigFile

People
Owner: JHTHORSEN [...] cpan.org
Requestors: velladecin [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.6004
Fixed in: (no value)



Subject: ServiceClassName field should be zero-terminated
According to DOCSIS doco ServiceClassName field should be a string that is zero-terminated. The lenght of the field is 16 including the zero- terminator. Currently this is not being handled and modem config cannot be subsequently used, modems end up > reject(c) < due to wrong CmMic and CmtsMic. The doco says further that if the field is empty then a zero length string should be used. I have done some quick testing and the enclosed patch fixes this. A simple switch 'if $_[0]->{value}' in Encode.pm/stringz() looks after the 'zero length' if no parameter reference is present. This could perhaps be improved a little... Please let me know, if more info is required OS: cenos 5.5 (Final) kernel: 2.6.18 perl: v5.8.8 cheers v.v.
Subject: stringz.patch
--- lib/DOCSIS/ConfigFile/Encode.pm 2011-08-18 16:55:34.000000000 +1000 +++ lib/DOCSIS/ConfigFile/Encode.pm.new 2011-09-12 10:49:11.000000000 +1000 @@ -375,6 +375,20 @@ } } +=head2 stringz + +Returns a list of bytes representing the C<$str> with a zero +terminator at the end. It simply uses C</string> and adds +'%00' to the end of the string itself. +Only ServiceClassName needs this, see Syminfo.pm + +=cut + +sub stringz { + $_[0]->{value} .= '%00' if $_[0]->{value}; + return string (@_); +} + =head2 hexstr Will encode any hex encoded string into a list of bytes. The string --- lib/DOCSIS/ConfigFile/Decode.pm 2011-08-18 16:55:14.000000000 +1000 +++ lib/DOCSIS/ConfigFile/Decode.pm.new 2011-09-12 11:58:18.000000000 +1000 @@ -348,6 +348,17 @@ } } +=head2 stringz + +Same as string above. However this string is zero-terminated as needed +for ServiceClassName (see Syminfo.pm and Encode.pm) + +=cut + +sub stringz { + return string (@_); +} + =head2 hexstr Will unpack the input string and a string with leading "0x", followed --- lib/DOCSIS/ConfigFile/Syminfo.pm 2011-08-18 16:55:59.000000000 +1000 +++ lib/DOCSIS/ConfigFile/Syminfo.pm.new 2011-09-12 10:42:45.000000000 +1000 @@ -408,7 +408,7 @@ [qw/ UsServiceFlow 24 0 nested 0 0 1 /], [qw/ UsServiceFlowRef 1 24 ushort 1 65535 1 /], [qw/ UsServiceFlowId 2 24 uint 1 4294967295 1 /], - [qw/ ServiceClassName 4 24 string 2 16 1 /], + [qw/ ServiceClassName 4 24 stringz 2 16 1 /], [qw/ QosParamSetType 6 24 uchar 0 255 1 /], [qw/ TrafficPriority 7 24 uchar 0 7 1 /], [qw/ MaxRateSustained 8 24 uint 0 0 1 /], @@ -434,7 +434,7 @@ [qw/ DsServiceFlow 25 0 nested 0 0 1 /], [qw/ DsServiceFlowRef 1 25 ushort 1 65535 1 /], [qw/ DsServiceFlowId 2 25 uint 1 4294967295 1 /], - [qw/ ServiceClassName 4 25 string 2 16 1 /], + [qw/ ServiceClassName 4 25 stringz 2 16 1 /], [qw/ QosParamSetType 6 25 uchar 0 255 1 /], [qw/ TrafficPriority 7 25 uchar 0 7 1 /], [qw/ MaxRateSustained 8 25 uint 0 4294967295 1 /],
Hello, Thanks for the patch! I've applied the patch and made some changes: https://github.com/jhthorsen/docsis- configfile/commit/9bef9833e90db22ec01224310671045c38783525 The reason for the changes, is that I want the decoded format to be "human" friendly. This means that the "\0 character should be optional in the input, in my opinion. Could you tell me what you think? It would also be really nice if you could send me a config file (with as little config as possible) to illustrate the bug. That means a config file WITH the \0 character applied. I could then make a unittest where the config is decoded and encoded and then diffed against the original provided by you.
From: velladecin [...] hotmail.com
On Mon Sep 12 01:51:48 2011, JHTHORSEN wrote: Show quoted text
> Hello, > > Thanks for the patch! > > I've applied the patch and made some changes: > https://github.com/jhthorsen/docsis- > configfile/commit/9bef9833e90db22ec01224310671045c38783525 > > The reason for the changes, is that I want the decoded format to be > "human" friendly. This means that the "\0 character should be optional > in the input, in my opinion. > > Could you tell me what you think? >
sounds good to me, if the user 'zero-terminates' then good, if not then the module should look after it. Show quoted text
> It would also be really nice if you could send me a config file (with as > little config as possible) to illustrate the bug. That means a config > file WITH the \0 character applied. I could then make a unittest where > the config is decoded and encoded and then diffed against the original > provided by you.
i've got two configs one with zero-terminator and one without. mind you this is not working config, this only illustrates the diff. key used - vella123 $VAR1 = [ { 'name' => 'UsServiceFlow', 'nested' => [ { 'value' => 7, 'name' => 'QosParamSetType' }, { 'value' => '0x00000080', 'name' => 'RequestOrTxPolicy' }, { 'value' => 'DataS_U_512k', 'name' => 'ServiceClassName' }, { 'value' => 1, 'name' => 'UsServiceFlowRef' } ] }, ]; cheers v.v.
Subject: encoded.cm.zero
Download encoded.cm.zero
application/octet-stream 68b

Message body not shown because it is not plain text.

Subject: encoded.cm.non_zero
Download encoded.cm.non_zero
application/octet-stream 68b

Message body not shown because it is not plain text.

Just pushed a new release to CPAN: 0.61 Mon Oct 3 21:58:40 CEST 2011 - Fix RT70882: ServiceClassName need to be zero-terminated This is optional in input data structure and removed/not visible in decoded tree either