summaryrefslogtreecommitdiffstats
path: root/gatchat/gatppp.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2011-05-25 05:22:58 -0500
committerDenis Kenzior <denkenz@gmail.com>2011-05-25 05:22:58 -0500
commite244e2d42a641e52f58f1c376a302d5a4cd7f905 (patch)
tree997c761685c662bcebb2477c51242ed6db0bdf0f /gatchat/gatppp.c
parent4f7027de6f2bfabab14532ced28ccf18e3c1518b (diff)
downloadofono-e244e2d42a641e52f58f1c376a302d5a4cd7f905.tar.bz2
gatppp: Set the suspend function in open / listen
In case it was set before calling these functions
Diffstat (limited to 'gatchat/gatppp.c')
-rw-r--r--gatchat/gatppp.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 07384730..5fb41461 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -402,6 +402,17 @@ static void io_disconnect(gpointer user_data)
pppcp_signal_close(ppp->lcp);
}
+static void ppp_proxy_suspend_net_interface(gpointer user_data)
+{
+ GAtPPP *ppp = user_data;
+
+ ppp->suspended = TRUE;
+ ppp_net_suspend_interface(ppp->net);
+
+ if (ppp->suspend_func)
+ ppp->suspend_func(ppp->suspend_data);
+}
+
gboolean g_at_ppp_listen(GAtPPP *ppp, GAtIO *io)
{
ppp->hdlc = g_at_hdlc_new_from_io(io);
@@ -410,6 +421,8 @@ gboolean g_at_ppp_listen(GAtPPP *ppp, GAtIO *io)
ppp->suspended = FALSE;
g_at_hdlc_set_receive(ppp->hdlc, ppp_receive, ppp);
+ g_at_hdlc_set_suspend_function(ppp->hdlc,
+ ppp_proxy_suspend_net_interface, ppp);
g_at_io_set_disconnect_function(io, io_disconnect, ppp);
ppp_enter_phase(ppp, PPP_PHASE_ESTABLISHMENT);
@@ -426,6 +439,8 @@ gboolean g_at_ppp_open(GAtPPP *ppp, GAtIO *io)
ppp->suspended = FALSE;
g_at_hdlc_set_receive(ppp->hdlc, ppp_receive, ppp);
+ g_at_hdlc_set_suspend_function(ppp->hdlc,
+ ppp_proxy_suspend_net_interface, ppp);
g_at_hdlc_set_no_carrier_detect(ppp->hdlc, TRUE);
g_at_io_set_disconnect_function(io, io_disconnect, ppp);
@@ -506,17 +521,6 @@ void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data)
ppp->debug_data = user_data;
}
-static void ppp_proxy_suspend_net_interface(gpointer user_data)
-{
- GAtPPP *ppp = user_data;
-
- ppp->suspended = TRUE;
- ppp_net_suspend_interface(ppp->net);
-
- if (ppp->suspend_func)
- ppp->suspend_func(ppp->suspend_data);
-}
-
void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func,
gpointer user_data)
{
@@ -525,7 +529,9 @@ void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func,
ppp->suspend_func = func;
ppp->suspend_data = user_data;
- g_at_hdlc_set_suspend_function(ppp->hdlc,
+
+ if (ppp->hdlc != NULL)
+ g_at_hdlc_set_suspend_function(ppp->hdlc,
ppp_proxy_suspend_net_interface, ppp);
}