drivers: modem: socket: add modem_socket_next_packet_size

Let's hide the internals of sock->packet_sizes[] by adding a function
which returns the size of the next waiting packet.

Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
Michael Scott 2020-01-27 13:13:01 -08:00 committed by Jukka Rissanen
parent e23ada9d4a
commit 25ce3bf3eb
2 changed files with 21 additions and 1 deletions

View file

@ -19,6 +19,24 @@
* Packet Size Support Functions
*/
u16_t modem_socket_next_packet_size(struct modem_socket_config *cfg,
struct modem_socket *sock)
{
u16_t total = 0U;
k_sem_take(&cfg->sem_lock, K_FOREVER);
if (!sock || !sock->packet_count) {
goto exit;
}
total = sock->packet_sizes[0];
exit:
k_sem_give(&cfg->sem_lock);
return total;
}
static u16_t modem_socket_packet_get_total(struct modem_socket *sock)
{
int i;

View file

@ -59,7 +59,9 @@ struct modem_socket_config {
const struct socket_op_vtable *vtable;
};
/* return total size of remaining packets */
/* return size of the first packet */
u16_t modem_socket_next_packet_size(struct modem_socket_config *cfg,
struct modem_socket *sock);
int modem_socket_packet_size_update(struct modem_socket_config *cfg,
struct modem_socket *sock, int new_total);
int modem_socket_get(struct modem_socket_config *cfg, int family, int type,