Re: [PATCH] emulator: fix request tests

2011-06-16 Thread Denis Kenzior
Hi Frédéric,

On 06/16/2011 08:27 AM, Frédéric Danis wrote:
> ---
>  src/emulator.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 

Patch has been applied with a minor style amendment.

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


Re: [PATCH 1/2] linktop: reimplemented linktop plugin based on mbm with minimum features

2011-06-16 Thread Denis Kenzior
Hi Amit,



> @@ -127,93 +178,130 @@ static GAtChat *open_device(struct ofono_modem *modem,
>   if (chat == NULL)
>   return NULL;
>  
> - if (getenv("OFONO_AT_DEBUG"))
> - g_at_chat_set_debug(chat, linktop_debug, debug);
> -
>   return chat;
>  }
>  
> -static void linktop_disconnect(gpointer user_data)
> +static void linktop_disconnect(gpointer user_data);
> +
> +static gboolean reopen_callback(gpointer user_data)
>  {
>   struct ofono_modem *modem = user_data;
>   struct linktop_data *data = ofono_modem_get_data(modem);
> + const char *data_dev;
> +
> + data_dev = ofono_modem_get_string(modem, "DataDevice");
> + data->data_port = create_port(data_dev);
> + /* retry once if failed */
> + if (data->data_port == NULL) {
> + if (data->reopen_source > 0)
> + return FALSE;

Ok, this isn't right.  When mixing logic between two plugins, pay
attention! :)

reopen_callback is called from a GSource.  The way GSources work is that
returning FALSE means that the GSource should not be repeated, and
returning TRUE means it should be.  Since you never reset reopen_source
to 0 anywhere this won't work like you expect...  The reason this works
is probably because the 1 second timeout is enough...

> +
> + data->reopen_source = g_timeout_add_seconds(1,
> + reopen_callback, modem);
> + ofono_debug("opening data port failed, retrying...");
> + return FALSE;
> + }
>  
> - DBG("");
> -
> - if (data->gc)
> - ofono_gprs_context_remove(data->gc);
> -
> - g_at_chat_unref(data->modem);
> - data->modem = NULL;
> -
> - data->modem = open_device(modem, "Modem", "Modem: ");
> - if (data->modem == NULL)
> - return;
> + if (getenv("OFONO_AT_DEBUG"))
> + g_at_chat_set_debug(data->data_port, linktop_debug, "Data: ");
>  
> - g_at_chat_set_disconnect_function(data->modem,
> + g_at_chat_set_disconnect_function(data->data_port,
>   linktop_disconnect, modem);
>  
>   ofono_info("Reopened GPRS context channel");
>  
> - data->gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
> -
> + data->gc = ofono_gprs_context_create(modem, 0,
> + "atmodem", data->data_port);
>   if (data->gprs && data->gc)
>   ofono_gprs_add_context(data->gprs, data->gc);
> +
> + data->reopen_source = 0;
> +
> + return FALSE;
>  }
>  
> -static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
> +static void linktop_disconnect(gpointer user_data)
>  {
>   struct ofono_modem *modem = user_data;
> + struct linktop_data *data = ofono_modem_get_data(modem);
>  
> - DBG("");
> + DBG("%p, data->gc %p", modem, data->gc);
>  
> - ofono_modem_set_powered(modem, ok);
> + /* gprs_context has been destructed and needs not reopen */
> + if (data->gc == NULL)
> + return
> + 

You have a dangling tab on the line above.

> + ofono_gprs_context_remove(data->gc);
> +
> + g_at_chat_unref(data->data_port);
> + data->data_port = NULL;
> +
> + /* Waiting for the +CGEV: ME DEACT might also work */
> + if (data->reopen_source > 0)
> + g_source_remove(data->reopen_source);
> +
> + data->reopen_source = g_timeout_add_seconds(1, reopen_callback, modem);
>  }
>  
>  static int linktop_enable(struct ofono_modem *modem)
>  {
>   struct linktop_data *data = ofono_modem_get_data(modem);
> + const char *modem_dev;
> + const char *data_dev;
>  
>   DBG("%p", modem);
>  
> - data->modem = open_device(modem, "Modem", "Modem: ");
> - if (data->modem == NULL)
> - return -EINVAL;
> + modem_dev = ofono_modem_get_string(modem, "ModemDevice");
> + data_dev = ofono_modem_get_string(modem, "DataDevice");
>  
> - g_at_chat_set_disconnect_function(data->modem,
> - linktop_disconnect, modem);
> + DBG("%s, %s", modem_dev, data_dev);
>  
> - data->control = open_device(modem, "Control", "Control: ");
> - if (data->control == NULL) {
> - g_at_chat_unref(data->modem);
> - data->modem = NULL;
> + if (modem_dev == NULL || data_dev == NULL)
> + return -EINVAL;
> +
> + data->modem_port = create_port(modem_dev);
> + if (data->modem_port == NULL)
>   return -EIO;
> - }
>  
> - g_at_chat_send(data->control, "ATE0 +CMEE=1", none_prefix,
> - NULL, NULL, NULL);
> + if (getenv("OFONO_AT_DEBUG"))
> + g_at_chat_set_debug(data->modem_port, linktop_debug, "Modem: ");
>  
> - g_at_chat_send(data->modem, "AT", none_prefix,
> - NULL, NULL, NULL);
> + data->data_port = create_port(data_dev);
> + if (d

[PATCH] call-forward: Call forwarding state handling

2011-06-16 Thread Nicolas Bertrand
When CFU is active be cautious with conditional
call-forward activation/deactivation
---
 src/call-forwarding.c |   46 --
 1 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/src/call-forwarding.c b/src/call-forwarding.c
index 73ce433..eff5e9d 100644
--- a/src/call-forwarding.c
+++ b/src/call-forwarding.c
@@ -504,6 +504,7 @@ static DBusMessage *cf_get_properties_reply(DBusMessage 
*msg,
DBusMessageIter dict;
int i;
dbus_bool_t status;
+   GSList *hidden = NULL;
 
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -515,17 +516,33 @@ static DBusMessage *cf_get_properties_reply(DBusMessage 
*msg,
OFONO_PROPERTIES_ARRAY_SIGNATURE,
&dict);
 
-   for (i = 0; i < 4; i++)
-   property_append_cf_conditions(&dict, cf->cf_conditions[i],
-   BEARER_CLASS_VOICE,
-   cf_type_lut[i]);
-
if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) ||
cf->cfis_record_id > 0)
status = is_cfu_enabled(cf, NULL);
else
status = FALSE;
 
+   /*
+* If unconditional call-forwarding is enabled,
+* hide conditionnal status
+*/
+   if (status == TRUE) {
+   struct ofono_call_forwarding_condition cd = {0, 0, {"", 0}, 0};
+
+   for (i = 0; i < 4; i++)
+   hidden = g_slist_prepend(hidden, &cd);
+   }
+
+   for (i = 0; i < 4; i++)
+   property_append_cf_conditions(&dict, (status &&
+   i != CALL_FORWARDING_TYPE_UNCONDITIONAL) ?
+   hidden : cf->cf_conditions[i],
+   BEARER_CLASS_VOICE,
+   cf_type_lut[i]);
+
+   if (status == TRUE)
+   g_slist_free(hidden);
+
ofono_dbus_dict_append(&dict, "ForwardingFlagOnSim", DBUS_TYPE_BOOLEAN,
&status);
 
@@ -552,6 +569,13 @@ static void get_query_cf_callback(const struct ofono_error 
*error, int total,
cf->flags |= CALL_FORWARDING_FLAG_CACHED;
}
 
+   if (cf->query_next == CALL_FORWARDING_TYPE_UNCONDITIONAL &&
+   is_cfu_enabled(cf, NULL) == TRUE) {
+   DBusMessage *reply = cf_get_properties_reply(cf->pending, cf);
+   __ofono_dbus_pending_reply(&cf->pending, reply);
+   return;
+   }
+
if (cf->query_next == CALL_FORWARDING_TYPE_NOT_REACHABLE) {
DBusMessage *reply = cf_get_properties_reply(cf->pending, cf);
__ofono_dbus_pending_reply(&cf->pending, reply);
@@ -575,7 +599,8 @@ static DBusMessage *cf_get_properties(DBusConnection *conn, 
DBusMessage *msg,
struct ofono_modem *modem = __ofono_atom_get_modem(cf->atom);
 
if ((cf->flags & CALL_FORWARDING_FLAG_CACHED) ||
-   ofono_modem_get_online(modem) == FALSE)
+   ofono_modem_get_online(modem) == FALSE ||
+   is_cfu_enabled(cf, NULL) == TRUE)
return cf_get_properties_reply(msg, cf);
 
if (cf->driver->query == NULL)
@@ -698,6 +723,15 @@ static void set_property_callback(const struct ofono_error 
*error, void *data)
return;
}
 
+   if (cf->query_next != CALL_FORWARDING_TYPE_UNCONDITIONAL &&
+   is_cfu_enabled(cf, NULL) == TRUE) {
+   DBusMessage *reply;
+   cf->flags &= ~CALL_FORWARDING_FLAG_CACHED;
+   reply = dbus_message_new_method_return(cf->pending);
+   __ofono_dbus_pending_reply(&cf->pending, reply);
+   return;
+   }
+
/* Successfully set, query the entire set just in case */
set_query_next_cf_cond(cf);
 }
-- 
1.7.1

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


Re: ZTE 3G dongle fails to work on Ofono

2011-06-16 Thread Denis Kenzior
Hi,

On 06/15/2011 10:31 PM, Deng, Ying An wrote:
> Hi,
> 
>  
> 
> I am trying with ZTE MF180 USB dongles on ofono 0.48 version, but met
> with some error when authenticate SIM:
> 
> ofonod[2563]: Querying remaining pin retries failed
> 
> 

Feel free to ignore this error, it just means that the zte driver does
not implement PIN retry queries.  You would need to find the vendor
specific command that does this.

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


[PATCH] emulator: fix request tests

2011-06-16 Thread Frédéric Danis
---
 src/emulator.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index c120ad3..8821afd 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -433,7 +433,7 @@ static void brsf_cb(GAtServer *server, GAtServerRequestType 
type,
if (g_at_result_iter_next_number(&iter, &val) == FALSE)
goto fail;
 
-   if ((val < 0) && (val > 127))
+   if ((val < 0) || (val > 127))
goto fail;
 
em->r_features = val;
@@ -715,7 +715,7 @@ static void cmee_cb(GAtServer *server, GAtServerRequestType 
type,
if (g_at_result_iter_next_number(&iter, &val) == FALSE)
goto fail;
 
-   if (val < 0 && val > 1)
+   if (val != 0 && val != 1)
goto fail;
 
em->cmee_mode = val;
-- 
1.7.1

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


[PATCH 2/2] GAtPPP: Add PFC option support

2011-06-16 Thread Guillaume Zajac
---
 gatchat/gatppp.c  |   57 -
 gatchat/ppp.h |3 ++
 gatchat/ppp_lcp.c |   28 +++--
 3 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index a505db1..6704536 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -86,6 +86,7 @@ struct _GAtPPP {
gboolean acfc;
guint8 address;
guint8 control;
+   gboolean pfc;
 };
 
 void ppp_debug(GAtPPP *ppp, const char *str)
@@ -174,6 +175,7 @@ static void ppp_receive(const unsigned char *buf, gsize 
len, void *data)
struct ppp_header *header = (struct ppp_header *) buf;
gboolean acfc_frame = (header->address != PPP_ADDR_FIELD
|| header->control != PPP_CTRL);
+   gboolean pfc_frame = FALSE;
guint16 protocol;
const guint8 *packet;
 
@@ -185,6 +187,20 @@ static void ppp_receive(const unsigned char *buf, gsize 
len, void *data)
packet = ppp_info(buf);
}
 
+   pfc_frame = (protocol != LCP_PROTOCOL && protocol != CHAP_PROTOCOL &&
+   protocol != IPCP_PROTO && protocol != PPP_IP_PROTO);
+
+   if (ppp->pfc && pfc_frame) {
+   guint8 proto = (protocol >> 8) & 0xFF ;
+   packet = packet - 1;
+   /*
+* The only protocol that can be compressed is PPP_IP_PROTO
+* because first byte is 0x00.
+*/
+   if (proto == PPP_IP_COMPRESSED_PROTO)
+   protocol = PPP_IP_PROTO;
+   }
+
if (ppp_drop_packet(ppp, protocol))
return;
 
@@ -277,6 +293,32 @@ static void ppp_send_acfc_frame(GAtPPP *ppp, guint8 
*packet,
if (ppp->acfc)
offset = 2;
 
+   /* We remove the only address and control field */
+   if (g_at_hdlc_send(ppp->hdlc, packet + offset,
+   infolen + sizeof(*header) - offset)
+   == FALSE)
+   DBG(ppp, "Failed to send a frame\n");
+}
+
+static void ppp_send_acfc_pfc_frame(GAtPPP *ppp, guint8 *packet,
+   guint infolen)
+{
+   struct ppp_header *header = (struct ppp_header *) packet;
+   guint offset = 0;
+
+   if (ppp->acfc && ppp->pfc)
+   offset = 3;
+   else if (ppp->acfc)
+   offset = 2;
+   else if (ppp->pfc) {
+   /*
+* We remove only the 1st byte that is 0x00 of protocol field.
+*/
+   packet[2] = packet[1];
+   packet[1] = packet[0];
+   offset = 1;
+   }
+
if (g_at_hdlc_send(ppp->hdlc, packet + offset,
infolen + sizeof(*header) - offset)
== FALSE)
@@ -298,9 +340,17 @@ void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint 
infolen)
break;
case CHAP_PROTOCOL:
case IPCP_PROTO:
-   case PPP_IP_PROTO:
+   /*
+* We can't use PFC option because first byte of CHAP_PROTOCOL
+* and IPCP_PROTO is not equal to 0x00
+*/
ppp_send_acfc_frame(ppp, packet, infolen);
break;
+   case PPP_IP_PROTO:
+   /*
+* We can't use both compression options if they are negotiated
+*/
+   ppp_send_acfc_pfc_frame(ppp, packet, infolen);
}
 }
 
@@ -460,6 +510,11 @@ gboolean ppp_set_acfc_enabled(GAtPPP *ppp, gboolean acfc)
return ppp->acfc;
 }
 
+void ppp_set_pfc_enabled(GAtPPP *ppp, gboolean pfc)
+{
+   ppp->pfc = pfc;
+}
+
 static void io_disconnect(gpointer user_data)
 {
GAtPPP *ppp = user_data;
diff --git a/gatchat/ppp.h b/gatchat/ppp.h
index 3cf11f7..5efda31 100644
--- a/gatchat/ppp.h
+++ b/gatchat/ppp.h
@@ -27,6 +27,8 @@
 #define PPP_IP_PROTO   0x0021
 #define MD55
 
+#define PPP_IP_COMPRESSED_PROTO 0x21
+
 #define DBG(p, fmt, arg...) do {   \
char *str = g_strdup_printf("%s:%s() " fmt, __FILE__,   \
__FUNCTION__ , ## arg); \
@@ -132,4 +134,5 @@ void ppp_set_recv_accm(GAtPPP *ppp, guint32 accm);
 void ppp_set_xmit_accm(GAtPPP *ppp, guint32 accm);
 void ppp_set_mtu(GAtPPP *ppp, const guint8 *data);
 gboolean ppp_set_acfc_enabled(GAtPPP *ppp, gboolean acfc);
+void ppp_set_pfc_enabled(GAtPPP *ppp, gboolean pfc);
 struct ppp_header *ppp_packet_new(gsize infolen, guint16 protocol);
diff --git a/gatchat/ppp_lcp.c b/gatchat/ppp_lcp.c
index 24e7bae..2b62d25 100644
--- a/gatchat/ppp_lcp.c
+++ b/gatchat/ppp_lcp.c
@@ -58,12 +58,13 @@ enum lcp_options {
ACFC= 8,
 };
 
-/* Maximum size of all options, we only ever request ACCM, MRU and ACFC */
-#define MAX_CONFIG_OPTION_SIZE 12
+/* Maximum size of all options, we only ever request ACCM, MRU, ACFC and PFC */
+#define MAX_CONFIG_

[PATCH 1/2] GAtPPP: Add ACFC option support

2011-06-16 Thread Guillaume Zajac
---
 gatchat/gatppp.c  |  116 ++--
 gatchat/ppp.h |7 +++
 gatchat/ppp_lcp.c |   27 +++-
 3 files changed, 124 insertions(+), 26 deletions(-)

diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 5fb4146..a505db1 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -83,6 +83,9 @@ struct _GAtPPP {
int fd;
guint guard_timeout_source;
gboolean suspended;
+   gboolean acfc;
+   guint8 address;
+   guint8 control;
 };
 
 void ppp_debug(GAtPPP *ppp, const char *str)
@@ -168,17 +171,39 @@ static inline gboolean ppp_drop_packet(GAtPPP *ppp, 
guint16 protocol)
 static void ppp_receive(const unsigned char *buf, gsize len, void *data)
 {
GAtPPP *ppp = data;
-   guint16 protocol = ppp_proto(buf);
-   const guint8 *packet = ppp_info(buf);
+   struct ppp_header *header = (struct ppp_header *) buf;
+   gboolean acfc_frame = (header->address != PPP_ADDR_FIELD
+   || header->control != PPP_CTRL);
+   guint16 protocol;
+   const guint8 *packet;
+
+   if (acfc_frame) {
+   protocol = ppp_acfc_proto(buf);
+   packet = ppp_acfc_info(buf);
+   } else {
+   protocol = ppp_proto(buf);
+   packet = ppp_info(buf);
+   }
 
if (ppp_drop_packet(ppp, protocol))
return;
 
+   /*
+* RFC 1661:
+* If we received PPP packets with Adress and Control Field Compressed
+* although ACFC had not been negociated, we silently discard them.
+*/
+   if (!ppp->acfc && acfc_frame)
+   return;
+
switch (protocol) {
case PPP_IP_PROTO:
ppp_net_process_packet(ppp->net, packet);
break;
case LCP_PROTOCOL:
+   /* Those values will be tested while negociating ACFC option */
+   ppp->address = header->address;
+   ppp->control = header->control;
pppcp_process_packet(ppp->lcp, packet);
break;
case IPCP_PROTO:
@@ -196,37 +221,29 @@ static void ppp_receive(const unsigned char *buf, gsize 
len, void *data)
};
 }
 
-/*
- * transmit out through the lower layer interface
- *
- * infolen - length of the information part of the packet
- */
-void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint infolen)
+static void ppp_send_lcp_frame(GAtPPP *ppp, guint8 *packet, guint infolen)
 {
struct ppp_header *header = (struct ppp_header *) packet;
-   guint16 proto = ppp_proto(packet);
guint8 code;
-   gboolean lcp = (proto == LCP_PROTOCOL);
guint32 xmit_accm = 0;
gboolean sta = FALSE;
+   gboolean lcp;
 
/*
 * all LCP Link Configuration, Link Termination, and Code-Reject
 * packets must be sent with the default sending ACCM
 */
-   if (lcp) {
-   code = pppcp_get_code(packet);
-   lcp = code > 0 && code < 8;
-
-   /*
-* If we're going down, we try to make sure to send the final
-* ack before informing the upper layers via the ppp_disconnect
-* function.  Once we enter PPP_DEAD phase, no further packets
-* will be sent
-*/
-   if (code == PPPCP_CODE_TYPE_TERMINATE_ACK)
-   sta = TRUE;
-   }
+   code = pppcp_get_code(packet);
+   lcp = code > 0 && code < 8;
+
+   /*
+* If we're going down, we try to make sure to send the final
+* ack before informing the upper layers via the ppp_disconnect
+* function.  Once we enter PPP_DEAD phase, no further packets
+* will be sent
+*/
+   if (code == PPPCP_CODE_TYPE_TERMINATE_ACK)
+   sta = TRUE;
 
if (lcp) {
xmit_accm = g_at_hdlc_get_xmit_accm(ppp->hdlc);
@@ -251,6 +268,42 @@ void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint 
infolen)
g_at_hdlc_set_xmit_accm(ppp->hdlc, xmit_accm);
 }
 
+static void ppp_send_acfc_frame(GAtPPP *ppp, guint8 *packet,
+   guint infolen)
+{
+   struct ppp_header *header = (struct ppp_header *) packet;
+   guint offset = 0;
+
+   if (ppp->acfc)
+   offset = 2;
+
+   if (g_at_hdlc_send(ppp->hdlc, packet + offset,
+   infolen + sizeof(*header) - offset)
+   == FALSE)
+   DBG(ppp, "Failed to send a frame\n");
+}
+
+/*
+ * transmit out through the lower layer interface
+ *
+ * infolen - length of the information part of the packet
+ */
+void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint infolen)
+{
+   guint16 proto = ppp_proto(packet);
+
+   switch (proto) {
+   case LCP_PROTOCOL:
+   ppp_send_lcp_frame(ppp, packet, infolen);
+   break;
+   case CHAP_PROTOCOL:
+   case IPCP_PROTO:
+   case P

[PATCH 0/2] ACFC and PFC options implementation

2011-06-16 Thread Guillaume Zajac
Hi,

Those 2 patches, are implementing:
- Address and Control Field Compression option
- Protocol Field Compression option

It has been tested with gsmdial that do not negotiate any options and Win7
that negotiate both option.
An improvement of gsmdial and some ppp_lcp APIs could be done to test options
separately e.g. only PFC negotiated and only ACFC negotiated

Guillaume Zajac (2):
  GAtPPP: Add ACFC option support
  GAtPPP: Add PFC option support

 gatchat/gatppp.c  |  169 ++---
 gatchat/ppp.h |   10 +++
 gatchat/ppp_lcp.c |   49 ++-
 3 files changed, 203 insertions(+), 25 deletions(-)

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


Re: Problems ofono 0.45 and Nokia 6760

2011-06-16 Thread Aki Niemi
On Thu, 2011-06-16 at 11:27 +0200, ext Claudio Degioanni wrote:
> > So my advice is to simply use DUN via USB ACM interface. So I think the
> > nokia driver might work better than the isiusb one in this case.
> I'm using embedded tegra2 system, in the past i have tested the
> connection on x86 machine and it
> works succefull.

Ah, I see.

This issue was actually fixed in commit
44ad041c2740064ec055bee7c4084953a10e799d about a week after the 0.45
release.

Cheers,
Aki

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