mirror of git://git.sysmocom.de/ofono
gprs: Add implementation of set_ipv4_prefix_length
This commit is contained in:
parent
2690d1c8dd
commit
f8d6a0a668
21
src/gprs.c
21
src/gprs.c
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue