[PATCH 1/2] stemodem: Create network interfaces statically

2010-11-14 Thread Sjur Brændeland
From: Sjur Brændeland 

Changes:
o Restructure code so interfaces are created statically when probe is called.
o Removed some of the unnecessary initializations at declaration.
o No longer reporting "default gateway" on PtP IP Interface.
o Bugfix: Handle network initiated deactivation.
---
 drivers/stemodem/gprs-context.c |  153 ++-
 1 files changed, 85 insertions(+), 68 deletions(-)

diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index 05fec3f..d8db23b 100644
--- a/drivers/stemodem/gprs-context.c
+++ b/drivers/stemodem/gprs-context.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -65,10 +66,18 @@ struct gprs_context_data {
 };
 
 struct conn_info {
+   /*
+* cid is allocated in oFono Core and is identifying
+* the Account. cid = 0 indicates that it is currently unused.
+*/
unsigned int cid;
-   unsigned int device;
+   /* Id used by CAIF and EPPSD to identify the CAIF channel*/
unsigned int channel_id;
-   char interface[10];
+   /* Linux Interface Id */
+   unsigned int ifindex;
+   /* Linux Interface name */
+   char interface[IF_NAMESIZE];
+   gboolean created;
 };
 
 struct eppsd_response {
@@ -76,7 +85,6 @@ struct eppsd_response {
char ip_address[IP_ADDR_LEN];
char subnet_mask[IP_ADDR_LEN];
char mtu[IP_ADDR_LEN];
-   char default_gateway[IP_ADDR_LEN];
char dns_server1[IP_ADDR_LEN];
char dns_server2[IP_ADDR_LEN];
char p_cscf_server[IP_ADDR_LEN];
@@ -96,8 +104,6 @@ static void start_element_handler(GMarkupParseContext 
*context,
rsp->current = rsp->subnet_mask;
else if (!strcmp(element_name, "mtu"))
rsp->current = rsp->mtu;
-   else if (!strcmp(element_name, "default_gateway"))
-   rsp->current = rsp->default_gateway;
else if (!strcmp(element_name, "dns_server") &&
rsp->dns_server1[0] == '\0')
rsp->current = rsp->dns_server1;
@@ -123,7 +129,7 @@ static void text_handler(GMarkupParseContext *context,
 
if (rsp->current) {
strncpy(rsp->current, text, IP_ADDR_LEN);
-   rsp->current[IP_ADDR_LEN] = 0;
+   rsp->current[IP_ADDR_LEN] = '\0';
}
 }
 
@@ -153,8 +159,7 @@ static gint conn_compare_by_cid(gconstpointer a, 
gconstpointer b)
return 0;
 }
 
-static struct conn_info *conn_info_create(unsigned int device,
-   unsigned int channel_id)
+static struct conn_info *conn_info_create(unsigned int channel_id)
 {
struct conn_info *connection = g_try_new0(struct conn_info, 1);
 
@@ -162,7 +167,6 @@ static struct conn_info *conn_info_create(unsigned int 
device,
return NULL;
 
connection->cid = 0;
-   connection->device = device;
connection->channel_id = channel_id;
 
return connection;
@@ -171,7 +175,7 @@ static struct conn_info *conn_info_create(unsigned int 
device,
 /*
  * Creates a new IP interface for CAIF.
  */
-static gboolean caif_if_create(const char *interface, unsigned int connid)
+static gboolean caif_if_create(struct conn_info *conn)
 {
return FALSE;
 }
@@ -179,9 +183,8 @@ static gboolean caif_if_create(const char *interface, 
unsigned int connid)
 /*
  * Removes IP interface for CAIF.
  */
-static gboolean caif_if_remove(const char *interface, unsigned int connid)
+static void caif_if_remove(struct conn_info *conn)
 {
-   return FALSE;
 }
 
 static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
@@ -210,21 +213,13 @@ static void ste_eppsd_down_cb(gboolean ok, GAtResult 
*result,
DBG("Did not find data (used caif device) for"
"connection with cid; %d",
gcd->active_context);
-   goto error;
+   CALLBACK_WITH_FAILURE(cb, cbd->data);
+   return;
}
 
conn = l->data;
-
-   if (!caif_if_remove(conn->interface, conn->channel_id)) {
-   DBG("Failed to remove caif interface %s.",
-   conn->interface);
-   }
-
conn->cid = 0;
-   return;
-
-error:
-   CALLBACK_WITH_FAILURE(cb, cbd->data);
+   CALLBACK_WITH_SUCCESS(cb, cbd->data);
 }
 
 static void ste_eppsd_up_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -233,7 +228,7 @@ static void ste_eppsd_up_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
ofono_gprs_context_up_cb_t cb = cbd->cb;
struct ofono_gprs_context *gc = cbd->user;
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
-   struct conn_info *conn = NULL;
+   struct conn_info *conn;
GAtResultIter iter;
GSList *l;
int i;
@@ -241,17 +236,15 @@ static void ste_eppsd_up_cb(gboolean ok, GAtResul

Re: [PATCH 1/2] stemodem: Create network interfaces statically

2010-11-18 Thread Sjur Brændeland
Hi Denis & Marcel.

> From: Sjur Brændeland 
>
> Changes:
> o Restructure code so interfaces are created statically when probe is called.
> o Removed some of the unnecessary initializations at declaration.
> o No longer reporting "default gateway" on PtP IP Interface.
> o Bugfix: Handle network initiated deactivation.
> ---
>  drivers/stemodem/gprs-context.c |  153 
> ++-
>  1 files changed, 85 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
> index 05fec3f..d8db23b 100644
> --- a/drivers/stemodem/gprs-context.c
> +++ b/drivers/stemodem/gprs-context.c

Have you received this patch in readable format?
I'm sending patches using git send-email over gmail,
and when I check sent items in gmail, it comes up as base64 encoded.
Is this garbled for you as well?

BTW are you using patchwork or similar so I could check the patch
status somewhere?

Regards,
Sjur
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/2] stemodem: Create network interfaces statically

2010-11-22 Thread Denis Kenzior
Hi Sjur,

On 11/18/2010 02:03 AM, Sjur Brændeland wrote:
> Hi Denis & Marcel.
> 
>> From: Sjur Brændeland 
>>
>> Changes:
>> o Restructure code so interfaces are created statically when probe is called.
>> o Removed some of the unnecessary initializations at declaration.
>> o No longer reporting "default gateway" on PtP IP Interface.
>> o Bugfix: Handle network initiated deactivation.
>> ---
>>  drivers/stemodem/gprs-context.c |  153 
>> ++-
>>  1 files changed, 85 insertions(+), 68 deletions(-)
>>
>> diff --git a/drivers/stemodem/gprs-context.c 
>> b/drivers/stemodem/gprs-context.c
>> index 05fec3f..d8db23b 100644
>> --- a/drivers/stemodem/gprs-context.c
>> +++ b/drivers/stemodem/gprs-context.c
> 
> Have you received this patch in readable format?
> I'm sending patches using git send-email over gmail,
> and when I check sent items in gmail, it comes up as base64 encoded.
> Is this garbled for you as well?

They seem to come through fine for me at least.

> 
> BTW are you using patchwork or similar so I could check the patch
> status somewhere?
> 

Nope, but it has been suggested that this might be a good idea.  I'm
open to the idea of trying this out, but don't promise I will like it ;)

> Regards,
> Sjur

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/2] stemodem: Create network interfaces statically

2010-11-22 Thread Sjur Brændeland
Hi Denis.

>> Have you received this patch in readable format?
>> I'm sending patches using git send-email over gmail,
>> and when I check sent items in gmail, it comes up as base64 encoded.
>> Is this garbled for you as well?
>
> They seem to come through fine for me at least.

Good, that's a relief - thank you for checking this.

Regards,
Sjur
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono