[PATCH] fix ppp protocol-reject constructing error

2011-05-11 Thread Caiwen Zhang
In PPP Protocol-Reject package the 'rejected data field' should be a copy
of the rejected package, the copy starts from the data field. besides, 
Protocol-Reject package include a 'rejected protocol field', it is the
same as the protocol field of the rejected package.

Protocol-Reject package structure is:

| PPP_header | rejected protocol | rejected data

The rejected package structure is:
| Addr | Control | protocol | data

So the Protocol-Reject package data field is copied from the 3rd byte of
the rejected package.

---
 gatchat/ppp_cp.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c
index 6e4a9c5..2d47933 100644
--- a/gatchat/ppp_cp.c
+++ b/gatchat/ppp_cp.c
@@ -922,7 +922,8 @@ void pppcp_send_protocol_reject(struct pppcp_data *data,
 * info should contain the old packet info, plus the 16bit
 * protocol number we are rejecting.
 */
-   packet = pppcp_packet_new(data, PPPCP_CODE_TYPE_PROTOCOL_REJECT, len);
+   packet = pppcp_packet_new(data, PPPCP_CODE_TYPE_PROTOCOL_REJECT,
+   len - 2);
 
/*
 * Identifier must be changed for each Protocol-Reject sent
@@ -933,8 +934,7 @@ void pppcp_send_protocol_reject(struct pppcp_data *data,
 * rejected packet should be copied in, but it should be
 * truncated if it needs to be to comply with mtu requirement
 */
-   memcpy(packet-data, rejected_packet,
-   (ntohs(packet-length) - CP_HEADER_SZ));
+   memcpy(packet-data, rejected_packet + 2, len - 2);
 
ppp_transmit(data-ppp, pppcp_to_ppp_packet(packet),
ntohs(packet-length));
-- 
1.7.5
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] add name field when process chap authentication

2011-05-11 Thread Caiwen Zhang
Some systems require name field, otherwise chap authentication will fail.

---
 gatchat/ppp_auth.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/gatchat/ppp_auth.c b/gatchat/ppp_auth.c
index b73f320..f2b8c31 100644
--- a/gatchat/ppp_auth.c
+++ b/gatchat/ppp_auth.c
@@ -60,6 +60,7 @@ static void chap_process_challenge(struct ppp_chap *chap, 
const guint8 *packet)
struct chap_header *response;
GChecksum *checksum;
const char *secret = g_at_ppp_get_password(chap-ppp);
+   const char *username = g_at_ppp_get_username(chap-ppp);
guint16 response_length;
struct ppp_header *ppp_packet;
gsize digest_len;
@@ -83,6 +84,8 @@ static void chap_process_challenge(struct ppp_chap *chap, 
const guint8 *packet)
 */
digest_len = g_checksum_type_get_length(chap-method);
response_length = digest_len + sizeof(*header) + 1;
+   if (username != NULL)
+   response_length += strlen(username);
ppp_packet = ppp_packet_new(response_length, CHAP_PROTOCOL);
if (ppp_packet == NULL)
goto challenge_out;
@@ -98,6 +101,10 @@ static void chap_process_challenge(struct ppp_chap *chap, 
const guint8 *packet)
/* leave the name empty? */
}
 
+   if (username != NULL)
+   memcpy(response-data + digest_len + 1, username,
+   strlen(username));
+
/* transmit the packet */
ppp_transmit(chap-ppp, (guint8 *) ppp_packet, response_length);
g_free(ppp_packet);
-- 
1.7.5

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


[PATCH 0/5] Introduce call management buttons

2011-05-11 Thread Nicolas Bertrand
This patch add support of call state management.
Buttons Alerting and Active permit to change the state of on-going call.

Nicolas Bertrand (5):
  controlbase: Add call state management buttons
  hardwaremanipulator: Call state changed signals
  callmanager: Change call state management slots
  control: handle call management buttons
  phonesim: connect call mangagement signals

 src/callmanager.cpp   |7 +++
 src/callmanager.h |   12 ++--
 src/control.cpp   |   12 
 src/control.h |2 ++
 src/controlbase.ui|   18 ++
 src/hardwaremanipulator.h |2 ++
 src/phonesim.cpp  |4 
 7 files changed, 51 insertions(+), 6 deletions(-)

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


[PATCH 1/5] controlbase: Add call state management buttons

2011-05-11 Thread Nicolas Bertrand
---
 src/controlbase.ui |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/controlbase.ui b/src/controlbase.ui
index dd60cda..45b60f9 100644
--- a/src/controlbase.ui
+++ b/src/controlbase.ui
@@ -1395,6 +1395,24 @@ p, li { white-space: pre-wrap; }
 /widget
/item
item
+layout class=QHBoxLayout name=horizontalLayout_4
+ item
+  widget class=QPushButton name=pbAlerting
+   property name=text
+stringAlerting/string
+   /property
+  /widget
+ /item
+ item
+  widget class=QPushButton name=pbActive
+   property name=text
+stringActive/string
+   /property
+  /widget
+ /item
+/layout
+   /item
+   item
 layout class=QHBoxLayout name=horizontalLayout_3
  item
   widget class=QGroupBox name=gbIncomingCall
-- 
1.7.1

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


[PATCH 2/5] hardwaremanipulator: Call state changed signals

2011-05-11 Thread Nicolas Bertrand
---
 src/hardwaremanipulator.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/hardwaremanipulator.h b/src/hardwaremanipulator.h
index ae8e716..9a82ca0 100644
--- a/src/hardwaremanipulator.h
+++ b/src/hardwaremanipulator.h
@@ -58,6 +58,8 @@ signals:
 void variableChanged(const QString n, const QString v);
 void switchTo(const QString cmd);
 void startIncomingCall(const QString number, const QString 
called_number, const QString name);
+void stateChangedToAlerting();
+void stateChangedToConnected();
 
 protected:
 virtual QString constructCBMessage(const QString messageCode, int 
geographicalScope, const QString updateNumber, const QString channel,
-- 
1.7.1

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


[PATCH 3/5] callmanager: Change call state management slots

2011-05-11 Thread Nicolas Bertrand
---
 src/callmanager.cpp |7 +++
 src/callmanager.h   |   12 ++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/callmanager.cpp b/src/callmanager.cpp
index 0ede2ad..8085056 100644
--- a/src/callmanager.cpp
+++ b/src/callmanager.cpp
@@ -700,6 +700,10 @@ bool CallManager::chld4()
 
 void CallManager::dialingToConnected()
 {
+// Stop timers in case they are still active
+alertingTimer-stop();
+connectTimer-stop();
+
 // Find the currently dialing or alerting call.
 int index = indexForId( idForState( CallState_Dialing ) );
 if ( index  0 )
@@ -726,6 +730,9 @@ void CallManager::dialingToConnected()
 
 void CallManager::dialingToAlerting()
 {
+// Stop the timer in case it is still active
+alertingTimer-stop();
+
 // Find the currently dialing or alerting call.
 int index = indexForId( idForState( CallState_Dialing ) );
 if ( index  0 )
diff --git a/src/callmanager.h b/src/callmanager.h
index 228e26c..c953a7d 100644
--- a/src/callmanager.h
+++ b/src/callmanager.h
@@ -100,6 +100,12 @@ public slots:
 void startIncomingCall( const QString number, const QString calledNumber,
 const QString name );
 
+// Transition the active dialing or alerting call to connected.
+void dialingToConnected();
+
+// Transition the active dialing call to alerting.
+void dialingToAlerting();
+
 signals:
 // Send a response to a command.
 void send( const QString line );
@@ -118,12 +124,6 @@ signals:
 void callStatesChanged( QListCallInfo *list );
 
 private slots:
-// Transition the active dialing or alerting call to connected.
-void dialingToConnected();
-
-// Transition the active dialing call to alerting.
-void dialingToAlerting();
-
 // Transition the waiting call to incoming.
 void waitingToIncoming();
 
-- 
1.7.1

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


[PATCH 4/5] control: handle call management buttons

2011-05-11 Thread Nicolas Bertrand
---
 src/control.cpp |   12 
 src/control.h   |2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/control.cpp b/src/control.cpp
index de141c3..4fdba27 100644
--- a/src/control.cpp
+++ b/src/control.cpp
@@ -88,6 +88,8 @@ ControlWidget::ControlWidget(const QString ruleFile, Control 
*parent)
 connect(ui-pbSendGNSSData, SIGNAL(clicked()), this, SLOT(sendGNSSData()));
 connect(ui-pbGNSSDefault, SIGNAL(clicked()), this, 
SLOT(setDefaultGNSSData()));
 connect(ui-pbSendNotif, SIGNAL(clicked()), this, SLOT(sendCSSN()));
+connect(ui-pbAlerting, SIGNAL(clicked()), this, SLOT(setStateAlerting()));
+connect(ui-pbActive, SIGNAL(clicked()), this, SLOT(setStateConnected()));
 
 QStringList headers;
 headers  Sender  Priority  Notification Status;
@@ -168,6 +170,16 @@ void Control::callManagement( QListCallInfo *list )
 widget-setCssuEnabled( enableCSSU );
 }
 
+void ControlWidget::setStateConnected()
+{
+emit p-stateChangedToConnected();
+}
+
+void ControlWidget::setStateAlerting()
+{
+emit p-stateChangedToAlerting();
+}
+
 void ControlWidget::setCssiEnabled( bool enableCSSI )
 {
 ui-cbCSSI-setEnabled( enableCSSI );
diff --git a/src/control.h b/src/control.h
index ac39eb3..1d8f06f 100644
--- a/src/control.h
+++ b/src/control.h
@@ -104,6 +104,8 @@ private slots:
 void sendGNSSData();
 void setDefaultGNSSData();
 void sendCSSN();
+void setStateAlerting();
+void setStateConnected();
 
 signals:
 void unsolicitedCommand(const QString );
-- 
1.7.1

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


[PATCH 5/5] phonesim: connect call mangagement signals

2011-05-11 Thread Nicolas Bertrand
---
 src/phonesim.cpp |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/phonesim.cpp b/src/phonesim.cpp
index 6b45cf6..d3bd049 100644
--- a/src/phonesim.cpp
+++ b/src/phonesim.cpp
@@ -530,6 +530,10 @@ SimRules::SimRules( int fd, QObject *p,  const QString 
filename, HardwareManipu
  _callManager, 
SLOT(startIncomingCall(QString,QString,QString)) );
 connect ( _callManager, SIGNAL( callStatesChanged( QListCallInfo * ) 
),
   machine, SLOT( callManagement( QListCallInfo * ) ) );
+connect ( machine, SIGNAL( stateChangedToAlerting() ), _callManager,
+SLOT( dialingToAlerting() ) );
+connect ( machine, SIGNAL( stateChangedToConnected() ), _callManager,
+SLOT( dialingToConnected() ) );
 }
 
 connect(this,SIGNAL(readyRead()),
-- 
1.7.1

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


[PATCH] Fix a memory leak, all dir opened with opendir must be closed with closedir

2011-05-11 Thread Bertrand Aygon
---
 plugins/nokia-gpio.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/plugins/nokia-gpio.c b/plugins/nokia-gpio.c
index 3ddf6e1..57aad8d 100644
--- a/plugins/nokia-gpio.c
+++ b/plugins/nokia-gpio.c
@@ -645,7 +645,6 @@ static int gpio_probe_links(void)
DBG(Using %s: trying to make links to %s, gpiodir, cmtdir);
 
if (!dir_exists(cmtdir)) {
-
if (mkdir(cmtdir, 0755) == -1) {
DBG(%s: %s, cmtdir, strerror(errno));
return -(errno = ENODEV);
@@ -663,8 +662,10 @@ static int gpio_probe_links(void)
FILE *nf;
size_t len;
 
-   if (d == NULL)
+   if (d == NULL) {
+   (void) closedir(gpio);
return 0;
+   }
 
snprintf(nn, sizeof nn, %s/%s/name, gpiodir, d-d_name);
 
@@ -701,6 +702,8 @@ static int gpio_probe_links(void)
 
DBG(%s: %s, /sys/class/gpio, strerror(errno));
 
+   (void) closedir(gpio);
+
return -(errno = ENODEV);
 }
 
-- 
1.7.4.1

-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: Les Montalets- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] reopen data device once if open data device failed

2011-05-11 Thread Denis Kenzior
Hi Caiwen,

On 05/11/2011 12:49 AM, Zhang, Caiwen wrote:
 Hi Denis,
 
 I think this is wrong as well. We should remove that context no
 matter
 if online of offline, but off course you do not wanna create a new
 GPRS
 context if you are actually offline, right?


 If the device is offline, the GPRS context atom has been released
 when set
 the device to offline. That's another issue has been fixed by Martin
 (Need
 set data-gc to NULL, because it has been release if device is
 offline).

 It will create a new GPRS context when the device is switch to
 online(in
 huawei_post_online()), so don't create it here if it is offline.



 I suggest you migrate the huawei modem driver to create the gprs atom
 in
 post_sim state instead of post_online.  It will solve many of the
 issues
 you're trying to solve.

 
 Thanks your suggestion.
 
 Yes, It can help that we don't need to care whether gprs atom and gprs 
 context atom 
 be repeatedly created. But if do this at post_sim state, it will beak the rule
 that only enable the atom when it is available. At post_sim state GPRS is 
 still unavailable.
 In addition, all other plug-ins do this at post_online, only do this in 
 Huawei plug-in,
 it may impact the consistency of the codes.
 

I wouldn't really suggest this if I didn't think it was a good idea.
All modem drivers should be migrated to create gprs in the post_sim
state instead of post_online at some point anyway.  And even if the GPRS
connections cannot be established when the modem is Offline, the
relevant settings on ConnectionManager interface can still be modified.

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


Re: [PATCH 1/1] Fix primary context active/deactive result d-bus reply missing issue

2011-05-11 Thread Denis Kenzior
Hi Martin,

On 04/27/2011 02:04 AM, martin...@intel.com wrote:
 From: Martin Xu martin...@intel.com
 
 If user offline modem when the gprs_context is in enabling or disabling
 state(activating/disactivating), the GPRS primary context activate/disactivate
 result will not be replied to the corresponding application.
 ---
  drivers/atmodem/gprs-context.c |7 +++
  src/gprs.c |5 +
  2 files changed, 12 insertions(+), 0 deletions(-)
 

Please check commit 4714d8199aacf0ba6be777a70e01b3016ba2aa5f, this might
partly fix this issue.

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


Re: [PATCH] fix miss dbus reply issue

2011-05-11 Thread Denis Kenzior
Hi Caiwen,

On 05/10/2011 05:31 AM, Caiwen Zhang wrote:
 When set modem offline or power off, if there is some other operation in 
 progress,
 the dbus reply may lost. Always check the pending dbus message to make sure 
 don't
 miss any reply.
 
 This should be a common issue, this patch only fix the GPRS relatived.
 
 ---
  src/gprs.c |   17 ++-
  1 files changed, 17 insertions(+), 0 deletions(-)
 
 diff --git a/src/gprs.c b/src/gprs.c
 index e221741..535432e 100644
 --- a/src/gprs.c
 +++ b/src/gprs.c
 @@ -1363,6 +1363,10 @@ static gboolean context_dbus_unregister(struct 
 pri_context *ctx)
   DBusConnection *conn = ofono_dbus_get_connection();
   char path[256];
  
 + if (ctx-pending != NULL)
 + __ofono_dbus_pending_reply(ctx-pending,
 + __ofono_error_failed(ctx-pending));
 +

I don't really see the need for this change just yet, especially if the
gprs atom is moved to post_sim state.  Feel free to convince me otherwise ;)

   strcpy(path, ctx-path);
   idmap_put(ctx-gprs-pid_map, ctx-id);
  
 @@ -2133,6 +2137,8 @@ void ofono_gprs_set_cid_range(struct ofono_gprs *gprs,
  static void gprs_context_unregister(struct ofono_atom *atom)
  {
   struct ofono_gprs_context *gc = __ofono_atom_get_data(atom);
 + GSList *l;
 + struct pri_context *ctx;
  
   if (gc-gprs == NULL)
   return;
 @@ -2143,6 +2149,13 @@ static void gprs_context_unregister(struct ofono_atom 
 *atom)
   gc-settings = NULL;
   }
  
 + for (l = gc-gprs-contexts; l; l = l-next) {
 + ctx = l-data;
 + if (ctx-context_driver == gc  ctx-pending != NULL)
 + __ofono_dbus_pending_reply(ctx-pending,
 + __ofono_error_failed(ctx-pending));
 + }
 +
   gc-gprs-context_drivers = g_slist_remove(gc-gprs-context_drivers,
   gc);
   gc-gprs = NULL;

I've fixed this part slightly differently in commit
4714d8199aacf0ba6be777a70e01b3016ba2aa5f.  Please have a look and let me
know if it solves your problems.

 @@ -2481,6 +2494,10 @@ static void gprs_unregister(struct ofono_atom *atom)
   gprs-netreg = NULL;
   }
  
 + if (gprs-pending != NULL)
 + __ofono_dbus_pending_reply(gprs-pending,
 + __ofono_error_failed(gprs-pending));
 +
   ofono_modem_remove_interface(modem,
   OFONO_CONNECTION_MANAGER_INTERFACE);
   g_dbus_unregister_interface(conn, path,

Again, replying to pending messages on atom removal is not something I
want to do yet.  The application can easily cancel pending calls when a
particular interface goes away..

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


Re: [PATCH] Fix a memory leak, all dir opened with opendir must be closed with closedir

2011-05-11 Thread Denis Kenzior
Hi Bertrand,

On 05/11/2011 10:27 AM, Bertrand Aygon wrote:
 ---
  plugins/nokia-gpio.c |7 +--
  1 files changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/plugins/nokia-gpio.c b/plugins/nokia-gpio.c
 index 3ddf6e1..57aad8d 100644
 --- a/plugins/nokia-gpio.c
 +++ b/plugins/nokia-gpio.c
 @@ -645,7 +645,6 @@ static int gpio_probe_links(void)
   DBG(Using %s: trying to make links to %s, gpiodir, cmtdir);
  
   if (!dir_exists(cmtdir)) {
 -
   if (mkdir(cmtdir, 0755) == -1) {
   DBG(%s: %s, cmtdir, strerror(errno));
   return -(errno = ENODEV);

Since this is a style issue, I broke your patch up into two.

 @@ -663,8 +662,10 @@ static int gpio_probe_links(void)
   FILE *nf;
   size_t len;
  
 - if (d == NULL)
 + if (d == NULL) {
 + (void) closedir(gpio);
   return 0;
 + }
  
   snprintf(nn, sizeof nn, %s/%s/name, gpiodir, d-d_name);
  
 @@ -701,6 +702,8 @@ static int gpio_probe_links(void)
  
   DBG(%s: %s, /sys/class/gpio, strerror(errno));
  
 + (void) closedir(gpio);
 +
   return -(errno = ENODEV);
  }
  

Patch has been applied with a modified commit message.  Thanks.

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


Re: [PATCH 0/5] Introduce call management buttons

2011-05-11 Thread Denis Kenzior
Hi Nicolas,

On 05/11/2011 06:46 AM, Nicolas Bertrand wrote:
 This patch add support of call state management.
 Buttons Alerting and Active permit to change the state of on-going call.
 
 Nicolas Bertrand (5):
   controlbase: Add call state management buttons
   hardwaremanipulator: Call state changed signals
   callmanager: Change call state management slots
   control: handle call management buttons
   phonesim: connect call mangagement signals
 
  src/callmanager.cpp   |7 +++
  src/callmanager.h |   12 ++--
  src/control.cpp   |   12 
  src/control.h |2 ++
  src/controlbase.ui|   18 ++
  src/hardwaremanipulator.h |2 ++
  src/phonesim.cpp  |4 
  7 files changed, 51 insertions(+), 6 deletions(-)
 

I applied all patches in this series, however calls still proceed to
Alerting / Active state automagically.  Are there plans to fix that?

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


RE: [PATCH 1/1] Fix primary context active/deactive result d-bus reply missing issue

2011-05-11 Thread Xu, Martin
Denis:
 -Original Message-
 From: Denis Kenzior [mailto:denk...@gmail.com]
 Sent: Thursday, May 12, 2011 2:31 AM
 To: ofono@ofono.org
 Cc: Xu, Martin
 Subject: Re: [PATCH 1/1] Fix primary context active/deactive result d-bus 
 reply
 missing issue
 
 Hi Martin,
 
 On 04/27/2011 02:04 AM, martin...@intel.com wrote:
  From: Martin Xu martin...@intel.com
 
  If user offline modem when the gprs_context is in enabling or disabling
  state(activating/disactivating), the GPRS primary context 
  activate/disactivate
  result will not be replied to the corresponding application.
  ---
   drivers/atmodem/gprs-context.c |7 +++
   src/gprs.c |5 +
   2 files changed, 12 insertions(+), 0 deletions(-)
 
 
 Please check commit 4714d8199aacf0ba6be777a70e01b3016ba2aa5f, this
 might
 partly fix this issue.
Thanks. :-)
The patch only fix the issue partly, we are continue to test and review the 
code and try to find the final solution. 
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] add name field when process chap authentication

2011-05-11 Thread Denis Kenzior
Hi Caiwen,

On 05/11/2011 04:19 AM, Caiwen Zhang wrote:
 Some systems require name field, otherwise chap authentication will fail.
 
 ---
  gatchat/ppp_auth.c |7 +++
  1 files changed, 7 insertions(+), 0 deletions(-)
 

Patch has been applied with a minor style fix and a reworded commit
message.  Thanks for that.

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