1 /* Convert an IPv6 scope ID from text to the internal representation.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <net-internal.h>
29 /* Parse SOURCE as a scope ID for ADDRESS. Return 0 on success and -1
32 __inet6_scopeid_pton (const struct in6_addr
*address
, const char *scope
,
35 if (IN6_IS_ADDR_LINKLOCAL (address
)
36 || IN6_IS_ADDR_MC_NODELOCAL (address
)
37 || IN6_IS_ADDR_MC_LINKLOCAL (address
))
39 uint32_t number
= __if_nametoindex (scope
);
47 if (isdigit_l (scope
[0], _nl_C_locobj_ptr
))
50 unsigned long long number
51 = ____strtoull_l_internal (scope
, &end
, /*base */ 10, /* group */ 0,
53 if (*end
== '\0' && number
<= UINT32_MAX
)
64 libc_hidden_def (__inet6_scopeid_pton
)