mirror of git://git.sysmocom.de/ofono
Eliminated bool, true and false from gisi
This commit is contained in:
parent
8001338da7
commit
a97a97147d
|
@ -570,14 +570,8 @@ static void g_isi_dispatch_response(GIsiClient *client, uint16_t obj,
|
||||||
|
|
||||||
req = *(GIsiRequest **)ret;
|
req = *(GIsiRequest **)ret;
|
||||||
|
|
||||||
if (req->func) {
|
if (!req->func || req->func(client, msg + 1, len - 1, obj, req->data))
|
||||||
bool handled;
|
g_isi_request_cancel(req);
|
||||||
|
|
||||||
handled = req->func(client, msg + 1, len - 1, obj, req->data);
|
|
||||||
if (!handled)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_isi_request_cancel(req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data callback for both responses and indications */
|
/* Data callback for both responses and indications */
|
||||||
|
|
|
@ -27,7 +27,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <gisi/modem.h>
|
#include <gisi/modem.h>
|
||||||
|
|
||||||
struct _GIsiClient;
|
struct _GIsiClient;
|
||||||
|
@ -36,16 +35,16 @@ typedef struct _GIsiClient GIsiClient;
|
||||||
struct _GIsiRequest;
|
struct _GIsiRequest;
|
||||||
typedef struct _GIsiRequest GIsiRequest;
|
typedef struct _GIsiRequest GIsiRequest;
|
||||||
|
|
||||||
typedef void (*GIsiVerifyFunc)(GIsiClient *client, bool alive,
|
typedef void (*GIsiVerifyFunc)(GIsiClient *client, gboolean alive,
|
||||||
uint16_t object, void *opaque);
|
uint16_t object, void *opaque);
|
||||||
|
|
||||||
typedef bool (*GIsiResponseFunc)(GIsiClient *client,
|
typedef gboolean (*GIsiResponseFunc)(GIsiClient *client,
|
||||||
const void *restrict data, size_t len,
|
const void *restrict data, size_t len,
|
||||||
uint16_t object, void *opaque);
|
uint16_t object, void *opaque);
|
||||||
|
|
||||||
typedef void (*GIsiIndicationFunc) (GIsiClient *client,
|
typedef void (*GIsiIndicationFunc) (GIsiClient *client,
|
||||||
const void *restrict data, size_t len,
|
const void *restrict data, size_t len,
|
||||||
uint16_t object, void *opaque);
|
uint16_t object, void *opaque);
|
||||||
|
|
||||||
GIsiClient *g_isi_client_create(GIsiModem *modem, uint8_t resource);
|
GIsiClient *g_isi_client_create(GIsiModem *modem, uint8_t resource);
|
||||||
|
|
||||||
|
@ -70,8 +69,8 @@ GIsiRequest *g_isi_request_make(GIsiClient *client, const void *data,
|
||||||
GIsiResponseFunc func, void *opaque);
|
GIsiResponseFunc func, void *opaque);
|
||||||
struct iovec;
|
struct iovec;
|
||||||
GIsiRequest *g_isi_request_vmake(GIsiClient *client, const struct iovec *iov,
|
GIsiRequest *g_isi_request_vmake(GIsiClient *client, const struct iovec *iov,
|
||||||
size_t iovlen, unsigned timeout,
|
size_t iovlen, unsigned timeout,
|
||||||
GIsiResponseFunc func, void *opaque);
|
GIsiResponseFunc func, void *opaque);
|
||||||
|
|
||||||
void g_isi_request_cancel(GIsiRequest *req);
|
void g_isi_request_cancel(GIsiRequest *req);
|
||||||
|
|
||||||
|
|
73
gisi/iter.c
73
gisi/iter.c
|
@ -25,7 +25,6 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
@ -49,7 +48,7 @@ static inline void bcd_to_mccmnc(const uint8_t *restrict bcd,
|
||||||
}
|
}
|
||||||
|
|
||||||
void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const void *restrict data,
|
void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const void *restrict data,
|
||||||
size_t len, size_t used, bool longhdr,
|
size_t len, size_t used, gboolean longhdr,
|
||||||
uint16_t sub_blocks)
|
uint16_t sub_blocks)
|
||||||
{
|
{
|
||||||
if (!data)
|
if (!data)
|
||||||
|
@ -69,25 +68,25 @@ void g_isi_sb_iter_init(GIsiSubBlockIter *iter, const void *restrict data,
|
||||||
|
|
||||||
iter->start = (uint8_t *)data + used;
|
iter->start = (uint8_t *)data + used;
|
||||||
iter->end = iter->start + len;
|
iter->end = iter->start + len;
|
||||||
iter->longhdr = false;
|
iter->longhdr = FALSE;
|
||||||
iter->sub_blocks = len > used ? iter->start[-1] : 0;
|
iter->sub_blocks = len > used ? iter->start[-1] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter)
|
gboolean g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter)
|
||||||
{
|
{
|
||||||
if (!iter)
|
if (!iter)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
if (iter->sub_blocks == 0)
|
if (iter->sub_blocks == 0)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
if (iter->start + (iter->longhdr ? 4 : 2) > iter->end)
|
if (iter->start + (iter->longhdr ? 4 : 2) > iter->end)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
if (iter->start + g_isi_sb_iter_get_len(iter) > iter->end)
|
if (iter->start + g_isi_sb_iter_get_len(iter) > iter->end)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter)
|
int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter)
|
||||||
|
@ -104,103 +103,103 @@ size_t g_isi_sb_iter_get_len(const GIsiSubBlockIter *iter)
|
||||||
return iter->start[1];
|
return iter->start[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
|
||||||
void **data, unsigned pos)
|
void **data, unsigned pos)
|
||||||
{
|
{
|
||||||
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|
||||||
|| iter->start + pos > iter->end)
|
|| iter->start + pos > iter->end)
|
||||||
return false;
|
return FALSE;
|
||||||
*data = (void *)iter->start + pos;
|
*data = (void *)iter->start + pos;
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
|
||||||
uint8_t *byte, unsigned pos)
|
uint8_t *byte, unsigned pos)
|
||||||
{
|
{
|
||||||
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|
||||||
|| iter->start + pos > iter->end)
|
|| iter->start + pos > iter->end)
|
||||||
return false;
|
return FALSE;
|
||||||
*byte = iter->start[pos];
|
*byte = iter->start[pos];
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
|
||||||
uint16_t *word, unsigned pos)
|
uint16_t *word, unsigned pos)
|
||||||
{
|
{
|
||||||
uint16_t val;
|
uint16_t val;
|
||||||
|
|
||||||
if (pos + 1 > g_isi_sb_iter_get_len(iter))
|
if (pos + 1 > g_isi_sb_iter_get_len(iter))
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
memcpy(&val, iter->start + pos, sizeof(uint16_t));
|
memcpy(&val, iter->start + pos, sizeof(uint16_t));
|
||||||
*word = ntohs(val);
|
*word = ntohs(val);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
|
||||||
uint32_t *dword, unsigned pos)
|
uint32_t *dword, unsigned pos)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
|
||||||
if (pos + 3 > g_isi_sb_iter_get_len(iter))
|
if (pos + 3 > g_isi_sb_iter_get_len(iter))
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
memcpy(&val, iter->start + pos, sizeof(uint32_t));
|
memcpy(&val, iter->start + pos, sizeof(uint32_t));
|
||||||
*dword = ntohl(val);
|
*dword = ntohl(val);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
|
||||||
char *mcc, char *mnc, unsigned pos)
|
char *mcc, char *mnc, unsigned pos)
|
||||||
{
|
{
|
||||||
if (pos + 2 > g_isi_sb_iter_get_len(iter))
|
if (pos + 2 > g_isi_sb_iter_get_len(iter))
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
bcd_to_mccmnc(iter->start + pos, mcc, mnc);
|
bcd_to_mccmnc(iter->start + pos, mcc, mnc);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
|
||||||
char **utf8, size_t len, unsigned pos)
|
char **utf8, size_t len, unsigned pos)
|
||||||
{
|
{
|
||||||
uint8_t *ucs2 = NULL;
|
uint8_t *ucs2 = NULL;
|
||||||
|
|
||||||
if (pos > g_isi_sb_iter_get_len(iter))
|
if (pos > g_isi_sb_iter_get_len(iter))
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
if (!utf8 || len == 0 || pos + len > g_isi_sb_iter_get_len(iter))
|
if (!utf8 || len == 0 || pos + len > g_isi_sb_iter_get_len(iter))
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
ucs2 = iter->start + pos;
|
ucs2 = iter->start + pos;
|
||||||
if (ucs2 + len > iter->end)
|
if (ucs2 + len > iter->end)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
*utf8 = g_convert((const char *)ucs2, len, "UTF-8//TRANSLIT", "UCS-2BE",
|
*utf8 = g_convert((const char *)ucs2, len, "UTF-8//TRANSLIT", "UCS-2BE",
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
return *utf8 != NULL;
|
return *utf8 != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
|
||||||
char **latin, size_t len, unsigned pos)
|
char **latin, size_t len, unsigned pos)
|
||||||
{
|
{
|
||||||
uint8_t *str = NULL;
|
uint8_t *str = NULL;
|
||||||
|
|
||||||
if (pos > g_isi_sb_iter_get_len(iter))
|
if (pos > g_isi_sb_iter_get_len(iter))
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
if (!latin || len == 0 || pos + len > g_isi_sb_iter_get_len(iter))
|
if (!latin || len == 0 || pos + len > g_isi_sb_iter_get_len(iter))
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
str = iter->start + pos;
|
str = iter->start + pos;
|
||||||
if (str + len > iter->end)
|
if (str + len > iter->end)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
*latin = g_strndup((char *)str, len);
|
*latin = g_strndup((char *)str, len);
|
||||||
|
|
||||||
return *latin != NULL;
|
return *latin != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_isi_sb_iter_next(GIsiSubBlockIter *iter)
|
gboolean g_isi_sb_iter_next(GIsiSubBlockIter *iter)
|
||||||
{
|
{
|
||||||
uint8_t len = g_isi_sb_iter_get_len(iter);
|
uint8_t len = g_isi_sb_iter_get_len(iter);
|
||||||
|
|
||||||
|
@ -208,13 +207,13 @@ bool g_isi_sb_iter_next(GIsiSubBlockIter *iter)
|
||||||
len = iter->longhdr ? 4 : 2;
|
len = iter->longhdr ? 4 : 2;
|
||||||
|
|
||||||
if (iter->sub_blocks == 0)
|
if (iter->sub_blocks == 0)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
if (iter->start + len > iter->end)
|
if (iter->start + len > iter->end)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
iter->start += len;
|
iter->start += len;
|
||||||
iter->sub_blocks--;
|
iter->sub_blocks--;
|
||||||
|
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
23
gisi/iter.h
23
gisi/iter.h
|
@ -29,7 +29,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
struct _GIsiSubBlockIter {
|
struct _GIsiSubBlockIter {
|
||||||
uint8_t *start;
|
uint8_t *start;
|
||||||
|
@ -46,28 +45,28 @@ void g_isi_sb_iter_init(GIsiSubBlockIter *iter,
|
||||||
void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter,
|
void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter,
|
||||||
const void *restrict data,
|
const void *restrict data,
|
||||||
size_t len, size_t used,
|
size_t len, size_t used,
|
||||||
bool longhdr,
|
gboolean longhdr,
|
||||||
uint16_t sub_blocks);
|
uint16_t sub_blocks);
|
||||||
bool g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter);
|
gboolean g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter);
|
||||||
|
|
||||||
bool g_isi_sb_iter_next(GIsiSubBlockIter *iter);
|
gboolean g_isi_sb_iter_next(GIsiSubBlockIter *iter);
|
||||||
|
|
||||||
int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter);
|
int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter);
|
||||||
size_t g_isi_sb_iter_get_len(const GIsiSubBlockIter *iter);
|
size_t g_isi_sb_iter_get_len(const GIsiSubBlockIter *iter);
|
||||||
|
|
||||||
bool g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
|
||||||
void **data, unsigned pos);
|
void **data, unsigned pos);
|
||||||
bool g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
|
||||||
uint8_t *byte, unsigned pos);
|
uint8_t *byte, unsigned pos);
|
||||||
bool g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
|
||||||
uint16_t *word, unsigned pos);
|
uint16_t *word, unsigned pos);
|
||||||
bool g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
|
||||||
uint32_t *dword, unsigned pos);
|
uint32_t *dword, unsigned pos);
|
||||||
bool g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
|
||||||
char *mcc, char *mnc, unsigned pos);
|
char *mcc, char *mnc, unsigned pos);
|
||||||
bool g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
|
||||||
char **utf8, size_t len, unsigned pos);
|
char **utf8, size_t len, unsigned pos);
|
||||||
bool g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
|
gboolean g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
|
||||||
char **ascii, size_t len, unsigned pos);
|
char **ascii, size_t len, unsigned pos);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <gisi/modem.h>
|
#include <gisi/modem.h>
|
||||||
|
|
||||||
|
|
45
gisi/pipe.c
45
gisi/pipe.c
|
@ -26,7 +26,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
@ -125,8 +124,8 @@ struct _GIsiPipe {
|
||||||
void *opaque;
|
void *opaque;
|
||||||
int error;
|
int error;
|
||||||
uint8_t handle;
|
uint8_t handle;
|
||||||
bool enabled;
|
gboolean enabled;
|
||||||
bool enabling;
|
gboolean enabling;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int g_isi_pipe_error(uint8_t code)
|
static int g_isi_pipe_error(uint8_t code)
|
||||||
|
@ -163,16 +162,16 @@ static void g_isi_pipe_handle_error(GIsiPipe *pipe, uint8_t code)
|
||||||
pipe->error_handler(pipe);
|
pipe->error_handler(pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_isi_pipe_created(GIsiClient *client,
|
static gboolean g_isi_pipe_created(GIsiClient *client,
|
||||||
const void *restrict data, size_t len,
|
const void *restrict data, size_t len,
|
||||||
uint16_t object, void *opaque)
|
uint16_t object, void *opaque)
|
||||||
{
|
{
|
||||||
GIsiPipe *pipe = opaque;
|
GIsiPipe *pipe = opaque;
|
||||||
const isi_pipe_resp_t *resp = data;
|
const isi_pipe_resp_t *resp = data;
|
||||||
|
|
||||||
if (len < 5 ||
|
if (len < 5 ||
|
||||||
resp->cmd != PNS_PIPE_CREATE_RESP)
|
resp->cmd != PNS_PIPE_CREATE_RESP)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
if (resp->pipe_handle != PN_PIPE_INVALID_HANDLE) {
|
if (resp->pipe_handle != PN_PIPE_INVALID_HANDLE) {
|
||||||
pipe->handle = resp->pipe_handle;
|
pipe->handle = resp->pipe_handle;
|
||||||
|
@ -182,7 +181,7 @@ static bool g_isi_pipe_created(GIsiClient *client,
|
||||||
pipe->handler(pipe);
|
pipe->handler(pipe);
|
||||||
} else
|
} else
|
||||||
g_isi_pipe_handle_error(pipe, resp->error_code);
|
g_isi_pipe_handle_error(pipe, resp->error_code);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,8 +219,8 @@ GIsiPipe *g_isi_pipe_create(GIsiModem *modem, void (*created)(GIsiPipe *),
|
||||||
pipe->handler = created;
|
pipe->handler = created;
|
||||||
pipe->error_handler = NULL;
|
pipe->error_handler = NULL;
|
||||||
pipe->error = 0;
|
pipe->error = 0;
|
||||||
pipe->enabling = false;
|
pipe->enabling = FALSE;
|
||||||
pipe->enabled = false;
|
pipe->enabled = FALSE;
|
||||||
pipe->handle = PN_PIPE_INVALID_HANDLE;
|
pipe->handle = PN_PIPE_INVALID_HANDLE;
|
||||||
|
|
||||||
if (pipe->client == NULL ||
|
if (pipe->client == NULL ||
|
||||||
|
@ -250,22 +249,22 @@ g_isi_pipe_check_resp(const GIsiPipe *pipe, uint8_t cmd,
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_isi_pipe_enabled(GIsiClient *client,
|
static gboolean g_isi_pipe_enabled(GIsiClient *client,
|
||||||
const void *restrict data, size_t len,
|
const void *restrict data, size_t len,
|
||||||
uint16_t object, void *opaque)
|
uint16_t object, void *opaque)
|
||||||
{
|
{
|
||||||
GIsiPipe *pipe = opaque;
|
GIsiPipe *pipe = opaque;
|
||||||
const isi_pipe_resp_t *resp;
|
const isi_pipe_resp_t *resp;
|
||||||
|
|
||||||
resp = g_isi_pipe_check_resp(pipe, PNS_PIPE_ENABLE_RESP, data, len);
|
resp = g_isi_pipe_check_resp(pipe, PNS_PIPE_ENABLE_RESP, data, len);
|
||||||
if (!resp)
|
if (!resp)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
g_isi_pipe_handle_error(pipe, resp->error_code);
|
g_isi_pipe_handle_error(pipe, resp->error_code);
|
||||||
pipe->enabling = false;
|
pipe->enabling = FALSE;
|
||||||
if (!pipe->error)
|
if (!pipe->error)
|
||||||
pipe->enabled = true;
|
pipe->enabled = TRUE;
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GIsiRequest *g_isi_pipe_enable(GIsiPipe *pipe)
|
static GIsiRequest *g_isi_pipe_enable(GIsiPipe *pipe)
|
||||||
|
@ -295,26 +294,26 @@ int g_isi_pipe_start(GIsiPipe *pipe)
|
||||||
if (pipe->handle != PN_PIPE_INVALID_HANDLE)
|
if (pipe->handle != PN_PIPE_INVALID_HANDLE)
|
||||||
g_isi_pipe_enable(pipe);
|
g_isi_pipe_enable(pipe);
|
||||||
else
|
else
|
||||||
pipe->enabling = true;
|
pipe->enabling = TRUE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not very useful, it will never have time to trigger */
|
/* Not very useful, it will never have time to trigger */
|
||||||
static bool g_isi_pipe_removed(GIsiClient *client,
|
static gboolean g_isi_pipe_removed(GIsiClient *client,
|
||||||
const void *restrict data, size_t len,
|
const void *restrict data, size_t len,
|
||||||
uint16_t object, void *opaque)
|
uint16_t object, void *opaque)
|
||||||
{
|
{
|
||||||
GIsiPipe *pipe = opaque;
|
GIsiPipe *pipe = opaque;
|
||||||
const isi_pipe_resp_t *resp;
|
const isi_pipe_resp_t *resp;
|
||||||
|
|
||||||
resp = g_isi_pipe_check_resp(pipe, PNS_PIPE_REMOVE_RESP, data, len);
|
resp = g_isi_pipe_check_resp(pipe, PNS_PIPE_REMOVE_RESP, data, len);
|
||||||
if (!resp)
|
if (!resp)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
pipe->handle = PN_PIPE_INVALID_HANDLE;
|
pipe->handle = PN_PIPE_INVALID_HANDLE;
|
||||||
pipe->error = -EPIPE;
|
pipe->error = -EPIPE;
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <gisi/modem.h>
|
#include <gisi/modem.h>
|
||||||
|
|
||||||
struct _GIsiServer;
|
struct _GIsiServer;
|
||||||
|
@ -36,9 +35,9 @@ typedef struct _GIsiServer GIsiServer;
|
||||||
struct _GIsiIncoming;
|
struct _GIsiIncoming;
|
||||||
typedef struct _GIsiIncoming GIsiIncoming;
|
typedef struct _GIsiIncoming GIsiIncoming;
|
||||||
|
|
||||||
typedef bool (*GIsiRequestFunc)(GIsiServer *server,
|
typedef gboolean (*GIsiRequestFunc)(GIsiServer *server,
|
||||||
const void *restrict data, size_t len,
|
const void *restrict data, size_t len,
|
||||||
GIsiIncoming *, void *opaque);
|
GIsiIncoming *, void *opaque);
|
||||||
|
|
||||||
GIsiServer *g_isi_server_create(GIsiModem *modem, uint8_t resource,
|
GIsiServer *g_isi_server_create(GIsiModem *modem, uint8_t resource,
|
||||||
uint8_t major, uint8_t minor);
|
uint8_t major, uint8_t minor);
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
@ -43,14 +42,14 @@ struct verify_data {
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool verify_cb(GIsiClient *client, const void *restrict data,
|
static gboolean verify_cb(GIsiClient *client, const void *restrict data,
|
||||||
size_t len, uint16_t object, void *opaque)
|
size_t len, uint16_t object, void *opaque)
|
||||||
{
|
{
|
||||||
const uint8_t *msg = data;
|
const uint8_t *msg = data;
|
||||||
struct verify_data *vd = opaque;
|
struct verify_data *vd = opaque;
|
||||||
GIsiVerifyFunc func = vd->func;
|
GIsiVerifyFunc func = vd->func;
|
||||||
|
|
||||||
bool alive = false;
|
gboolean alive = FALSE;
|
||||||
|
|
||||||
if (!msg)
|
if (!msg)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -60,18 +59,18 @@ static bool verify_cb(GIsiClient *client, const void *restrict data,
|
||||||
|
|
||||||
if (msg[1] == COMM_ISI_VERSION_GET_RESP && len >= 4) {
|
if (msg[1] == COMM_ISI_VERSION_GET_RESP && len >= 4) {
|
||||||
g_isi_version_set(client, msg[2], msg[3]);
|
g_isi_version_set(client, msg[2], msg[3]);
|
||||||
alive = true;
|
alive = TRUE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg[1] != COMM_ISA_ENTITY_NOT_REACHABLE_RESP)
|
if (msg[1] != COMM_ISA_ENTITY_NOT_REACHABLE_RESP)
|
||||||
alive = true;
|
alive = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (func)
|
if (func)
|
||||||
func(client, alive, object, vd->data);
|
func(client, alive, object, vd->data);
|
||||||
g_free(vd);
|
g_free(vd);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue