From 90d240820bd9cbb01d0e4e9af5223ff2bc078375 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 28 Jun 2010 17:38:54 -0500 Subject: [PATCH] ppp: Tweak the set_server_info API --- gatchat/gatppp.c | 17 ++++++++++++++--- gatchat/gatppp.h | 5 +++-- gatchat/test-server.c | 13 ++----------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index b65733ee..1f5b581d 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -465,10 +465,21 @@ void g_at_ppp_unref(GAtPPP *ppp) g_free(ppp); } -void g_at_ppp_set_server_info(GAtPPP *ppp, guint32 local, guint32 peer, - guint32 dns1, guint32 dns2) +void g_at_ppp_set_server_info(GAtPPP *ppp, + const char *local, const char *remote, + const char *dns1, const char *dns2) { - ipcp_set_server_info(ppp->ipcp, local, peer, dns1, dns2); + guint32 l = 0; + guint32 r = 0; + guint32 d1 = 0; + guint32 d2 = 0; + + inet_pton(AF_INET, local, &l); + inet_pton(AF_INET, remote, &r); + inet_pton(AF_INET, dns1, &d1); + inet_pton(AF_INET, dns2, &d2); + + ipcp_set_server_info(ppp->ipcp, l, r, d1, d2); } static GAtPPP *ppp_init_common(GAtHDLC *hdlc) diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h index aea4ec07..3a25380a 100644 --- a/gatchat/gatppp.h +++ b/gatchat/gatppp.h @@ -69,8 +69,9 @@ const char *g_at_ppp_get_password(GAtPPP *ppp); void g_at_ppp_set_recording(GAtPPP *ppp, const char *filename); -void g_at_ppp_set_server_info(GAtPPP *ppp, guint32 local, guint32 peer, - guint32 dns1, guint32 dns2); +void g_at_ppp_set_server_info(GAtPPP *ppp, + const char *local_ip, const char *remote_ip, + const char *dns1, const char *dns2); #ifdef __cplusplus } diff --git a/gatchat/test-server.c b/gatchat/test-server.c index 08de689e..71e49863 100644 --- a/gatchat/test-server.c +++ b/gatchat/test-server.c @@ -118,18 +118,9 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user) static gboolean update_ppp(gpointer user) { GAtPPP *ppp = user; - char local_ip[INET_ADDRSTRLEN] = "192.168.1.1"; - char remote_ip[INET_ADDRSTRLEN] = "192.168.1.2"; - char dns1[INET_ADDRSTRLEN] = "10.10.10.10"; - char dns2[INET_ADDRSTRLEN] = "10.10.10.11"; - guint32 l, r, d1, d2; - inet_pton(AF_INET, local_ip, &l); - inet_pton(AF_INET, remote_ip, &r); - inet_pton(AF_INET, dns1, &d1); - inet_pton(AF_INET, dns2, &d2); - - g_at_ppp_set_server_info(ppp, l, r, d1, d2); + g_at_ppp_set_server_info(ppp, "192.168.1.1", "192.168.1.2", + "10.10.10.10", "10.10.10.11"); return FALSE; }