summaryrefslogtreecommitdiffstats
path: root/gatchat/ppp_net.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-03-31 18:45:17 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-03-31 18:45:17 -0500
commitd6093b819fd31be14becc6dfcaeb30001eb88bc1 (patch)
tree0008da64efef79dcc4c7522f708e0e4f1dad6204 /gatchat/ppp_net.c
parent4d44103cce5643ad0a1b8a56dbda9ca758b91bb6 (diff)
downloadofono-d6093b819fd31be14becc6dfcaeb30001eb88bc1.tar.bz2
Refactor: GAtPPP connect callback
The connect callback was not giving enough information and the information it was providing was not in a convenient form. - Provide the ppp interface name (e.g. tun0) - Provide ip, dns1 & dns2 as strings - Do not send the ppp structure in the callback, it is most likely present in the user data anyway
Diffstat (limited to 'gatchat/ppp_net.c')
-rw-r--r--gatchat/ppp_net.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c
index 3a74e0be..12e2d55b 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -222,14 +222,32 @@ 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;
- /* call the connect function */
- if (ppp->connect_cb)
- ppp->connect_cb(ppp, G_AT_PPP_CONNECT_SUCCESS,
- __get_unaligned_long(data->ip_address),
- __get_unaligned_long(data->primary_dns),
- __get_unaligned_long(data->secondary_dns),
- ppp->connect_data);
+ 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);
+
+ memset(dns1, 0, sizeof(dns1));
+ addr.s_addr = __get_unaligned_long(data->primary_dns);
+ inet_ntop(AF_INET, &addr, dns1, INET_ADDRSTRLEN);
+
+ memset(dns2, 0, sizeof(dns2));
+ 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);
}
static void ipcp_down(struct pppcp_data *data)