mirror of git://git.sysmocom.de/ofono
gisi: Add getter for 16bit fields
This commit is contained in:
parent
b477941171
commit
0f0532eb6f
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
@ -102,6 +103,22 @@ gboolean g_isi_msg_data_get_byte(const GIsiMessage *msg, unsigned offset,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean g_isi_msg_data_get_word(const GIsiMessage *msg, unsigned offset,
|
||||||
|
uint16_t *word)
|
||||||
|
{
|
||||||
|
const uint8_t *buf = g_isi_msg_data(msg);
|
||||||
|
uint16_t val;
|
||||||
|
|
||||||
|
if (!buf || g_isi_msg_data_len(msg) < offset + 1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
memcpy(&val, buf + offset, sizeof(uint16_t));
|
||||||
|
if (word)
|
||||||
|
*word = ntohs(val);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean g_isi_msg_data_get_struct(const GIsiMessage *msg, unsigned offset,
|
gboolean g_isi_msg_data_get_struct(const GIsiMessage *msg, unsigned offset,
|
||||||
const void **type, size_t len)
|
const void **type, size_t len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,6 +60,8 @@ const void *g_isi_msg_data(const GIsiMessage *msg);
|
||||||
|
|
||||||
gboolean g_isi_msg_data_get_byte(const GIsiMessage *msg, unsigned offset,
|
gboolean g_isi_msg_data_get_byte(const GIsiMessage *msg, unsigned offset,
|
||||||
uint8_t *byte);
|
uint8_t *byte);
|
||||||
|
gboolean g_isi_msg_data_get_word(const GIsiMessage *msg, unsigned offset,
|
||||||
|
uint16_t *word);
|
||||||
gboolean g_isi_msg_data_get_struct(const GIsiMessage *msg, unsigned offset,
|
gboolean g_isi_msg_data_get_struct(const GIsiMessage *msg, unsigned offset,
|
||||||
const void **type, size_t len);
|
const void **type, size_t len);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue