From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= <sjurbren@gmail.com>
To: ofono@ofono.org
Subject: [PATCH 2/2] stemodem: Use RTNL to create network interfaces.
Date: Sun, 14 Nov 2010 19:51:03 +0100 [thread overview]
Message-ID: <1289760663-10334-2-git-send-email-sjurbren@gmail.com> (raw)
In-Reply-To: <1289760663-10334-1-git-send-email-sjurbren@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2298 bytes --]
From: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
drivers/stemodem/gprs-context.c | 43 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index d8db23b..899379c 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,38 @@ static struct conn_info *conn_info_create(unsigned int channel_id)
return connection;
}
+static void rtnl_callback(int ifindex, char *ifname, void *user_data)
+{
+ 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;
+}
+
/*
* Creates a new IP interface for CAIF.
*/
static gboolean caif_if_create(struct conn_info *conn)
{
- return FALSE;
+ int err;
+
+ err = caif_rtnl_create_interface(IFLA_CAIF_IPV4_CONNID,
+ conn->channel_id, FALSE,
+ rtnl_callback, conn);
+ if (err < 0) {
+ DBG("Failed to create IP interface for CAIF");
+ return FALSE;
+ }
+
+ return TRUE;
}
/*
@@ -185,6 +212,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,
@@ -573,10 +612,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-14 18:51 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 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= [this message]
2010-11-18 8:03 ` 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 ` [PATCHv3 2/2] stemodem: Use RTNL to create network interfaces Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
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=1289760663-10334-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