mirror of git://git.sysmocom.de/ofono
Implement g_at_ppp_set_debug support
This commit is contained in:
parent
dc55d14e9c
commit
ef82241deb
|
@ -44,13 +44,13 @@ void g_at_ppp_open(GAtPPP *ppp)
|
|||
}
|
||||
|
||||
void g_at_ppp_set_credentials(GAtPPP *ppp, const char *username,
|
||||
const char *passwd)
|
||||
const char *passwd)
|
||||
{
|
||||
auth_set_credentials(ppp->auth, username, passwd);
|
||||
}
|
||||
|
||||
void g_at_ppp_set_connect_function(GAtPPP *ppp, GAtPPPConnectFunc func,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
if (func == NULL)
|
||||
return;
|
||||
|
@ -60,7 +60,7 @@ void g_at_ppp_set_connect_function(GAtPPP *ppp, GAtPPPConnectFunc func,
|
|||
}
|
||||
|
||||
void g_at_ppp_set_disconnect_function(GAtPPP *ppp, GAtDisconnectFunc func,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
if (func == NULL)
|
||||
return;
|
||||
|
@ -69,6 +69,15 @@ void g_at_ppp_set_disconnect_function(GAtPPP *ppp, GAtDisconnectFunc func,
|
|||
ppp->disconnect_data = user_data;
|
||||
}
|
||||
|
||||
void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data)
|
||||
{
|
||||
if (ppp == NULL)
|
||||
return;
|
||||
|
||||
ppp->debugf = func;
|
||||
ppp->debug_data = user_data;
|
||||
}
|
||||
|
||||
void g_at_ppp_shutdown(GAtPPP *ppp)
|
||||
{
|
||||
/* close the ppp link */
|
||||
|
|
|
@ -47,6 +47,7 @@ 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,
|
||||
gpointer user_data);
|
||||
void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data);
|
||||
void g_at_ppp_shutdown(GAtPPP *ppp);
|
||||
void g_at_ppp_ref(GAtPPP *ppp);
|
||||
void g_at_ppp_unref(GAtPPP *ppp);
|
||||
|
|
|
@ -71,7 +71,7 @@ static int oldmode = 0;
|
|||
|
||||
static void gsmdial_debug(const char *str, void *data)
|
||||
{
|
||||
g_print("%s: %s\n", (const char *)data, str);
|
||||
g_print("%s: %s\n", (const char *) data, str);
|
||||
}
|
||||
|
||||
static gboolean quit_eventloop(gpointer user_data)
|
||||
|
@ -269,8 +269,9 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
|||
g_print("Unable to create PPP object\n");
|
||||
exit(1);
|
||||
}
|
||||
g_at_ppp_set_credentials(ppp, option_username,
|
||||
option_password);
|
||||
g_at_ppp_set_debug(ppp, gsmdial_debug, "PPP");
|
||||
|
||||
g_at_ppp_set_credentials(ppp, option_username, option_password);
|
||||
|
||||
/* set connect and disconnect callbacks */
|
||||
g_at_ppp_set_connect_function(ppp, ppp_connect, NULL);
|
||||
|
|
|
@ -137,6 +137,8 @@ struct _GAtPPP {
|
|||
GAtDisconnectFunc disconnect_cb;
|
||||
gpointer disconnect_data;
|
||||
gint modem_watch;
|
||||
GAtDebugFunc debugf;
|
||||
gpointer debug_data;
|
||||
};
|
||||
|
||||
gboolean ppp_cb(GIOChannel *channel, GIOCondition cond, gpointer data);
|
||||
|
|
|
@ -34,19 +34,25 @@
|
|||
#include "gatppp.h"
|
||||
#include "ppp.h"
|
||||
|
||||
#define DEBUG
|
||||
#ifdef DEBUG
|
||||
static const char *pppcp_state_strings[] =
|
||||
{"INITIAL", "STARTING", "CLOSED", "STOPPED", "CLOSING", "STOPPING",
|
||||
"REQSENT", "ACKRCVD", "ACKSENT", "OPENED" };
|
||||
|
||||
#define pppcp_trace(p) do { \
|
||||
g_print("%s: %s: current state %d:%s\n", p->prefix, __FUNCTION__, \
|
||||
p->state, pppcp_state_strings[p->state]); \
|
||||
} while (0)
|
||||
#else
|
||||
#define pppcp_trace(p) do { } while (0)
|
||||
#endif
|
||||
static void pppcp_debug(struct pppcp_data *p, const char *func)
|
||||
{
|
||||
GAtPPP *ppp = p->ppp;
|
||||
char *str;
|
||||
|
||||
if (!ppp || !ppp->debugf)
|
||||
return;
|
||||
|
||||
str = g_strdup_printf("%s: %s: current state %d:%s",
|
||||
p->prefix, func, p->state, pppcp_state_strings[p->state]);
|
||||
ppp->debugf(str, ppp->debug_data);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
#define pppcp_trace(p) pppcp_debug(p, __FUNCTION__)
|
||||
|
||||
#define pppcp_to_ppp_packet(p) \
|
||||
(((guint8 *) p) - PPP_HEADROOM)
|
||||
|
|
Loading…
Reference in New Issue