diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-04-30 15:31:26 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-04-30 15:31:26 -0500 |
commit | 6d20194e7520a2190429b9f4582a7ee3b573d3c9 (patch) | |
tree | 982d847212b6658c7c1835c2cd6f55f6a6fbc430 /gatchat/gatppp.h | |
parent | 9ae0dcb47d71803681a205c4708be82d27111443 (diff) | |
download | ofono-6d20194e7520a2190429b9f4582a7ee3b573d3c9.tar.bz2 |
ppp: Refactor connect / disconnect callbacks
Right now it is very hard to figure out whether we should be calling the
connect callback or the disconnect callback. So refactor as follows:
- Connect callback is only called once the net is actually up
- Disconnect callback is called once ppp is down, with a reason
for why it is so.
Diffstat (limited to 'gatchat/gatppp.h')
-rw-r--r-- | gatchat/gatppp.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h index 7631fe58..438b9521 100644 --- a/gatchat/gatppp.h +++ b/gatchat/gatppp.h @@ -33,22 +33,28 @@ struct _GAtPPP; typedef struct _GAtPPP GAtPPP; -typedef enum _GAtPPPConnectStatus { - G_AT_PPP_CONNECT_SUCCESS, - G_AT_PPP_CONNECT_FAIL -} GAtPPPConnectStatus; +typedef enum _GAtPPPDisconnectReason { + G_AT_PPP_REASON_UNKNOWN, + G_AT_PPP_REASON_AUTH_FAIL, /* Failed to authenticate */ + G_AT_PPP_REASON_IPCP_FAIL, /* Failed to negotiate IPCP */ + G_AT_PPP_REASON_NET_FAIL, /* Failed to create tun */ + G_AT_PPP_REASON_PEER_CLOSED, /* Peer initiated a close */ + G_AT_PPP_REASON_LINK_DEAD, /* Link to the peer died */ + G_AT_PPP_REASON_LOCAL_CLOSE, /* Normal user close */ +} GAtPPPDisconnectReason; -typedef void (*GAtPPPConnectFunc)(GAtPPPConnectStatus success, - const char *iface, const char *ip, +typedef void (*GAtPPPConnectFunc)(const char *iface, const char *ip, const char *dns1, const char *dns2, gpointer user_data); +typedef void (*GAtPPPDisconnectFunc)(GAtPPPDisconnectReason reason, + gpointer user_data); GAtPPP *g_at_ppp_new(GIOChannel *modem); GAtPPP *g_at_ppp_new_from_io(GAtIO *io); void g_at_ppp_open(GAtPPP *ppp); void g_at_ppp_set_connect_function(GAtPPP *ppp, GAtPPPConnectFunc callback, gpointer user_data); -void g_at_ppp_set_disconnect_function(GAtPPP *ppp, GAtDisconnectFunc func, +void g_at_ppp_set_disconnect_function(GAtPPP *ppp, GAtPPPDisconnectFunc func, gpointer user_data); void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data); void g_at_ppp_shutdown(GAtPPP *ppp); |