[PATCH] coding-style: Add exception to M12 rule for external enums
by Sjur Brændeland
From: Sjur Brændeland <sjur.brandeland(a)stericsson.com>
---
doc/coding-style.txt | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/doc/coding-style.txt b/doc/coding-style.txt
index 6fa355e..fb43891 100644
--- a/doc/coding-style.txt
+++ b/doc/coding-style.txt
@@ -205,6 +205,10 @@ default: // wrong
break;
}
+However if the enum comes from an external header file outside ofono
+we cannot make any assumption of how the enum is defined and this
+rule might not apply.
+
O1: Shorten the name
====================
Better to use abbreviation, rather than full name, to name a variable,
--
1.7.0.4
11 years, 10 months
[PATCH] plugin: Add ste modem initd integration
by Sjur Brændeland
From: Sjur Brændeland <sjur.brandeland(a)stericsson.com>
This patch introduces auto discovery of ST-Ericsson modems.
ST-Ericsson modems are managed by a Modem Init Daemon that
is responsible for start/stop/restart flashing etc. The
STE plugin monitors the modem state exposed from the
Modem Init Damon Dbus API. When the modem is in state "on"
the STE modem is created and registered.
---
Makefile.am | 5 ++
configure.ac | 6 ++
plugins/stemid.c | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 206 insertions(+), 0 deletions(-)
create mode 100644 plugins/stemid.c
diff --git a/Makefile.am b/Makefile.am
index f841b4c..aaf5de5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -81,6 +81,11 @@ gatchat_sources = gatchat/gatchat.h gatchat/gatchat.c \
udev_files = plugins/ofono.rules
+if STE_MODEM_INITD
+builtin_modules += stemid
+builtin_sources += plugins/stemid.c
+endif
+
if UDEV
builtin_modules += udev
builtin_sources += plugins/udev.c
diff --git a/configure.ac b/configure.ac
index 6aeab7c..6fafadd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,12 @@ AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
+AC_ARG_ENABLE(ste_modem_initd, AC_HELP_STRING([--disable-ste-modem-initd],
+ [disable auto discovery of STE modem using modem init daemon]),
+ [enable_ste_modem_initd=${enableval}])
+
+AM_CONDITIONAL(STE_MODEM_INITD, test "${enable_ste_modem_initd}" != "no")
+
if (test "${prefix}" = "NONE"); then
dnl no prefix and no localstatedir, so default to /var
if (test "$localstatedir" = '${prefix}/var'); then
diff --git a/plugins/stemid.c b/plugins/stemid.c
new file mode 100644
index 0000000..7041e5e
--- /dev/null
+++ b/plugins/stemid.c
@@ -0,0 +1,195 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 ST-Ericsson AB.
+ *
+ * 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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <net/if.h>
+
+#include <gdbus.h>
+#include <glib.h>
+#include <gatchat.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/dbus.h>
+#include <ofono/version.h>
+
+/*
+ * ST-Ericsson's modem init daemon defines the signal StateChange
+ * and the method GetState. When state is "on" the STE modem is
+ * created and registered.
+ */
+#define STATUS_CHANGED "StateChange"
+#define MID_SERVICE "com.stericsson.modeminit"
+#define MID_INTERFACE MID_SERVICE ".Modem"
+#define GET_STATE "GetState"
+#define MID_STATE_ON "on"
+#define MID_STATE_DISCONNECT "disconnect"
+#define TIMEOUT 5000
+
+static struct ofono_modem *ste_modem;
+static guint mid_api_watch;
+static guint mid_state_watch;
+
+static void handle_stemodem(const char *state)
+{
+
+ DBG("state:%s", state);
+
+ if (strcmp(state, MID_STATE_ON) == 0) {
+ int err;
+
+ if (ste_modem != NULL)
+ return;
+
+ ste_modem = ofono_modem_create("ste", "ste");
+ DBG("register STE modem");
+ err = ofono_modem_register(ste_modem);
+ } else {
+
+ if (ste_modem == NULL)
+ return;
+
+ ofono_modem_remove(ste_modem);
+ ste_modem = NULL;
+ }
+}
+
+static void mid_getstate_reply(DBusPendingCall *call, void *user_data)
+{
+ DBusMessage *reply;
+ char *state;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+ ofono_error("STE Modem Init Daemon is unavailable");
+ goto error;
+ }
+
+ if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &state,
+ DBUS_TYPE_INVALID) == FALSE) {
+ ofono_error("STE Modem Init Damon: bad signature for GetState");
+ goto error;
+ }
+
+ handle_stemodem(state);
+
+error:
+ dbus_message_unref(reply);
+}
+
+static gboolean mid_signal_status_change(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *state;
+
+ if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &state,
+ DBUS_TYPE_INVALID) == FALSE) {
+ ofono_error("STE Modem Init Daemon: invalid signal signature");
+ return FALSE;
+ }
+
+ handle_stemodem(state);
+ return TRUE;
+}
+
+static void mid_connect(DBusConnection *connection, void *user_data)
+{
+ DBusMessage *message;
+ DBusPendingCall *call;
+
+ DBG("");
+ message = dbus_message_new_method_call(MID_SERVICE, "/",
+ MID_INTERFACE, "GetState");
+
+ if (!message) {
+ ofono_error("Unable to allocate new D-Bus message");
+ goto error;
+ }
+
+ dbus_message_set_auto_start(message, FALSE);
+
+ if (dbus_connection_send_with_reply(connection, message,
+ &call, TIMEOUT) == FALSE) {
+ ofono_error("Sending D-Bus message failed");
+ goto error;
+ }
+
+ if (call == NULL) {
+ DBG("D-Bus connection not available");
+ goto error;
+ }
+
+ dbus_pending_call_set_notify(call, mid_getstate_reply, NULL, NULL);
+ dbus_pending_call_unref(call);
+
+error:
+ dbus_message_unref(message);
+}
+
+static void mid_disconnect(DBusConnection *connection, void *user_data)
+{
+ handle_stemodem(MID_STATE_DISCONNECT);
+}
+
+static int stemid_init()
+{
+ DBusConnection *connection;
+
+ DBG("");
+
+ connection = ofono_dbus_get_connection();
+
+ if (connection == NULL)
+ return -EIO;
+
+ mid_api_watch = g_dbus_add_service_watch(connection, MID_SERVICE,
+ mid_connect, mid_disconnect, NULL, NULL);
+
+ mid_state_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ MID_INTERFACE,
+ STATUS_CHANGED,
+ mid_signal_status_change,
+ NULL, NULL);
+ return 0;
+}
+
+static void stemid_exit()
+{
+ DBusConnection *connection = ofono_dbus_get_connection();
+
+ g_dbus_remove_watch(connection, mid_state_watch);
+ g_dbus_remove_watch(connection, mid_api_watch);
+}
+
+OFONO_PLUGIN_DEFINE(stemid, "STE modem init daemon dbus api", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, stemid_init, stemid_exit)
--
1.6.3.3
11 years, 10 months
[PATCH 0/4] Emergency Calls (3rd round)
by Andras Domokos
Here is a new proposal for emergency calls handling.
Steps in handling emergency calls:
- subscribe to modem online notifications (add modem online watcher)
- an emergency call detected (phone number is emergency number)
- increment emergency mode
- advertise "EmergencyMode" property change on D-Bus (first call)
- set modem online if it's in offline mode (minimal setup)
- adevertise "Online" property change on D-Bus
- if modem is not online postpone making the call, otherwise make
the emergency call
- when modem online notification comes and there is postponed call request
make the emergency call
- when an emergency call ends decrement emergency mode
- set modem offline if it was set online due to the emergency call (last call)
- advertise "Online" property change on D-Bus
- advertise "EmergencyMode" property change on D-Bus (last call)
Andras Domokos (4):
modem: add modem online-offline watch
modem: add EmergencyMode property
modem: move dial_request_cb function
voicecall: add emergency call handling
src/modem.c | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 12 ++++
src/voicecall.c | 175 ++++++++++++++++++++++++++++++++++++++++++++----------
3 files changed, 332 insertions(+), 33 deletions(-)
11 years, 10 months
[RFC PATCH 0/2] Differentiate HSPA technologies
by Rémi Denis-Courmont
Hello,
In some use cases, I need to be able to list the active and available
technologies. This patch set splits the three HSPA modes to enable which
this requires.
Rémi Denis-Courmont (2):
Distinguish HSDPA, HSUPA or both as access technologies
Update the network documentation
doc/network-api.txt | 5 +++--
src/common.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
--
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis
11 years, 10 months
[PATCH] doc: Add Location Services API
by Sjur Brændeland
From: Sjur Brændeland <sjur.brandeland(a)stericsson.com>
As requested, this is our initial proposal for a minimal API
in order to support E911, based on the 27.007 defined AT
commands.
We've discussed internally different names for this API:
AGNSSManager or AssistedGlobalNavigationSatelliteSystem,
but ended up with the simpler LocationServicesManager.
Looking forward to your comments on this API.
Regards,
Simon Lethbridge and
Sjur Brændeland
---
doc/location-services-api.txt | 56 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
create mode 100644 doc/location-services-api.txt
diff --git a/doc/location-services-api.txt b/doc/location-services-api.txt
new file mode 100644
index 0000000..18ef230
--- /dev/null
+++ b/doc/location-services-api.txt
@@ -0,0 +1,56 @@
+LocationServicesManager hierarchy
+=================================
+
+Service org.ofono
+Interface org.ofono.LocationServicesManager
+Object path [variable prefix]/{modem0,modem1,...}
+
+Methods dict GetProperties()
+
+ Returns properties for the modem object. See
+ the properties section for available properties.
+
+ Possible Errors: [service].Error.InvalidArguments
+
+ void SetProperty(string name, variant value)
+
+ Changes the value of the specified property. Only
+ properties that are listed as read-write are
+ changeable. On success a PropertyChanged signal
+ will be emitted.
+
+ Possible Errors: [service].Error.InvalidArguments
+ [service].Error.DoesNotExist
+
+ void SendPositioningControl(string xml_element)
+
+ Send an XML element conforming to the XML DTD for <pos>
+ as defined in 3GPP 27.007 Table 8.55-2. This xml is
+ used for transferring data associated with positioning
+ requests received via control plane from the network.
+ This includes assistance data requests and the results
+ of positioning procedures. This method maps directly to
+ the 3GPP 27.007 AT+CPOS command.
+
+
+Signals PropertyChanged(string name, variant value)
+
+ This signal indicates a changed value of the given
+ property.
+
+ PositioningRequest(string xml_element)
+
+ Receive an XML element conforming to the XML DTD for
+ <pos> in 3GPP 27.007. This xml is used for transferring
+ data associated with positioning requests received, via
+ control plane, from the network. This includes
+ measurement requests and assistance data. This signal
+ maps directly to the 3GPP defined +CPOSR unsolicited
+ result code.
+
+Properties boolean NetworkInitiatedProceduresEnabled [readwrite]
+
+ If NetworkInitiatedProceduresEnabled is False, then
+ no Position Requests from the network are accepted.
+ The modem is not enabled for positioning requests
+ from the networks view point.
--
1.6.3.3
11 years, 10 months
[PATCH v5b 0/3] stemodem: Add RTNL handling to gprs-context.c
by Sjur Brændeland
From: Sjur Brændeland <sjur.brandeland(a)stericsson.com>
This patch-set applies on top of:
"[PATCH v5] stemodem: Add RTNL functionality managing CAIF Network Interfaces."
I have broken this patch-set into three separate patches as requested.
1) Bug-fixes and renaming
2) Restructuring for creating interfaces statically
3) Introducing calls to caif_rtnl_* to actually use the network interfaces.
Regards,
Sjur
Sjur Brændeland (3):
stemodem: Fix for error handling, memleak and changed some defines
stemodem: Create network interfaces statically
stemodem: Use RTNL to create interfaces
drivers/stemodem/gprs-context.c | 222 ++++++++++++++++++++++++++-------------
1 files changed, 147 insertions(+), 75 deletions(-)
11 years, 10 months
[PATCH v5] stemodem: Add RTNL functionality managing CAIF Network Interfaces.
by Sjur Brændeland
From: Sjur Brændeland <sjur.brandeland(a)stericsson.com>
---
Makefile.am | 2 +
drivers/stemodem/caif_rtnl.c | 340 ++++++++++++++++++++++++++++++++++++++++++
drivers/stemodem/caif_rtnl.h | 29 ++++
3 files changed, 371 insertions(+), 0 deletions(-)
create mode 100644 drivers/stemodem/caif_rtnl.c
create mode 100644 drivers/stemodem/caif_rtnl.h
diff --git a/Makefile.am b/Makefile.am
index 05082de..f163b0a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -226,6 +226,8 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/stemodem/stemodem.c \
drivers/stemodem/voicecall.c \
drivers/stemodem/radio-settings.c \
+ drivers/stemodem/caif_rtnl.c \
+ drivers/stemodem/caif_rtnl.h \
drivers/stemodem/gprs-context.c \
drivers/stemodem/caif_socket.h \
drivers/stemodem/if_caif.h
diff --git a/drivers/stemodem/caif_rtnl.c b/drivers/stemodem/caif_rtnl.c
new file mode 100644
index 0000000..4ce2401
--- /dev/null
+++ b/drivers/stemodem/caif_rtnl.c
@@ -0,0 +1,340 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 ST-Ericsson AB.
+ *
+ * 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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <fcntl.h>
+#include <linux/rtnetlink.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+
+#include "if_caif.h"
+#include "caif_rtnl.h"
+
+#define NLMSG_TAIL(nmsg) \
+ ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
+
+#define RTNL_MSG_SIZE 4096
+
+struct rtnl_msg {
+ struct nlmsghdr n;
+ struct ifinfomsg i;
+ char data[RTNL_MSG_SIZE];
+};
+
+struct iplink_req {
+ guint32 rtnlmsg_seqnr;
+ gpointer user_data;
+ caif_rtnl_create_cb_t callback;
+};
+
+static GSList *pending_requests;
+static guint32 rtnl_seqnr;
+static guint rtnl_watch;
+static GIOChannel *rtnl_channel;
+
+static struct iplink_req *find_request(guint32 seq)
+{
+ GSList *list;
+
+ for (list = pending_requests; list; list = list->next) {
+ struct iplink_req *req = list->data;
+
+ if (req->rtnlmsg_seqnr == seq)
+ return req;
+ }
+
+ return NULL;
+}
+
+static void parse_newlink_param(struct ifinfomsg *msg, int size,
+ int *ifindex, char *ifname)
+{
+ struct rtattr *attr;
+
+ for (attr = IFLA_RTA(msg); RTA_OK(attr, size);
+ attr = RTA_NEXT(attr, size)) {
+
+ if (attr->rta_type == IFLA_IFNAME &&
+ ifname != NULL) {
+
+ strncpy(ifname, RTA_DATA(attr), IF_NAMESIZE);
+ ifname[IF_NAMESIZE-1] = '\0';
+ break;
+ }
+ }
+
+ *ifindex = msg->ifi_index;
+}
+
+static void parse_rtnl_message(const void *buf, size_t len)
+{
+ struct ifinfomsg *msg;
+ struct iplink_req *req = NULL;
+ char ifname[IF_NAMESIZE];
+ int ifindex;
+
+ while (len > 0) {
+ const struct nlmsghdr *hdr = buf;
+
+ if (!NLMSG_OK(hdr, len))
+ break;
+
+ switch (hdr->nlmsg_type) {
+ case RTM_NEWLINK:
+ req = g_slist_nth_data(pending_requests, 0);
+ if (req == NULL)
+ break;
+
+ msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
+ parse_newlink_param(msg, IFA_PAYLOAD(hdr),
+ &ifindex, ifname);
+
+ if (req->callback)
+ req->callback(ifindex, ifname, req->user_data);
+ break;
+
+ case NLMSG_ERROR:
+ req = find_request(hdr->nlmsg_seq);
+ if (req == NULL)
+ break;
+
+ DBG("nlmsg error req");
+ if (req->callback)
+ req->callback(-1, ifname, req->user_data);
+ break;
+ default:
+ break;
+ }
+
+ len -= hdr->nlmsg_len;
+ buf += hdr->nlmsg_len;
+
+ if (req) {
+ pending_requests = g_slist_remove(pending_requests,
+ req);
+ g_free(req);
+ req = NULL;
+ }
+ }
+}
+
+static int add_attribute(struct nlmsghdr *n, unsigned int maxlen, int type,
+ const void *data, int datalen)
+{
+ int len = RTA_LENGTH(datalen);
+ struct rtattr *rta;
+
+ if ((NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) {
+ DBG("attribute to large for message %d %d %d\n",
+ n->nlmsg_len, len, maxlen);
+ return -1;
+ }
+
+ rta = NLMSG_TAIL(n);
+ rta->rta_type = type;
+ rta->rta_len = len;
+ memcpy(RTA_DATA(rta), data, datalen);
+ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
+
+ return 0;
+}
+
+static void prep_rtnl_req(struct rtnl_msg *msg, int reqtype, guint seqnr)
+{
+ msg->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+ msg->n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL;
+ msg->n.nlmsg_type = reqtype;
+ msg->n.nlmsg_seq = seqnr;
+ msg->i.ifi_family = AF_UNSPEC;
+}
+
+static gboolean netlink_event(GIOChannel *chan,
+ GIOCondition cond, gpointer data)
+{
+ unsigned char buf[RTNL_MSG_SIZE];
+ int len;
+ int sk = g_io_channel_unix_get_fd(rtnl_channel);
+
+ if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
+ rtnl_watch = 0;
+ return FALSE;
+ }
+
+ memset(buf, 0, sizeof(buf));
+ len = recv(sk, (void *)&buf, sizeof(buf), MSG_DONTWAIT);
+ if (len < 0) {
+ if (len == -EAGAIN)
+ return TRUE;
+ rtnl_watch = 0;
+ return FALSE;
+ }
+
+ parse_rtnl_message(buf, len);
+
+ return TRUE;
+}
+
+int caif_rtnl_init(void)
+{
+ struct sockaddr_nl addr;
+ int sk, err;
+
+ sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
+ if (sk < 0)
+ return sk;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.nl_family = AF_NETLINK;
+ addr.nl_groups = RTMGRP_LINK;
+
+ err = bind(sk, (struct sockaddr *) &addr, sizeof(addr));
+ if (err < 0) {
+ close(sk);
+ return err;
+ }
+
+ rtnl_channel = g_io_channel_unix_new(sk);
+ g_io_channel_set_flags(rtnl_channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_close_on_unref(rtnl_channel, TRUE);
+
+ rtnl_watch = g_io_add_watch(rtnl_channel,
+ G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
+ netlink_event, NULL);
+
+ return 0;
+}
+
+void caif_rtnl_exit(void)
+{
+ GSList *list;
+
+ if (rtnl_watch > 0)
+ g_source_remove(rtnl_watch);
+
+ g_io_channel_unref(rtnl_channel);
+
+ for (list = pending_requests; list; list = list->next) {
+ struct iplink_req *req = list->data;
+ g_free(req);
+ }
+
+ g_slist_free(pending_requests);
+}
+
+int caif_rtnl_create_interface(int type, int connid, int loop,
+ caif_rtnl_create_cb_t cb, void *user_data)
+{
+ struct iplink_req *req;
+ struct sockaddr_nl addr;
+ int err, sk;
+ struct rtnl_msg msg;
+ struct rtattr *linkinfo;
+ struct rtattr *data_start;
+
+ req = g_try_new0(struct iplink_req, 1);
+ if (req == NULL)
+ return -ENOMEM;
+
+ req->user_data = user_data;
+ req->callback = cb;
+ memset(&msg, 0, RTNL_MSG_SIZE);
+
+ req->rtnlmsg_seqnr = ++rtnl_seqnr;
+ prep_rtnl_req(&msg, RTM_NEWLINK, req->rtnlmsg_seqnr);
+
+ linkinfo = NLMSG_TAIL(&msg.n);
+ add_attribute(&msg.n, sizeof(msg), IFLA_LINKINFO,
+ NULL, 0);
+ add_attribute(&msg.n, sizeof(msg), IFLA_INFO_KIND,
+ "caif", 4);
+ data_start = NLMSG_TAIL(&msg.n);
+ add_attribute(&msg.n, sizeof(msg), IFLA_INFO_DATA,
+ NULL, 0);
+
+ switch (type) {
+ case IFLA_CAIF_IPV4_CONNID:
+ case IFLA_CAIF_IPV6_CONNID:
+ add_attribute(&msg.n, sizeof(msg),
+ type, &connid,
+ sizeof(connid));
+ break;
+
+ case __IFLA_CAIF_UNSPEC:
+ case IFLA_CAIF_LOOPBACK:
+ case __IFLA_CAIF_MAX:
+ DBG("unsupported linktype");
+ return -EINVAL;
+ }
+
+ if (loop) {
+ add_attribute(&msg.n, sizeof(msg),
+ IFLA_CAIF_LOOPBACK, &loop, sizeof(loop));
+ }
+
+ data_start->rta_len = (void *)NLMSG_TAIL(&msg.n) - (void *)data_start;
+ linkinfo->rta_len = (void *)NLMSG_TAIL(&msg.n) - (void *)linkinfo;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.nl_family = AF_NETLINK;
+ sk = g_io_channel_unix_get_fd(rtnl_channel);
+ err = sendto(sk, &msg, msg.n.nlmsg_len, 0,
+ (struct sockaddr *) &addr, sizeof(addr));
+ if (err < 0)
+ goto error;
+
+ pending_requests = g_slist_append(pending_requests, req);
+ return 0;
+
+error:
+ g_free(req);
+ return err;
+}
+
+int caif_rtnl_delete_interface(int ifid)
+{
+ struct sockaddr_nl addr;
+ struct rtnl_msg msg;
+ int err;
+ int sk = g_io_channel_unix_get_fd(rtnl_channel);
+
+ memset(&msg, 0, sizeof(msg));
+ prep_rtnl_req(&msg, RTM_DELLINK, ++rtnl_seqnr);
+ msg.i.ifi_index = ifid;
+ memset(&addr, 0, sizeof(addr));
+ addr.nl_family = AF_NETLINK;
+
+ err = sendto(sk, &msg, msg.n.nlmsg_len, 0,
+ (struct sockaddr *) &addr, sizeof(addr));
+ if (err < 0)
+ return err;
+
+ return 0;
+}
diff --git a/drivers/stemodem/caif_rtnl.h b/drivers/stemodem/caif_rtnl.h
new file mode 100644
index 0000000..9e44b08
--- /dev/null
+++ b/drivers/stemodem/caif_rtnl.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 ST-Ericsson AB.
+ *
+ * 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
+ *
+ */
+typedef void (*caif_rtnl_create_cb_t) (int ifindex, char *ifname,
+ void *user_data);
+
+extern int caif_rtnl_create_interface(int type, int connid, int loop,
+ caif_rtnl_create_cb_t cb, void *user_data);
+extern int caif_rtnl_delete_interface(int ifid);
+
+extern int caif_rtnl_init(void);
+extern void caif_rtnl_exit(void);
--
1.6.3.3
11 years, 10 months
[RfC] SIM file watch support.
by Andrzej Zaborowski
In order to support the Refresh STK command we need to implement at
least two types of reset: UICC reset (manufacturer specific) and NAA
application reset. Other types can fall back to application reset
which can be implemented by removing all atoms and reinitialising them.
When we get a Refresh with "File Change Notification" we should first
check if we're even interested in the file. We check if the file is
being watched by any atom and whether the atom can deal with the change
dynamically. If not, we fall back to NAA application reset.
The proposed api lets the users of sim_fs_read register to
notifications of file change by adding a watch. In the simplest case
they can add a "null" watch for a file ID that they care about
(callback address is NULL), to indicate that the file is important to
us, but we haven't implemented a way to deal with the contents change
dynamically, or we can not.
(Maybe all files being read should automatically become watched, but
some files might be read only on some user action, in that case we
don't need to watch them)
stk.c will check if any of the file IDs supplied in the command have
any watches on them. If there are only watches with non-NULL
callback, it'll call all of them and not reset application. If
there are any NULL notifiers, then stk.c will fall back to full
application reset. If any of the files were cached, they need to
be re-read.
---
src/simfs.h | 12 ++++++++++++
src/sim.c | 21 ++++++++++++++++++++-
2 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/src/simfs.h b/src/simfs.h
index ef962db..679955a 100644
--- a/src/simfs.h
+++ b/src/simfs.h
@@ -25,6 +25,8 @@ typedef void (*sim_fs_read_info_cb_t)(int ok, unsigned char file_status,
int total_length, int record_length,
void *userdata);
+typedef void (*sim_fs_ef_notify_t)(int id, void *userdata);
+
struct sim_fs *sim_fs_new(struct ofono_sim *sim,
const struct ofono_sim_driver *driver);
@@ -48,3 +50,13 @@ char *sim_fs_get_cached_image(struct sim_fs *fs, int id);
void sim_fs_cache_image(struct sim_fs *fs, const char *image, int id);
void sim_fs_free(struct sim_fs *fs);
+
+int sim_fs_add_ef_watch(struct sim_fs *fs, int id,
+ sim_fs_ef_notify_t *notify, void *userdata);
+
+int sim_fs_remove_ef_watch(struct sim_fs *fs, int id,
+ sim_fs_ef_notify_t *notify, void *userdata);
+
+ofono_bool_t sim_fs_has_empty_watches(struct sim_fs *fs, int id);
+
+int sim_fs_notify_file_change(struct sim_fs *fs, int id);
diff --git a/src/sim.c b/src/sim.c
index 02ab329..ea36756 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1184,15 +1184,23 @@ static void sim_ready(enum ofono_sim_state new_state, void *user)
{
struct ofono_sim *sim = user;
- if (new_state != OFONO_SIM_STATE_READY)
+ if (new_state != OFONO_SIM_STATE_READY) {
+ sim_fs_remove_ef_watch(sim->simfs, SIM_EFMSISDN_FILEID,
+ NULL, sim);
+
return;
+ }
sim_own_numbers_update(sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFMSISDN_FILEID, NULL, sim);
ofono_sim_read(sim, SIM_EFSDN_FILEID, OFONO_SIM_FILE_STRUCTURE_FIXED,
sim_sdn_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFSDN_FILEID, NULL, sim);
+
ofono_sim_read(sim, SIM_EFIMG_FILEID, OFONO_SIM_FILE_STRUCTURE_FIXED,
sim_efimg_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFIMG_FILEID, NULL, sim);
}
static void sim_imsi_cb(const struct ofono_error *error, const char *imsi,
@@ -1437,6 +1445,7 @@ static void sim_efust_read_cb(int ok, int length, int record,
ofono_sim_read(sim, SIM_EFEST_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_efest_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFEST_FILEID, NULL, sim);
return;
@@ -1497,6 +1506,7 @@ static void sim_efphase_read_cb(int ok, int length, int record,
ofono_sim_read(sim, SIM_EFUST_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_efust_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFUST_FILEID, NULL, sim);
return;
}
@@ -1519,6 +1529,7 @@ static void sim_efphase_read_cb(int ok, int length, int record,
ofono_sim_read(sim, SIM_EFSST_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_efsst_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFSST_FILEID, NULL, sim);
}
static void sim_initialize_after_pin(struct ofono_sim *sim)
@@ -1526,10 +1537,12 @@ static void sim_initialize_after_pin(struct ofono_sim *sim)
ofono_sim_read(sim, SIM_EFPHASE_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_efphase_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFPHASE_FILEID, NULL, sim);
ofono_sim_read(sim, SIM_EFAD_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_ad_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFAD_FILEID, NULL, sim);
/*
* Read CPHS-support bits, this is still part of the SIM
@@ -1538,6 +1551,8 @@ static void sim_initialize_after_pin(struct ofono_sim *sim)
ofono_sim_read(sim, SIM_EF_CPHS_INFORMATION_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_cphs_information_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EF_CPHS_INFORMATION_FILEID,
+ NULL, sim);
}
static void sim_pin_query_cb(const struct ofono_error *error,
@@ -1828,6 +1843,7 @@ static void sim_initialize(struct ofono_sim *sim)
ofono_sim_read(sim, SIM_EF_ICCID_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_iccid_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EF_ICCID_FILEID, NULL, sim);
/* EFecc is read by the voicecall atom */
@@ -1842,9 +1858,12 @@ static void sim_initialize(struct ofono_sim *sim)
ofono_sim_read(sim, SIM_EFLI_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_efli_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFLI_FILEID, NULL, sim);
+
ofono_sim_read(sim, SIM_EFPL_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_efpl_read_cb, sim);
+ sim_fs_add_ef_watch(sim->simfs, SIM_EFPL_FILEID, NULL, sim);
}
int ofono_sim_read_bytes(struct ofono_sim *sim, int id,
--
1.7.1.86.g0e460.dirty
11 years, 10 months
[RFC 1/3] Simplify ofono_modem_set_powered() logic
by Gustavo F. Padovan
---
src/modem.c | 47 +++++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/src/modem.c b/src/modem.c
index 3776461..3fb6809 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -752,6 +752,7 @@ static GDBusSignalTable modem_signals[] = {
void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
{
DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t dbus_powered = powered;
if (modem->timeout > 0) {
g_source_remove(modem->timeout);
@@ -771,32 +772,34 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
modem->powered_pending = powered;
- if (modem->powered != powered) {
- dbus_bool_t dbus_powered = powered;
- modem->powered = powered;
+ if (modem->powered == powered)
+ goto out;
- if (modem->driver == NULL) {
- ofono_error("Calling ofono_modem_set_powered on a"
- "modem with no driver is not valid, "
- "please fix the modem driver.");
- return;
- }
+ modem->powered = powered;
- ofono_dbus_signal_property_changed(conn, modem->path,
- OFONO_MODEM_INTERFACE,
- "Powered", DBUS_TYPE_BOOLEAN,
- &dbus_powered);
+ if (modem->driver == NULL) {
+ ofono_error("Calling ofono_modem_set_powered on a"
+ "modem with no driver is not valid, "
+ "please fix the modem driver.");
+ return;
+ }
- if (powered) {
- modem_change_state(modem, MODEM_STATE_PRE_SIM);
+ ofono_dbus_signal_property_changed(conn, modem->path,
+ OFONO_MODEM_INTERFACE,
+ "Powered", DBUS_TYPE_BOOLEAN,
+ &dbus_powered);
- /* Force SIM Ready for devies with no sim atom */
- if (__ofono_modem_find_atom(modem,
- OFONO_ATOM_TYPE_SIM) == NULL)
- sim_state_watch(OFONO_SIM_STATE_READY, modem);
- } else
- modem_change_state(modem, MODEM_STATE_POWER_OFF);
- }
+ if (powered) {
+ modem_change_state(modem, MODEM_STATE_PRE_SIM);
+
+ /* Force SIM Ready for devies with no sim atom */
+ if (__ofono_modem_find_atom(modem,
+ OFONO_ATOM_TYPE_SIM) == NULL)
+ sim_state_watch(OFONO_SIM_STATE_READY, modem);
+ } else
+ modem_change_state(modem, MODEM_STATE_POWER_OFF);
+
+out:
if (powering_down && powered == FALSE) {
modems_remaining -= 1;
--
1.7.3.1
11 years, 10 months
[ANNOUNCE] oFono 0.35
by Denis Kenzior
Hi Everyone,
oFono 0.35 is out. This release is mostly a development release. We
also include a bug fix that precluded 2G sims from working correctly due
to FDN/BDN checks. 3G sims were not affected.
The first major change in this release is the included support of WAP
PUSH notifications. oFono now provides a way for the system to listen
to SMS messages containing WAP PUSH PDUs. Please see
doc/push-notification-api.txt for more details.
The other major change is the included support for SMS messages
formatted according to the Smart Messaging specification from Nokia.
This allows applications to send and receive vCard and vCalendar objects
over SMS. Traditionally this is used for e.g. sending business cards
and appointments over SMS. Please see doc/smart-messaging-api.txt for
more details.
ChangeLog:
- Fix issue with FDN and BDN enabled checks.
- Fix issue with capabilities and Phonet support.
- Fix issue with timeout for ISI network deregistration.
- Add support for Push Notification interface.
- Add support for Smart Messaging interface.
- Remove generic AT command modem plugin.
The signed tarballs for oFono 0.35 can be found on kernel.org [1] [2].
[1] http://www.kernel.org/pub/linux/network/ofono/ofono-0.35.tar.bz2
[2] http://www.kernel.org/pub/linux/network/ofono/ofono-0.35.tar.bz2.sign
Regards,
-Denis
11 years, 10 months