All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ppp: implement net close
@ 2010-04-02 23:45 Kristen Carlson Accardi
  2010-04-03  0:04 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Kristen Carlson Accardi @ 2010-04-02 23:45 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2160 bytes --]

---
 gatchat/ppp.h     |    1 +
 gatchat/ppp_net.c |   11 ++++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gatchat/ppp.h b/gatchat/ppp.h
index fa3749c..7b09fa9 100644
--- a/gatchat/ppp.h
+++ b/gatchat/ppp.h
@@ -105,6 +105,7 @@ struct ppp_net_data {
 	GAtPPP *ppp;
 	char *if_name;
 	GIOChannel *channel;
+	gint watch;
 };
 
 struct _GAtPPP {
diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c
index 908da84..d07a988 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -64,8 +64,6 @@ void ppp_net_process_packet(struct ppp_net_data *data, guint8 *packet)
 /*
  * packets received by the tun interface need to be written to
  * the modem.  So, just read a packet, write out to the modem
- *
- * TBD - how do we know we have a full packet?  Do we care?
  */
 static gboolean ppp_net_callback(GIOChannel *channel, GIOCondition cond,
 				gpointer userdata)
@@ -77,6 +75,9 @@ static gboolean ppp_net_callback(GIOChannel *channel, GIOCondition cond,
 	struct ppp_header *ppp = (struct ppp_header *) buf;
 	struct ppp_net_data *data = (struct ppp_net_data *) userdata;
 
+	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+		return FALSE;
+
 	if (cond & G_IO_IN) {
 		/* leave space to add PPP protocol field */
 		status = g_io_channel_read_chars(channel, buf + 2, MAX_PACKET,
@@ -93,7 +94,8 @@ static gboolean ppp_net_callback(GIOChannel *channel, GIOCondition cond,
 
 void ppp_net_close(struct ppp_net_data *data)
 {
-	/* Not Implemented Yet */
+	g_source_remove(data->watch);
+	g_io_channel_unref(data->channel);
 }
 
 void ppp_net_open(struct ppp_net_data *data)
@@ -101,7 +103,6 @@ void ppp_net_open(struct ppp_net_data *data)
 	int fd;
 	struct ifreq ifr;
 	GIOChannel *channel;
-	int signal_source;
 	int err;
 
 	if (data == NULL)
@@ -138,7 +139,7 @@ void ppp_net_open(struct ppp_net_data *data)
 	}
 	data->channel = channel;
 	g_io_channel_set_buffered(channel, FALSE);
-	signal_source = g_io_add_watch(channel,
+	data->watch = g_io_add_watch(channel,
 			G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
 			ppp_net_callback, (gpointer) data);
 }
-- 
1.6.6.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ppp: implement net close
  2010-04-02 23:45 [PATCH] ppp: implement net close Kristen Carlson Accardi
@ 2010-04-03  0:04 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2010-04-03  0:04 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

Hi Kristen,

> ---
>  gatchat/ppp.h     |    1 +
>  gatchat/ppp_net.c |   11 ++++++-----
>  2 files changed, 7 insertions(+), 5 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-03  0:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-02 23:45 [PATCH] ppp: implement net close Kristen Carlson Accardi
2010-04-03  0:04 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.