Hi Shinjo,

thank you for working on that!

On 12.05.2024 00:47, Shinjo Park wrote:
After the OsmoDevCon 2024, I have set up a repository containing the GSMTAPv3
WIP version:https://gitea.osmocom.org/peremen/gsmtapv3

Looking at the proposed structure of the GSMTAPv3 header:

```
 /*! Structure of the GSMTAP pseudo-header */
struct gsmtap_hdr_v3 {
        uint8_t version;
        uint16_t hdr_len;
        uint8_t res;

        uint16_t type;
        uint16_t sub_type;

        uint8_t metadata[0];
} __attribute__((packed));
```

I suggest to re-order fields a bit, more specifically to place field 'res' before field 'hdr_len', so that the later is at least WORD-alighed (just like all the other fields).

```
 /*! Structure of the GSMTAP pseudo-header */
 struct gsmtap_hdr_v3 {
        uint8_t version;
-       uint16_t hdr_len;
        uint8_t res;
+       uint16_t hdr_len;
```

This way the structure would be identical to its unpacked equivalent, and, in theory, accessing those fields for storing and loading values would be faster.

http://www.catb.org/esr/structure-packing/ -- nice read about struct padding in C/C++ and manual field reordering.

Best regards,
Vadim.

--
- Vadim Yanitskiy <vyanitskiy at sysmocom.de>    http://www.sysmocom.de/
========================================================================
* sysmocom - systems for mobile communications GmbH
* Siemensstr. 26a
* 10551 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschaeftsfuehrer / Managing Director: Harald Welte

Reply via email to