-SUBDIRS = gdbus gatchat isi include plugins drivers unit src doc
+SUBDIRS = gdbus gatchat gisi include plugins drivers unit src doc
DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles
COMPILER_FLAGS
-AC_OUTPUT(Makefile gdbus/Makefile gatchat/Makefile isi/Makefile
+AC_OUTPUT(Makefile gdbus/Makefile gatchat/Makefile gisi/Makefile
include/Makefile include/version.h src/Makefile
plugins/Makefile drivers/Makefile unit/Makefile
doc/Makefile)
#include "socket.h"
#include "client.h"
-struct isi_client {
+struct _GIsiClient {
uint8_t resource;
/* Requests */
guint source;
uint8_t prev[256], next[256];
guint timeout[256];
- isi_client_cb_t func[256];
+ GIsiResponseFunc func[256];
void *data[256];
/* Indications */
int fd;
guint source;
uint16_t count;
- isi_ind_cb_t func[256];
+ GIsiIndicationFunc func[256];
void *data[256];
} ind;
};
-static gboolean isi_callback(GIOChannel *, GIOCondition, gpointer);
-static gboolean isi_timeout(gpointer);
+static gboolean g_isi_callback(GIOChannel *channel, GIOCondition cond,
+ gpointer data);
+static gboolean g_isi_timeout(gpointer data);
-static inline struct isi_request *isi_req(struct isi_client *cl, uint8_t id)
+static inline GIsiRequest *g_isi_req(GIsiClient *cl, uint8_t id)
{
- return (struct isi_request *)(((uint8_t *)(void *)cl) + id);
+ return (GIsiRequest *)(((uint8_t *)(void *)cl) + id);
}
-static inline uint8_t isi_id(void *ptr)
+static inline uint8_t g_isi_id(void *ptr)
{
return ((uintptr_t)ptr) & 255;
}
-static inline struct isi_client *isi_cl(void *ptr)
+static inline GIsiClient *g_isi_cl(void *ptr)
{
- return (struct isi_client *)(((uintptr_t)ptr) & ~255);
+ return (GIsiClient *)(((uintptr_t)ptr) & ~255);
}
/**
* @param resource Phonet resource ID for the client
* @return NULL on error (see errno), an isi_client pointer on success,
*/
-struct isi_client *isi_client_create(uint8_t resource)
+GIsiClient *g_isi_client_create(uint8_t resource)
{
void *ptr;
- struct isi_client *cl;
+ GIsiClient *cl;
GIOChannel *channel;
unsigned i;
cl->fd = g_io_channel_unix_get_fd(channel);
cl->source = g_io_add_watch(channel,
G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
- isi_callback, cl);
+ g_isi_callback, cl);
g_io_channel_unref(channel);
return cl;
}
* Destroys an ISI client, cancels all pending transactions and subscriptions.
* @param client client to destroy
*/
-void isi_client_destroy(struct isi_client *client)
+void g_isi_client_destroy(GIsiClient *client)
{
unsigned id;
/**
* Make an ISI request and register a callback to process the response(s) to
* the resulting transaction.
- * @param cl ISI client (from isi_client_create())
+ * @param cl ISI client (from g_isi_client_create())
* @param buf pointer to request payload
* @param len request payload byte length
* @param cb callback to process response(s)
* @param opaque data for the callback
*/
-struct isi_request *isi_request_make(struct isi_client *cl,
- const void *__restrict buf, size_t len,
- unsigned timeout,
- isi_client_cb_t cb, void *opaque)
+GIsiRequest *g_isi_request_make(GIsiClient *cl, const void *__restrict buf,
+ size_t len, unsigned timeout,
+ GIsiResponseFunc cb, void *opaque)
{
struct iovec iov[2];
ssize_t ret;
if (timeout > 0)
cl->timeout[id] = g_timeout_add_seconds(timeout,
- isi_timeout, cl);
+ g_isi_timeout, cl);
else
cl->timeout[id] = 0;
- return isi_req(cl, id);
+ return g_isi_req(cl, id);
}
/**
* timeout.
* @param req request to cancel
*/
-void isi_request_cancel(struct isi_request *req)
+void g_isi_request_cancel(GIsiRequest *req)
{
- struct isi_client *cl = isi_cl(req);
- uint8_t id = isi_id(req);
+ GIsiClient *cl = g_isi_cl(req);
+ uint8_t id = g_isi_id(req);
cl->func[id] = NULL;
cl->data[id] = NULL;
#define PN_COMMGR 0x10
#define PNS_SUBSCRIBED_RESOURCES_IND 0x10
-static int isi_indication_init(struct isi_client *cl)
+static int g_isi_indication_init(GIsiClient *cl)
{
uint8_t msg[] = {
0, PNS_SUBSCRIBED_RESOURCES_IND, 1, cl->resource,
send(cl->ind.fd, msg, 4, 0);
cl->ind.source = g_io_add_watch(channel,
G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
- isi_callback, cl);
+ g_isi_callback, cl);
return 0;
}
-static void isi_indication_deinit(struct isi_client *client)
+static void g_isi_indication_deinit(GIsiClient *client)
{
uint8_t msg[] = {
0, PNS_SUBSCRIBED_RESOURCES_IND, 0,
* Subscribe to a given indication type for the resource that an ISI client
* is associated with. If the same type was already subscrived, the old
* subscription is overriden.
- * @param cl ISI client (fomr isi_client_create())
+ * @param cl ISI client (fomr g_isi_client_create())
* @param type indication type
* @param cb callback to process received indications
* @param data data for the callback
* @return 0 on success, a system error code otherwise.
*/
-int isi_subscribe(struct isi_client *cl, uint8_t type,
- isi_ind_cb_t cb, void *data)
+int g_isi_subscribe(GIsiClient *cl, uint8_t type,
+ GIsiIndicationFunc cb, void *data)
{
if (cb == NULL)
return EINVAL;
if (cl->ind.func[type] == NULL) {
if (cl->ind.count == 0) {
- int ret = isi_indication_init(cl);
+ int ret = g_isi_indication_init(cl);
if (ret)
return ret;
}
/**
* Unsubscribe from a given indication type.
- * @param client ISI client (from isi_client_create())
+ * @param client ISI client (from g_isi_client_create())
* @param type indication type.
*/
-void isi_unsubscribe(struct isi_client *client, uint8_t type)
+void g_isi_unsubscribe(GIsiClient *client, uint8_t type)
{
/* Unsubscribe */
if (client->ind.func[type] == NULL)
return;
client->ind.func[type] = NULL;
if (--client->ind.count == 0)
- isi_indication_deinit(client);
+ g_isi_indication_deinit(client);
}
/* Data callback for both responses and indications */
-static gboolean isi_callback(GIOChannel *channel, GIOCondition cond,
+static gboolean g_isi_callback(GIOChannel *channel, GIOCondition cond,
gpointer data)
{
- struct isi_client *cl = data;
+ GIsiClient *cl = data;
int fd = g_io_channel_unix_get_fd(channel);
bool indication = (fd != cl->fd);
int len;
return TRUE; /* Bad transaction ID */
if ((cl->func[id])(cl, buf + 1, len - 1, obj,
cl->data[id]))
- isi_request_cancel(isi_req(cl, id));
+ g_isi_request_cancel(g_isi_req(cl, id));
}
}
return TRUE;
}
-static gboolean isi_timeout(gpointer data)
+static gboolean g_isi_timeout(gpointer data)
{
- struct isi_request *req = data;
- struct isi_client *cl = isi_cl(req);
- uint8_t id = isi_id(req);
+ GIsiRequest *req = data;
+ GIsiClient *cl = g_isi_cl(req);
+ uint8_t id = g_isi_id(req);
assert(cl->func[id]);
(cl->func[id])(cl, NULL, 0, 0, cl->data[id]);
- isi_request_cancel(req);
+ g_isi_request_cancel(req);
return FALSE;
}
-int isi_client_error(const struct isi_client *client)
+int g_isi_client_error(const GIsiClient *client)
{ /* The only possible error at the moment */
return ETIMEDOUT;
}
--- /dev/null
+/*
+ * This file is part of oFono - Open Source Telephony
+ *
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __GISI_CLIENT_H
+#define __GISI_CLIENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+
+struct _GIsiClient;
+typedef struct _GIsiClient GIsiClient;
+
+struct _GIsiRequest;
+typedef struct _GIsiRequest GIsiRequest;
+
+typedef bool (*GIsiResponseFunc)(GIsiClient *client,
+ const void *restrict data, size_t len,
+ uint16_t object, void *opaque);
+
+typedef void (*GIsiIndicationFunc) (GIsiClient *client,
+ const void *restrict data, size_t len,
+ uint16_t object, void *opaque);
+
+GIsiClient *g_isi_client_create(uint8_t resource);
+
+void g_isi_client_destroy(GIsiClient *client);
+
+int g_isi_client_error(const GIsiClient *client);
+
+GIsiRequest *g_isi_request_make(GIsiClient *client, const void *data,
+ size_t len, unsigned timeout,
+ GIsiResponseFunc func, void *opaque);
+
+void g_isi_request_cancel(GIsiRequest *req);
+
+int g_isi_subscribe(GIsiClient *client, uint8_t type,
+ GIsiIndicationFunc func, void *opaque);
+
+void g_isi_unsubscribe(GIsiClient *client, uint8_t type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GISI_CLIENT_H */
#include "netlink.h"
-struct pn_netlink {
- pn_netlink_cb_t callback;
+struct _GPhonetNetlink {
+ GPhonetNetlinkFunc callback;
void *opaque;
guint watch;
};
/* Parser Netlink messages */
-static gboolean pn_nl_process(GIOChannel *channel, GIOCondition cond,
+static gboolean g_pn_nl_process(GIOChannel *channel, GIOCondition cond,
gpointer data)
{
struct {
ssize_t ret;
struct nlmsghdr *nlh;
int fd = g_io_channel_unix_get_fd(channel);
- struct pn_netlink *self = data;
+ GPhonetNetlink *self = data;
if (cond & (G_IO_NVAL|G_IO_HUP))
return FALSE;
}
/* Dump current Phonet address table */
-static int pn_netlink_query(int fd)
+static int g_pn_netlink_query(int fd)
{
struct {
struct nlmsghdr nlh;
return 0;
}
-struct pn_netlink *pn_netlink_start(pn_netlink_cb_t cb, void *opaque)
+GPhonetNetlink *g_pn_netlink_start(GPhonetNetlinkFunc cb, void *opaque)
{
GIOChannel *chan;
- struct pn_netlink *self;
+ GPhonetNetlink *self;
unsigned group = RTNLGRP_PHONET_IFADDR;
int fd;
if (setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
&group, sizeof(group)))
goto error;
- pn_netlink_query(fd);
+ g_pn_netlink_query(fd);
chan = g_io_channel_unix_new(fd);
if (chan == NULL)
self->callback = cb;
self->opaque = opaque;
self->watch = g_io_add_watch(chan, G_IO_IN|G_IO_ERR|G_IO_HUP,
- pn_nl_process, self);
+ g_pn_nl_process, self);
g_io_channel_unref(chan);
return 0;
return NULL;
}
-void pn_netlink_stop(struct pn_netlink *self)
+void g_pn_netlink_stop(GPhonetNetlink *self)
{
g_source_remove(self->watch);
g_free(self);
*
*/
-#ifndef OFONO_PHONET_NETLINK_H
-#define OFONO_PHONET_NETLINK_H 1
#include <stdbool.h>
#include <stdint.h>
-struct pn_netlink;
-typedef void (*pn_netlink_cb_t)(bool, uint8_t, unsigned, void *);
+#ifndef __GPHONET_NETLINK_H
+#define __GPHONET_NETLINK_H
-struct pn_netlink *pn_netlink_start(pn_netlink_cb_t, void *);
-void pn_netlink_stop(struct pn_netlink *self);
+#ifdef __cplusplus
+extern "C" {
#endif
+
+struct _GPhonetNetlink;
+typedef struct _GPhonetNetlink GPhonetNetlink;
+
+typedef void (*GPhonetNetlinkFunc)(bool up, uint8_t addr, unsigned idx,
+ void *data);
+
+GPhonetNetlink *g_pn_netlink_start(GPhonetNetlinkFunc func, void *data);
+void g_pn_netlink_stop(GPhonetNetlink *self);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GPHONET_NETLINK_H */
*
*/
-#ifndef OFONO_PHONET_SOCKET_H
-#define OFONO_PHONET_SOCKET_H 1
-
GIOChannel *phonet_new(uint8_t resource);
-size_t phonet_peek_length(GIOChannel *);
-ssize_t phonet_read(GIOChannel *, void *restrict, size_t, uint16_t *restrict,
- uint8_t *restrict);
-#endif
+size_t phonet_peek_length(GIOChannel *io);
+ssize_t phonet_read(GIOChannel *io, void *restrict buf, size_t len,
+ uint16_t *restrict obj, uint8_t *restrict res);
+++ /dev/null
-/*
- * This file is part of oFono - Open Source Telephony
- *
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Contact: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#ifndef OFONO_PHONET_CLIENT_H
-#define OFONO_PHONET_CLIENT_H 1
-#include <stdint.h>
-#include <stdbool.h>
-
-struct isi_client;
-struct isi_client *isi_client_create(uint8_t resource);
-void isi_client_destroy(struct isi_client *client);
-int isi_client_error(const struct isi_client *client);
-
-typedef bool (*isi_client_cb_t)(struct isi_client *client,
- const void *restrict data, size_t len,
- uint16_t object, void *opaque);
-struct isi_request;
-struct isi_request *isi_request_make(struct isi_client *, const void *, size_t,
- unsigned timeout, isi_client_cb_t, void *);
-void isi_request_cancel(struct isi_request *req);
-
-typedef void (*isi_ind_cb_t) (struct isi_client *client,
- const void *restrict data, size_t len,
- uint16_t object, void *opaque);
-int isi_subscribe(struct isi_client *client, uint8_t type,
- isi_ind_cb_t, void *);
-void isi_unsubscribe(struct isi_client *client, uint8_t type);
-#endif