Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. add/clean big-endian packed structs (struct_endianess.py) This is 1:1 the result of doing cd libosmocore ./contrib/struct_endianess.py git commit -a Running struct_endianess.py again should result in no changes. That means we could include such a check in the gerrit verification job now. Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 --- M include/osmocom/gprs/protocol/gsm_04_60.h M include/osmocom/gsm/protocol/gsm_03_41.h M include/osmocom/gsm/protocol/gsm_04_08.h M include/osmocom/gsm/protocol/gsm_04_08_gprs.h M include/osmocom/gsm/protocol/gsm_04_12.h M include/osmocom/gsm/protocol/gsm_04_14.h M include/osmocom/gsm/protocol/gsm_08_58.h M include/osmocom/gsm/protocol/gsm_44_318.h M tests/endian/endian_test.c 9 files changed, 647 insertions(+), 45 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Max: Looks good to me, but someone else must approve Pau Espin Pedrol: Looks good to me, but someone else must approve Stefan Sperling: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/gprs/protocol/gsm_04_60.h b/include/osmocom/gprs/protocol/gsm_04_60.h index 96e9ab7..5d5fca9 100644 --- a/include/osmocom/gprs/protocol/gsm_04_60.h +++ b/include/osmocom/gprs/protocol/gsm_04_60.h @@ -7,10 +7,12 @@ #pragma once #include +#include #if OSMO_IS_LITTLE_ENDIAN == 1 /* TS 04.60 10.3a.4.1.1 */ struct gprs_rlc_ul_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -26,10 +28,20 @@ spare_hi:1; uint8_t spare_lo:6, dummy:2; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t bsn2_hi:2, bsn1_lo:6; + uint8_t bsn2_lo:8; + uint8_t spare_hi:1, pi:1, rsb:1, cps:5; + uint8_t dummy:2, spare_lo:6; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.2.1 */ struct gprs_rlc_ul_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -44,10 +56,19 @@ spare_hi:5; uint8_t spare_lo:5, dummy:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t cps_hi:2, bsn1_lo:6; + uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1; + uint8_t dummy:3, spare_lo:5; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.3.1 */ struct gprs_rlc_ul_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -62,9 +83,17 @@ pi:1, spare:1, dummy:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t cps_hi:2, bsn1_lo:6; + uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -77,9 +106,18 @@ bsn2_hi:7; uint8_t bsn2_lo:3, cps:5; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t bsn2_hi:7, bsn1_lo:1; + uint8_t cps:5, bsn2_lo:3; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -91,9 +129,17 @@ uint8_t bsn1_lo:1, cps:3, dummy:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t dummy:4, cps:3, bsn1_lo:1; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -106,10 +152,18 @@ cps:4, spb:2, dummy:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Reviewer: Stefan Sperling Gerrit-Comment-Date: Wed, 19 Dec 2018 18:40:02 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Stefan Sperling has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Reviewer: Stefan Sperling Gerrit-Comment-Date: Tue, 18 Dec 2018 11:13:08 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Max has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Reviewer: Stefan Sperling Gerrit-Comment-Date: Mon, 17 Dec 2018 14:50:59 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Pau Espin Pedrol has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Reviewer: Stefan Sperling Gerrit-Comment-Date: Mon, 17 Dec 2018 14:45:47 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Hello Stefan Sperling, Pau Espin Pedrol, Max, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11787 to look at the new patch set (#4). Change subject: add/clean big-endian packed structs (struct_endianess.py) .. add/clean big-endian packed structs (struct_endianess.py) This is 1:1 the result of doing cd libosmocore ./contrib/struct_endianess.py git commit -a Running struct_endianess.py again should result in no changes. That means we could include such a check in the gerrit verification job now. Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 --- M include/osmocom/gprs/protocol/gsm_04_60.h M include/osmocom/gsm/protocol/gsm_03_41.h M include/osmocom/gsm/protocol/gsm_04_08.h M include/osmocom/gsm/protocol/gsm_04_08_gprs.h M include/osmocom/gsm/protocol/gsm_04_12.h M include/osmocom/gsm/protocol/gsm_04_14.h M include/osmocom/gsm/protocol/gsm_08_58.h M include/osmocom/gsm/protocol/gsm_44_318.h M tests/endian/endian_test.c 9 files changed, 647 insertions(+), 45 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/11787/4 -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Reviewer: Stefan Sperling
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Stefan Sperling has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 3: Code-Review+1 I agree with Max: More information in the log message couldn't hurt. -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Reviewer: Stefan Sperling Gerrit-Comment-Date: Mon, 17 Dec 2018 11:49:46 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Max has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 3: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/11787/3//COMMIT_MSG Commit Message: https://gerrit.osmocom.org/#/c/11787/3//COMMIT_MSG@7 PS3, Line 7: add/clean big-endian packed structs (struct_endianess.py) Please add exact call to struct_endianess.py you've used to make this change to make this reproducible. Also, please clarify if any manual editing was necessary or it's purely automated code change. -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Comment-Date: Fri, 14 Dec 2018 13:02:08 + Gerrit-HasComments: Yes Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 3: @laforge: now that it's here, ok to commit this? (pinging because this is starting to grow a beard) -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr Gerrit-Assignee: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Comment-Date: Wed, 05 Dec 2018 15:55:57 + Gerrit-HasComments: No Gerrit-HasLabels: No
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Pau Espin Pedrol has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 3: Code-Review+1 Fine for me since we don't want to spend more time on this for now. I'd like Harald to review it too though, since it's quite intrusive size-wise. -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Comment-Date: Tue, 20 Nov 2018 16:42:41 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 3: (1 comment) @pespin, am I missing something, or would you remove -1 now? https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h File include/osmocom/gsm/protocol/gsm_03_41.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h@36 PS2, Line 36: uint8_t language:4; > Ah nice, I didn't know the behaviour in packet structus was also to remove > padding intra-byte wise. […] feel free to submit a patch for the little-endian part (but I think it's not worth the effort) -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Comment-Date: Tue, 20 Nov 2018 15:59:08 + Gerrit-HasComments: Yes Gerrit-HasLabels: No
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Pau Espin Pedrol has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 2: (1 comment) https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h File include/osmocom/gsm/protocol/gsm_03_41.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h@36 PS2, Line 36: uint8_t language:4; > no, the struct is packed. They are both a single byte. […] Ah nice, I didn't know the behaviour in packet structus was also to remove padding intra-byte wise. Still I think it'd be a good idea to merge this kind of stuff into a single uint8_t, but not critical. -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 2 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Comment-Date: Mon, 19 Nov 2018 17:13:36 + Gerrit-HasComments: Yes Gerrit-HasLabels: No
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 3: (2 comments) https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gprs/protocol/gsm_04_60.h File include/osmocom/gprs/protocol/gsm_04_60.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gprs/protocol/gsm_04_60.h@33 PS2, Line 33: uint8_t tfi_hi:2, cv:4, si:1, r:1; > Please change the script to add lines/formatting like in the little endian > case. that's "impossible" since the order is reversed. Doing it the tivial way it usually is done so far with whitespace carried along in the regexes, it would end up as: uint8_ttfi_hi:8; cv:4, si:1, r:1, (sic) and I'm positively not going to spend time on that: it would involve interpreting indenting levels and open a whole nother chapter of pseudo intelligence. I actually also prefer the packed output in the big-endian section, so no matter what formatting the original author invented, the big-endian part is "one line per byte" and more compact; whitespace changes then (mostly) don't affect the big-endian part. To read the struct for human understanding, just read above. https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h File include/osmocom/gsm/protocol/gsm_03_41.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h@36 PS2, Line 36: uint8_t language:4; > Be careful here!! […] no, the struct is packed. They are both a single byte. If you want to have ignored bits, you need to add 'padding' members. (but you had me for a second there) try this: cat > /tmp/x.c
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Pau Espin Pedrol has posted comments on this change. ( https://gerrit.osmocom.org/11787 ) Change subject: add/clean big-endian packed structs (struct_endianess.py) .. Patch Set 2: Code-Review-1 (2 comments) https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gprs/protocol/gsm_04_60.h File include/osmocom/gprs/protocol/gsm_04_60.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gprs/protocol/gsm_04_60.h@33 PS2, Line 33: uint8_t tfi_hi:2, cv:4, si:1, r:1; Please change the script to add lines/formatting like in the little endian case. https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h File include/osmocom/gsm/protocol/gsm_03_41.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h@36 PS2, Line 36: uint8_t language:4; Be careful here!! Big endian generated code is not the same as in little endian. In little endian you are saying: I have 2 bytes, and for each I only care about the lower 4 bits (so it should never handle values greater than 16). In the big endian you are saying: I have 1 byte, and 4 lower bits are repreented by one variable, and the 4 higher bits by the other variable. So I see 2 possible issues here: * original little endian strucut looks suspicously wrong. Probably we want 1 byte with 2 variables instead of 2 bytes with 2 variables. We need to check that in specs. * Regardless of that, the script checking for endianess should take care of this case, since it's valid in general and used in some cases. -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 2 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder (102) Gerrit-Reviewer: Pau Espin Pedrol Gerrit-Comment-Date: Fri, 16 Nov 2018 10:49:20 + Gerrit-HasComments: Yes Gerrit-HasLabels: Yes
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11787 to look at the new patch set (#2). Change subject: add/clean big-endian packed structs (struct_endianess.py) .. add/clean big-endian packed structs (struct_endianess.py) Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 --- M include/osmocom/gprs/protocol/gsm_04_60.h M include/osmocom/gsm/protocol/gsm_03_41.h M include/osmocom/gsm/protocol/gsm_04_08.h M include/osmocom/gsm/protocol/gsm_04_08_gprs.h M include/osmocom/gsm/protocol/gsm_04_12.h M include/osmocom/gsm/protocol/gsm_04_14.h M include/osmocom/gsm/protocol/gsm_08_58.h M include/osmocom/gsm/protocol/gsm_44_318.h M tests/endian/endian_test.c 9 files changed, 647 insertions(+), 45 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/11787/2 -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 2 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder (102)
Change in libosmocore[master]: add/clean big-endian packed structs (struct_endianess.py)
Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/11787 Change subject: add/clean big-endian packed structs (struct_endianess.py) .. add/clean big-endian packed structs (struct_endianess.py) Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 --- M include/osmocom/gprs/protocol/gsm_04_60.h M include/osmocom/gsm/protocol/gsm_03_41.h M include/osmocom/gsm/protocol/gsm_04_08.h M include/osmocom/gsm/protocol/gsm_04_08_gprs.h M include/osmocom/gsm/protocol/gsm_04_12.h M include/osmocom/gsm/protocol/gsm_04_14.h M include/osmocom/gsm/protocol/gsm_08_58.h M include/osmocom/gsm/protocol/gsm_44_318.h M tests/endian/endian_test.c 9 files changed, 650 insertions(+), 62 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/11787/1 diff --git a/include/osmocom/gprs/protocol/gsm_04_60.h b/include/osmocom/gprs/protocol/gsm_04_60.h index 96e9ab7..5d5fca9 100644 --- a/include/osmocom/gprs/protocol/gsm_04_60.h +++ b/include/osmocom/gprs/protocol/gsm_04_60.h @@ -7,10 +7,12 @@ #pragma once #include +#include #if OSMO_IS_LITTLE_ENDIAN == 1 /* TS 04.60 10.3a.4.1.1 */ struct gprs_rlc_ul_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -26,10 +28,20 @@ spare_hi:1; uint8_t spare_lo:6, dummy:2; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t bsn2_hi:2, bsn1_lo:6; + uint8_t bsn2_lo:8; + uint8_t spare_hi:1, pi:1, rsb:1, cps:5; + uint8_t dummy:2, spare_lo:6; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.2.1 */ struct gprs_rlc_ul_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -44,10 +56,19 @@ spare_hi:5; uint8_t spare_lo:5, dummy:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t cps_hi:2, bsn1_lo:6; + uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1; + uint8_t dummy:3, spare_lo:5; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.3.1 */ struct gprs_rlc_ul_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -62,9 +83,17 @@ pi:1, spare:1, dummy:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t cps_hi:2, bsn1_lo:6; + uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -77,9 +106,18 @@ bsn2_hi:7; uint8_t bsn2_lo:3, cps:5; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t bsn2_hi:7, bsn1_lo:1; + uint8_t cps:5, bsn2_lo:3; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -91,9 +129,17 @@ uint8_t bsn1_lo:1, cps:3, dummy:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t dummy:4, cps:3, bsn1_lo:1; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -106,10 +152,18 @@ cps:4, spb:2, dummy:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1; +#endif } __attribute__ ((packed)); #else /* TS 04.60 10.3a.4.1.1 */ struct gprs_rlc_ul_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t tfi_hi:2, cv:4, si:1, @@ -125,10 +179,20 @@ cps:5;