File: net-private.h

package info (click to toggle)
ofono 2.18-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,064 kB
  • sloc: ansic: 224,979; sh: 5,012; python: 4,040; makefile: 956
file content (27 lines) | stat: -rw-r--r-- 673 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Embedded Linux library
 * Copyright (C) 2020  Intel Corporation
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

char *net_domain_name_parse(const uint8_t *raw, size_t raw_len);
char **net_domain_list_parse(const uint8_t *raw, size_t raw_len, bool padded);

static inline const void *net_prefix_from_ipv6(const uint8_t *address,
						uint8_t prefix_len)
{
	uint8_t last_byte = prefix_len / 8;
	uint8_t bits = prefix_len & 7;
	static uint8_t prefix[16];

	memcpy(prefix, address, last_byte);

	if (prefix_len & 7) {
		prefix[last_byte] = address[last_byte] & (0xff00 >> bits);
		last_byte++;
	}

	memset(prefix + last_byte, 0, 16 - last_byte);
	return prefix;
}