From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= <sjurbren@gmail.com>
To: ofono@ofono.org
Subject: [PATCHv3 2/2] stemodem: Use RTNL to create network interfaces.
Date: Mon, 22 Nov 2010 00:01:41 +0100 [thread overview]
Message-ID: <1290380501-13594-2-git-send-email-sjurbren@gmail.com> (raw)
In-Reply-To: <d34704fde1df023d47b287f4dad2a528.squirrel@squirrel-webmail.surftown.com>
[-- Attachment #1: Type: text/plain, Size: 2868 bytes --]
From: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
Changes from V2:
o Squashed functions caif_if_create info ste_gprs_context_probe
drivers/stemodem/gprs-context.c | 44 ++++++++++++++++++++++++++++++++------
1 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index 3ccda87..f118453 100644
--- a/drivers/stemodem/gprs-context.c
+++ b/drivers/stemodem/gprs-context.c
@@ -47,6 +47,7 @@
#include "stemodem.h"
#include "caif_socket.h"
#include "if_caif.h"
+#include "caif_rtnl.h"
#define MAX_CAIF_DEVICES 4
#define MAX_DNS 2
@@ -172,12 +173,20 @@ static struct conn_info *conn_info_create(unsigned int channel_id)
return connection;
}
-/*
- * Creates a new IP interface for CAIF.
- */
-static gboolean caif_if_create(struct conn_info *conn)
+static void rtnl_callback(int ifindex, const char *ifname, void *user_data)
{
- return FALSE;
+ struct conn_info *conn = user_data;
+
+ if (ifindex < 0) {
+ conn->created = FALSE;
+ ofono_error("Failed to create caif interface %s",
+ conn->interface);
+ return;
+ }
+
+ strncpy(conn->interface, ifname, sizeof(conn->interface));
+ conn->ifindex = ifindex;
+ conn->created = TRUE;
}
/*
@@ -185,6 +194,18 @@ static gboolean caif_if_create(struct conn_info *conn)
*/
static void caif_if_remove(struct conn_info *conn)
{
+ if (!conn->created)
+ return;
+
+ if (caif_rtnl_delete_interface(conn->ifindex) < 0) {
+ ofono_error("Failed to delete caif interface %s",
+ conn->interface);
+ return;
+ }
+
+ DBG("removed CAIF interface ch:%d ifname:%s ifindex:%d\n",
+ conn->channel_id, conn->interface, conn->ifindex);
+ return;
}
static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
@@ -526,7 +547,7 @@ static int ste_gprs_context_probe(struct ofono_gprs_context *gc,
GAtChat *chat = data;
struct gprs_context_data *gcd;
struct conn_info *ci;
- int i;
+ int i,err;
gcd = g_new0(struct gprs_context_data, 1);
gcd->chat = g_at_chat_clone(chat);
@@ -539,7 +560,14 @@ static int ste_gprs_context_probe(struct ofono_gprs_context *gc,
ci = conn_info_create(i+1);
if (!ci)
return -ENOMEM;
- caif_if_create(ci);
+ err = caif_rtnl_create_interface(IFLA_CAIF_IPV4_CONNID,
+ ci->channel_id, FALSE,
+ rtnl_callback, ci);
+ if (err < 0) {
+ DBG("Failed to create IP interface for CAIF");
+ return err;
+ }
+
g_caif_devices = g_slist_append(g_caif_devices, ci);
}
@@ -571,10 +599,12 @@ static struct ofono_gprs_context_driver driver = {
void ste_gprs_context_init()
{
+ caif_rtnl_init();
ofono_gprs_context_driver_register(&driver);
}
void ste_gprs_context_exit()
{
+ caif_rtnl_exit();
ofono_gprs_context_driver_unregister(&driver);
}
--
1.7.0.4
next prev parent reply other threads:[~2010-11-21 23:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-14 18:51 [PATCH 1/2] stemodem: Create network interfaces statically Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-14 18:51 ` [PATCH 2/2] stemodem: Use RTNL to create network interfaces Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-18 8:03 ` [PATCH 1/2] stemodem: Create network interfaces statically Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-22 10:34 ` Denis Kenzior
2010-11-22 11:32 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-21 20:55 ` [PATCH v2 " Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-21 20:55 ` [PATCH v2 2/2] stemodem: Use RTNL to create network interfaces Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-21 22:20 ` George Matveev
2010-11-21 22:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-21 23:01 ` [PATCHv3 1/2] stemodem: Create network interfaces statically Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-21 23:01 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= [this message]
2010-11-21 20:55 ` [PATCH RESEND] stemodem: Change use of types Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-23 9:07 ` Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290380501-13594-2-git-send-email-sjurbren@gmail.com \
--to=sjurbren@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox