osmo_io: Improve handling and documentation of segmentation_cb

The read length is not needed in the segmentation callback, msgb
already has all the necessary information, the parameter previously was
just msgb_length(msg).

Also handle negative return values (except -EAGAIN) of the callback as
errors which cause the msg to be dropped. -EAGAIN will defer the msg.

Change-Id: I6a0eebb8d4490f09a3cc6eb97d4ff47b4a8fd377
diff --git a/include/osmocom/core/osmo_io.h b/include/osmocom/core/osmo_io.h
index c19ca67..d7402d6 100644
--- a/include/osmocom/core/osmo_io.h
+++ b/include/osmocom/core/osmo_io.h
@@ -42,8 +42,12 @@
 			/*! call-back function when write has completed on fd */
 			void (*write_cb)(struct osmo_io_fd *iofd, int res,
 					 const struct msgb *msg);
-			/*! call-back function to segment the data returned by read_cb */
-			int (*segmentation_cb)(struct msgb *msg, int data_len);
+			/*! call-back function to segment the data at message boundaries.
+			 *  Needs to return the size of the next message. If it returns
+			 *  -EAGAIN or a value larger than msgb_length() (message is incomplete)
+			 *  osmo_io will wait for more data to be read. Other negative values
+			 *  cause the msg to be discarded. */
+			int (*segmentation_cb)(struct msgb *msg);
 		};
 
 		/* mode OSMO_IO_FD_MODE_RECVFROM_SENDTO: */