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 /],