goto out;
}
- vpninfo->ppp = openconnect_ppp_new(hdlc ? PPP_ENCAP_F5_HDLC : PPP_ENCAP_F5,
- ipv4, ipv6);
- if (!vpninfo->ppp) {
- ret = -ENOMEM;
- goto out;
- }
+ ret = openconnect_ppp_new(vpninfo, hdlc ? PPP_ENCAP_F5_HDLC : PPP_ENCAP_F5, ipv4, ipv6);
- ret = 0; /* success */
out:
free(profile_params);
free(sid);
goto out;
}
- vpninfo->ppp = openconnect_ppp_new(PPP_ENCAP_FORTINET_HDLC, ipv4, ipv6);
- if (!vpninfo->ppp) {
- ret = -ENOMEM;
- goto out;
- }
+ ret = openconnect_ppp_new(vpninfo, PPP_ENCAP_FORTINET_HDLC, ipv4, ipv6);
- ret = 0; /* success */
out:
if (ret)
openconnect_close_https(vpninfo, 0);
// first byte as an indicator of success and don't need to check for "HTTP"
// TODO: actually handle errors as described above
vpn_progress(vpninfo, PRG_DEBUG, _("Connection established\n"));
- vpninfo->ppp = openconnect_ppp_new(PPP_ENCAP_NX_HDLC, ipv4, ipv6);
- if (!vpninfo->ppp) {
- ret = -ENOMEM;
- goto out;
- }
-
- ret = 0;
+ ret = openconnect_ppp_new(vpninfo, PPP_ENCAP_NX_HDLC, ipv4, ipv6);
out:
if (ret < 0)
//ppp_bye(vpninfo);
// TODO: implement
return -EINVAL;
-}
\ No newline at end of file
+}
void buf_append_ppp_hdr(struct oc_text_buf *buf, struct oc_ppp *ppp, uint16_t proto, uint8_t code, uint8_t id);
int ppp_negotiate_config(struct openconnect_info *vpninfo);
int ppp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable);
-struct oc_ppp *openconnect_ppp_new(int encap, int want_ipv4, int want_ipv6);
+int openconnect_ppp_new(struct openconnect_info *vpninfo, int encap, int want_ipv4, int want_ipv6);
/* auth-globalprotect.c */
int gpst_obtain_cookie(struct openconnect_info *vpninfo);
"Discard-Request",
};
-struct oc_ppp *openconnect_ppp_new(int encap, int want_ipv4, int want_ipv6)
+int openconnect_ppp_new(struct openconnect_info *vpninfo,
+ int encap, int want_ipv4, int want_ipv6)
{
- struct oc_ppp *ppp = calloc(sizeof(*ppp), 1);
+ struct oc_ppp *ppp = vpninfo->ppp = calloc(sizeof(*ppp), 1);
if (!ppp)
- return NULL;
+ return -ENOMEM;
ppp->encap = encap;
switch (encap) {
default:
free(ppp);
- return NULL;
+ return -EINVAL;
}
ppp->want_ipv4 = want_ipv4;
if (openconnect_random(&ppp->out_lcp_magic, sizeof(ppp->out_lcp_magic))) {
free(ppp);
- return NULL;
+ return -EINVAL;
}
- return ppp;
+ return 0;
}
static void print_ppp_state(struct openconnect_info *vpninfo, int level)