Attention is currently required from: Hoernchen, laforge.

dexter has posted comments on this change by Hoernchen. ( 
https://gerrit.osmocom.org/c/pysim/+/43719?usp=email )

Change subject: cattp: ETSI TS 102 127 transport for OTA over BIP UDP
......................................................................


Patch Set 1: Code-Review+1

(15 comments)

Patchset:

PS1:
The logic looks ok to me, but there are a lot of magic numbers, which makes 
this module very hard to understand.


File pySim/cattp.py:

https://gerrit.osmocom.org/c/pysim/+/43719/comment/fc8e28cf_2a25e4d5?usp=email :
PS1, Line 54: HDR_LEN = 18            # TS 102 127 5.6.2, without a variable 
header area
Shouldn't this be 12 instead of 18? - However, in the code below I can see that 
18 is actually correct. Was just wondering why the spec says 12.

(The comment above this constant would look nicer)


https://gerrit.osmocom.org/c/pysim/+/43719/comment/6b34b1bf_3c6b6666?usp=email :
PS1, Line 68:
RST refers to connection reset like in TCP?


https://gerrit.osmocom.org/c/pysim/+/43719/comment/1d46a2d5_74520a00?usp=email :
PS1, Line 105:         self.data = bytes(data)
what if someone tries to instantiate a SYN PDU with data in it? Wouldn't that 
be illegal (see my other comment below?)


https://gerrit.osmocom.org/c/pysim/+/43719/comment/8977f892_003750d3?usp=email :
PS1, Line 136:         var = self._variable_header()
As far as I can see you are calling _variable_header only from here. Maybe turn 
it into a nested function or move the code into here?


https://gerrit.osmocom.org/c/pysim/+/43719/comment/221048ad_a5ea1352?usp=email :
PS1, Line 137:         hdr = bytearray([self.flags | (self.version & 0x03), 0, 
0, HDR_LEN + len(var)])
using construct wasn't an option? In other location you use it quite often, why 
not use it here too?


https://gerrit.osmocom.org/c/pysim/+/43719/comment/17c86fc1_ddffc20c?usp=email :
PS1, Line 144:         return bytes(hdr) + self.data
I wonder what would happen if self.syn is true and self.data has bytes. In ETSI 
TS 120 127, section 5.7.0 I find that the SYN PDU has a data length of 0, so 
this would be an illegal state. (same for the RST PDU)

Maybe it would be good to have some logic to detect such illegal cases and 
raise an exception then?


https://gerrit.osmocom.org/c/pysim/+/43719/comment/422a570d_8af8b79d?usp=email :
PS1, Line 154:                              (hdr_len, data_len, len(raw)))
I would recommend to split this. The first check directly after hdr_len = 
raw[3] and the second check after data_len = ... When hdr_lrn already contains 
values that are implausible, we should not continue.


https://gerrit.osmocom.org/c/pysim/+/43719/comment/30526dc4_8ae98c92?usp=email :
PS1, Line 156:             raise CatTpError('checksum mismatch')
maybe use constants for those offsets. I think this would be a lot easier to 
read.


https://gerrit.osmocom.org/c/pysim/+/43719/comment/9f85acaa_dc64c8d9?usp=email :
PS1, Line 163:             if len(var) < 5 or len(var) != 5 + var[4]:
I think you should comment this. On the 5 look the 5 looks strange, because in 
Figure 40 of the spec the Identification is depicted as a 16 bit field. But 
that is a trap. When looking it up, its actually a variable field with a one 
byte length. So the first comparison is correct, even though it appears to be 
wrong on the first look.

The second comparison targets adds the 5 byte of the fixed var part with the 
length field of the identification - also correct.

When you put a comment, please add a reference to: ETSI TS 102 127, section 5.5


https://gerrit.osmocom.org/c/pysim/+/43719/comment/c8d37da6_d07c03d7?usp=email :
PS1, Line 172:                 raise CatTpError('malformed EACK variable 
header')
So this checks if we have an uneven or even number of bytes in the variable 
part of the PDU. In the RST PDU case we should have an uneven number (I think 
tit should even be a fixed number). And in the EACK PDU case we must have an 
even number of bytes.

I would recommend to put a comment here, this is difficult to grasp.


https://gerrit.osmocom.org/c/pysim/+/43719/comment/1d58bd07_56ba0abb?usp=email :
PS1, Line 537:     ACK into the same PDU."""
maybe put an API docstring for every constructor parameter? I think here it is 
most important as this is the interface the API user has to understand to make 
use of this module.


https://gerrit.osmocom.org/c/pysim/+/43719/comment/5abcdcbf_4d32b672?usp=email :
PS1, Line 551:     def bind(self) -> int:
Called by the API user, add API docstring.


https://gerrit.osmocom.org/c/pysim/+/43719/comment/1df624a9_b8733b4d?usp=email :
PS1, Line 558:     def serve_forever(self):
Called by the API user, add API docstring.


https://gerrit.osmocom.org/c/pysim/+/43719/comment/9e29830a_61cdcdbf?usp=email :
PS1, Line 564:                 raw, addr = self._sock.recvfrom(65535)
maybe add a constant for the number of bytes?



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/43719?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6f31493c1f0fb48fb3fd5382d8af2c905d365e54
Gerrit-Change-Number: 43719
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Attention: Hoernchen <[email protected]>
Gerrit-Attention: laforge <[email protected]>
Gerrit-Comment-Date: Fri, 25 Sep 2026 12:40:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

Reply via email to