mirror of git://git.sysmocom.de/ofono
Make GAtPPP fields really private
This commit is contained in:
parent
352ea97f8f
commit
5772ad5d8b
|
@ -38,6 +38,56 @@
|
|||
#include "gatppp.h"
|
||||
#include "ppp.h"
|
||||
|
||||
#define BUFFERSZ DEFAULT_MRU*2
|
||||
|
||||
struct _GAtPPP {
|
||||
gint ref_count;
|
||||
enum ppp_phase phase;
|
||||
struct pppcp_data *lcp;
|
||||
struct auth_data *auth;
|
||||
struct pppcp_data *ipcp;
|
||||
struct ppp_net_data *net;
|
||||
guint8 buffer[BUFFERSZ];
|
||||
int index;
|
||||
gint mru;
|
||||
guint16 auth_proto;
|
||||
char user_name[256];
|
||||
char passwd[256];
|
||||
gboolean pfc;
|
||||
gboolean acfc;
|
||||
guint32 xmit_accm[8];
|
||||
guint32 recv_accm;
|
||||
GIOChannel *modem;
|
||||
GAtPPPConnectFunc connect_cb;
|
||||
gpointer connect_data;
|
||||
GAtDisconnectFunc disconnect_cb;
|
||||
gpointer disconnect_data;
|
||||
gint read_watch;
|
||||
gint write_watch;
|
||||
GAtDebugFunc debugf;
|
||||
gpointer debug_data;
|
||||
int record_fd;
|
||||
GQueue *xmit_queue;
|
||||
};
|
||||
|
||||
void ppp_debug(GAtPPP *ppp, const char *str)
|
||||
{
|
||||
if (!ppp || !ppp->debugf)
|
||||
return;
|
||||
|
||||
ppp->debugf(str, ppp->debug_data);
|
||||
}
|
||||
|
||||
void ppp_connect_cb(GAtPPP *ppp, GAtPPPConnectStatus success,
|
||||
const char *ip, const char *dns1, const char *dns2)
|
||||
{
|
||||
if (ppp->connect_cb == NULL)
|
||||
return;
|
||||
|
||||
ppp->connect_cb(success, ppp->net->if_name,
|
||||
ip, dns1, dns2, ppp->connect_data);
|
||||
}
|
||||
|
||||
#define PPPINITFCS16 0xffff /* Initial FCS value */
|
||||
#define PPPGOODFCS16 0xf0b8 /* Good final FCS value */
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "ppp_cp.h"
|
||||
|
||||
#define DEFAULT_MRU 1500
|
||||
#define BUFFERSZ DEFAULT_MRU*2
|
||||
#define DEFAULT_ACCM 0x00000000
|
||||
#define PPP_ESC 0x7d
|
||||
#define PPP_FLAG_SEQ 0x7e
|
||||
|
@ -108,36 +107,7 @@ struct ppp_net_data {
|
|||
gint watch;
|
||||
};
|
||||
|
||||
struct _GAtPPP {
|
||||
gint ref_count;
|
||||
enum ppp_phase phase;
|
||||
struct pppcp_data *lcp;
|
||||
struct auth_data *auth;
|
||||
struct pppcp_data *ipcp;
|
||||
struct ppp_net_data *net;
|
||||
guint8 buffer[BUFFERSZ];
|
||||
int index;
|
||||
gint mru;
|
||||
guint16 auth_proto;
|
||||
char user_name[256];
|
||||
char passwd[256];
|
||||
gboolean pfc;
|
||||
gboolean acfc;
|
||||
guint32 xmit_accm[8];
|
||||
guint32 recv_accm;
|
||||
GIOChannel *modem;
|
||||
GAtPPPConnectFunc connect_cb;
|
||||
gpointer connect_data;
|
||||
GAtDisconnectFunc disconnect_cb;
|
||||
gpointer disconnect_data;
|
||||
gint read_watch;
|
||||
gint write_watch;
|
||||
GAtDebugFunc debugf;
|
||||
gpointer debug_data;
|
||||
int record_fd;
|
||||
GQueue *xmit_queue;
|
||||
};
|
||||
|
||||
void ppp_debug(GAtPPP *ppp, const char *str);
|
||||
void ppp_generate_event(GAtPPP *ppp, enum ppp_event event);
|
||||
void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint infolen);
|
||||
void ppp_set_auth(GAtPPP *ppp, guint8 *auth_data);
|
||||
|
@ -166,3 +136,5 @@ void ppp_net_close(struct ppp_net_data *data);
|
|||
void ppp_net_free(struct ppp_net_data *data);
|
||||
struct pppcp_data *ipcp_new(GAtPPP *ppp);
|
||||
void ipcp_free(struct pppcp_data *data);
|
||||
void ppp_connect_cb(GAtPPP *ppp, GAtPPPConnectStatus success,
|
||||
const char *ip, const char *dns1, const char *dns2);
|
||||
|
|
|
@ -38,21 +38,13 @@ static const char *pppcp_state_strings[] =
|
|||
{"INITIAL", "STARTING", "CLOSED", "STOPPED", "CLOSING", "STOPPING",
|
||||
"REQSENT", "ACKRCVD", "ACKSENT", "OPENED" };
|
||||
|
||||
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_trace(p) do { \
|
||||
char *str = g_strdup_printf("%s: %s: current state %d:%s", \
|
||||
p->prefix, __FUNCTION__, \
|
||||
p->state, pppcp_state_strings[p->state]); \
|
||||
ppp_debug(p->ppp, str); \
|
||||
g_free(str); \
|
||||
} while (0);
|
||||
|
||||
#define pppcp_to_ppp_packet(p) \
|
||||
(((guint8 *) p) - PPP_HEADROOM)
|
||||
|
|
|
@ -66,15 +66,11 @@ enum ipcp_option_types {
|
|||
static void ipcp_up(struct pppcp_data *pppcp)
|
||||
{
|
||||
struct ipcp_data *data = pppcp->priv;
|
||||
GAtPPP *ppp = pppcp->ppp;
|
||||
char ip[INET_ADDRSTRLEN];
|
||||
char dns1[INET_ADDRSTRLEN];
|
||||
char dns2[INET_ADDRSTRLEN];
|
||||
struct in_addr addr;
|
||||
|
||||
if (ppp->connect_cb == NULL)
|
||||
return;
|
||||
|
||||
memset(ip, 0, sizeof(ip));
|
||||
addr.s_addr = __get_unaligned_long(data->ip_address);
|
||||
inet_ntop(AF_INET, &addr, ip, INET_ADDRSTRLEN);
|
||||
|
@ -87,12 +83,10 @@ static void ipcp_up(struct pppcp_data *pppcp)
|
|||
addr.s_addr = __get_unaligned_long(data->secondary_dns);
|
||||
inet_ntop(AF_INET, &addr, dns2, INET_ADDRSTRLEN);
|
||||
|
||||
ppp->connect_cb(G_AT_PPP_CONNECT_SUCCESS,
|
||||
pppcp->ppp->net->if_name,
|
||||
ip[0] ? ip : NULL,
|
||||
dns1[0] ? dns1 : NULL,
|
||||
dns2[0] ? dns2 : NULL,
|
||||
ppp->connect_data);
|
||||
ppp_connect_cb(pppcp->ppp, G_AT_PPP_CONNECT_SUCCESS,
|
||||
ip[0] ? ip : NULL,
|
||||
dns1[0] ? dns1 : NULL,
|
||||
dns2[0] ? dns2 : NULL);
|
||||
}
|
||||
|
||||
static void ipcp_down(struct pppcp_data *data)
|
||||
|
|
Loading…
Reference in New Issue