summaryrefslogtreecommitdiffstats
path: root/gatchat/ppp_ipcp.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-06-29 11:53:11 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-06-29 11:53:11 -0500
commit820b1f55c8f9e615ef860327ef58a54006ec8822 (patch)
treef760579f42c3d87d9dc415848414cfa4b8a6e4a2 /gatchat/ppp_ipcp.c
parent969862337a77d10081cc72ca9ec0aaafaa3e977e (diff)
downloadofono-820b1f55c8f9e615ef860327ef58a54006ec8822.tar.bz2
ppp: Refactor server-side API
The biggest update here is that the server needs to be in dormant mode by default, so as not to send a Configure-Req to the peer until the peer is ready. This requires adding special constructor for LCP to initialize it to Stopped state instead of initial state. Along with this, we pass the server local IP directly to the ppp server constructor.
Diffstat (limited to 'gatchat/ppp_ipcp.c')
-rw-r--r--gatchat/ppp_ipcp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gatchat/ppp_ipcp.c b/gatchat/ppp_ipcp.c
index 7d59a4bb..f3456070 100644
--- a/gatchat/ppp_ipcp.c
+++ b/gatchat/ppp_ipcp.c
@@ -316,7 +316,7 @@ static enum rcr_result ipcp_server_rcr(struct ipcp_data *ipcp,
struct ppp_option_iter iter;
guint8 nak_options[MAX_CONFIG_OPTION_SIZE];
guint16 len = 0;
- guint8 *rej_options;
+ guint8 *rej_options = NULL;
guint16 rej_len = 0;
guint32 addr;
@@ -462,7 +462,7 @@ struct pppcp_proto ipcp_proto = {
.rcr = ipcp_rcr,
};
-struct pppcp_data *ipcp_new(GAtPPP *ppp)
+struct pppcp_data *ipcp_new(GAtPPP *ppp, gboolean is_server, guint32 ip)
{
struct ipcp_data *ipcp;
struct pppcp_data *pppcp;
@@ -471,7 +471,7 @@ struct pppcp_data *ipcp_new(GAtPPP *ppp)
if (!ipcp)
return NULL;
- pppcp = pppcp_new(ppp, &ipcp_proto);
+ pppcp = pppcp_new(ppp, &ipcp_proto, FALSE);
if (!pppcp) {
g_printerr("Failed to allocate PPPCP struct\n");
g_free(ipcp);
@@ -479,7 +479,14 @@ struct pppcp_data *ipcp_new(GAtPPP *ppp)
}
pppcp_set_data(pppcp, ipcp);
- ipcp_reset_client_config_options(ipcp);
+ ipcp->is_server = is_server;
+
+ if (is_server) {
+ ipcp->local_addr = ip;
+ ipcp_reset_server_config_options(ipcp);
+ } else
+ ipcp_reset_client_config_options(ipcp);
+
pppcp_set_local_options(pppcp, ipcp->options, ipcp->options_len);
return pppcp;