gprs: Add implementation of set_ipv4_prefix_length

This commit is contained in:
Denis Kenzior 2017-11-13 20:43:07 -06:00
parent 2690d1c8dd
commit f8d6a0a668
1 changed files with 21 additions and 0 deletions

View File

@ -2920,6 +2920,27 @@ void ofono_gprs_context_set_ipv4_netmask(struct ofono_gprs_context *gc,
settings->ipv4->netmask = g_strdup(netmask);
}
void ofono_gprs_context_set_ipv4_prefix_length(struct ofono_gprs_context *gc,
unsigned int length)
{
struct context_settings *settings = gc->settings;
struct in_addr ipv4;
char buf[INET_ADDRSTRLEN];
if (settings->ipv4 == NULL)
return;
g_free(settings->ipv4->netmask);
memset(&ipv4, 0, sizeof(ipv4));
if (length)
ipv4.s_addr = htonl(~((1 << (32 - length)) - 1));
inet_ntop(AF_INET, &ipv4, buf, sizeof(buf));
settings->ipv4->netmask = g_strdup(buf);
}
void ofono_gprs_context_set_ipv4_gateway(struct ofono_gprs_context *gc,
const char *gateway)
{