From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] ppp: implement net close
Date: Fri, 02 Apr 2010 16:45:24 -0700 [thread overview]
Message-ID: <1270251924-5078-1-git-send-email-kristen@linux.intel.com> (raw)
[-- 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
next reply other threads:[~2010-04-02 23:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-02 23:45 Kristen Carlson Accardi [this message]
2010-04-03 0:04 ` [PATCH] ppp: implement net close Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1270251924-5078-1-git-send-email-kristen@linux.intel.com \
--to=kristen@linux.intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox