int ret;
struct oc_ncp *ncp;
unsigned char *p;
+ char abuf[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
switch (proto) {
case PPP_LCP: ncp = &ppp->lcp; break;
memcpy(&ppp->in_ipv4_addr, p+2, 4);
vpn_progress(vpninfo, PRG_DEBUG,
_("Received peer IPv4 address %s from server\n"),
- inet_ntoa(ppp->in_ipv4_addr));
+ inet_ntop(AF_INET, &ppp->in_ipv4_addr, abuf, sizeof(abuf)));
break;
case PROTO_TAG_LEN(PPP_IP6CP, IP6CP_INT_ID, 8): {
- char buf[40];
unsigned char ipv6_ll[16] = {0xfe, 0x80, 0, 0, 0, 0, 0, 0};
/* XX: The server has allegedly sent us its link-local IPv6 address.
*/
memcpy(ipv6_ll + 8, p+2, 8);
memcpy(&ppp->in_ipv6_addr, ipv6_ll, 16);
- if (!inet_ntop(AF_INET6, &ppp->in_ipv6_addr, buf, sizeof(buf)))
- return -EINVAL;
vpn_progress(vpninfo, PRG_DEBUG,
_("Received peer IPv6 link-local address %s from server\n"),
- buf);
+ inet_ntop(AF_INET6, &ppp->in_ipv6_addr, abuf, sizeof(abuf)));
break;
}
default:
struct oc_ppp *ppp = vpninfo->ppp;
struct oc_ncp *ncp;
unsigned char *p;
+ char abuf[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
switch (proto) {
case PPP_LCP: ncp = &ppp->lcp; break;
break;
case PROTO_TAG_LEN(PPP_IPCP, IPCP_IPADDR, 4): {
struct in_addr *a = (void *)(p + 2);
- const char *s = inet_ntoa(*a);
+ inet_ntop(AF_INET, a, abuf, sizeof(abuf));
if (code == CONFNAK && a->s_addr) {
vpn_progress(vpninfo, PRG_DEBUG,
- _("Server nak-offered IPv4 address: %s\n"), s);
+ _("Server nak-offered IPv4 address: %s\n"), abuf);
ppp->out_ipv4_addr = *a;
if (vpninfo->ip_info.addr) {
vpn_progress(vpninfo, PRG_ERR,
}
} else {
vpn_progress(vpninfo, PRG_DEBUG,
- _("Server rejected/nak'ed our IPv4 address or request: %s\n"), s);
+ _("Server rejected/nak'ed our IPv4 address or request: %s\n"), abuf);
return -EINVAL;
}
break;
case PROTO_TAG_LEN(PPP_IPCP, IPCP_xNS_BASE + 2, 4):
case PROTO_TAG_LEN(PPP_IPCP, IPCP_xNS_BASE + 3, 4): {
struct in_addr *a = (void *)(p + 2);
- const char *s = inet_ntoa(*a);
/* XX: see ppp.h for why bitfields work here */
int is_dns = t&1;
int entry = (t&2)>>1;
+ inet_ntop(AF_INET, a, abuf, sizeof(abuf));
if (code == CONFNAK && a->s_addr) {
vpn_progress(vpninfo, PRG_DEBUG,
_("Server nak-offered IPCP request for %s[%d] server: %s\n"),
- is_dns ? "DNS" : "NBNS", entry, s);
+ is_dns ? "DNS" : "NBNS", entry, abuf);
ppp->nameservers[t & 3] = *a;
ppp->got_peerns |= (1<<(t-IPCP_xNS_BASE));
} else {
case PROTO_TAG_LEN(PPP_IP6CP, IP6CP_INT_ID, 8): {
uint64_t *val = (void *)(p + 2);
if (code == CONFNAK && *val != 0) {
- char buf[40];
unsigned char ipv6_ll[16] = {0xfe, 0x80, 0, 0, 0, 0, 0, 0};
memcpy(ipv6_ll + 8, val, 8);
- if (!inet_ntop(AF_INET6, ipv6_ll, buf, sizeof(buf)))
- return -EINVAL;
+ inet_ntop(AF_INET6, ipv6_ll, abuf, sizeof(abuf));
vpn_progress(vpninfo, PRG_DEBUG,
- _("Server nak-offered IPv6 link-local address %s\n"), buf);
+ _("Server nak-offered IPv6 link-local address %s\n"), abuf);
/* If we don't already have a valid global IPv6 address, then we are
* supposed to use this one to create a valid link-local IPv6
* address to allow autoconfiguration (https://tools.ietf.org/html/rfc5072)
{
struct in_addr net_addr, mask_addr;
const char *in_ex = include ? "IN" : "EX";
- char envname[80], uptoslash[20];
+ char envname[80], uptoslash[20], abuf[INET_ADDRSTRLEN];
const char *slash;
char *endp;
int masklen;
/* Fix incorrectly-set host bits */
if (net_addr.s_addr & ~mask_addr.s_addr) {
net_addr.s_addr &= mask_addr.s_addr;
+ inet_ntop(AF_INET, &net_addr, abuf, sizeof(abuf));
if (include)
vpn_progress(vpninfo, PRG_ERR,
_("WARNING: Split include \"%s\" has host bits set, replacing with \"%s/%d\".\n"),
- route, inet_ntoa(net_addr), masklen);
+ route, abuf, masklen);
else
vpn_progress(vpninfo, PRG_ERR,
_("WARNING: Split exclude \"%s\" has host bits set, replacing with \"%s/%d\".\n"),
- route, inet_ntoa(net_addr), masklen);
+ route, abuf, masklen);
}
snprintf(envname, 79, "CISCO_SPLIT_%sC_%d_ADDR", in_ex, *v4_incs);
- script_setenv(vpninfo, envname, inet_ntoa(net_addr), 0, 0);
+ script_setenv(vpninfo, envname, inet_ntop(AF_INET, &net_addr, abuf, sizeof(abuf)), 0, 0);
snprintf(envname, 79, "CISCO_SPLIT_%sC_%d_MASK", in_ex, *v4_incs);
- script_setenv(vpninfo, envname, inet_ntoa(mask_addr), 0, 0);
+ script_setenv(vpninfo, envname, inet_ntop(AF_INET, &mask_addr, abuf, sizeof(abuf)), 0, 0);
snprintf(envname, 79, "CISCO_SPLIT_%sC_%d_MASKLEN", in_ex, *v4_incs);
script_setenv_int(vpninfo, envname, masklen);
_("Ignoring legacy network because netmask \"%s\" is invalid.\n"),
vpninfo->ip_info.netmask);
else {
- char *netaddr;
+ char netaddr[INET_ADDRSTRLEN];
int masklen = netmasklen(mask);
if (netmaskbits(masklen) != mask.s_addr)
goto bad_netmask;
addr.s_addr &= mask.s_addr;
- netaddr = inet_ntoa(addr);
+ inet_ntop(AF_INET, &addr, netaddr, sizeof(netaddr));
script_setenv(vpninfo, "INTERNAL_IP4_NETADDR", netaddr, 0, 0);
script_setenv(vpninfo, "INTERNAL_IP4_NETMASK", vpninfo->ip_info.netmask, 0, 0);