Attention is currently required from: pespin.
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32758 )
Change subject: osmo_io: Improve handling of segmentation_cb ......................................................................
Patch Set 3:
(2 comments)
File include/osmocom/core/osmo_io.h:
https://gerrit.osmocom.org/c/libosmocore/+/32758/comment/3a5b6023_b113506f PS3, Line 46: * Needs to return the size of the next segment. If it returns
I'm not sure what "the size of the next segment" means here.
Maybe message? Think of IPA messages over a stream protocol such as TCP. We need to find the message boundaries again and the segmentation_cb returns the size of the next message (as soon as it has enough data to determine that).
File src/core/osmo_io.c:
https://gerrit.osmocom.org/c/libosmocore/+/32758/comment/bb40fb79_0c675e17 PS3, Line 249: } else if (pending_len < 0) {
I think this should be pending_len > 0?
No, pending_len is the difference between what was read so far and the necessary size of the next packet.
len (what segmentation_cb() returns) is the expected size of the next packet, msg_len is the size of what was read so far.
So for IPA and you read 3 bytes:
| 0x00 | 0x03 | 0x00 |
In that case segmentation_cb will return 6 (len in the message is 3 + size of ipa_head).
pending_len = -3 (3 bytes are missing), therefore we need to save the complete msg and defer handling anything.