forked from acouzens/open5gs
change link local address
This commit is contained in:
parent
23c5e1040a
commit
9b5234bd5f
|
@ -126,8 +126,10 @@ CORE_DECLARE(status_t) sock_add_node(
|
|||
list_t *list, sock_node_t **node, c_sockaddr_t *sa_list, int family);
|
||||
CORE_DECLARE(status_t) sock_remove_node(list_t *list, sock_node_t *node);
|
||||
CORE_DECLARE(status_t) sock_remove_all_nodes(list_t *list);
|
||||
|
||||
CORE_DECLARE(status_t) sock_probe_node(
|
||||
list_t *list, list_t *list6, c_uint16_t port);
|
||||
CORE_DECLARE(status_t) sock_fill_scope_id_in_local(c_sockaddr_t *sa_list);
|
||||
|
||||
CORE_DECLARE(status_t) core_getaddrinfo(c_sockaddr_t **sa_list,
|
||||
int family, const char *hostname, c_uint16_t port, int flags);
|
||||
|
|
|
@ -459,6 +459,61 @@ status_t sock_probe_node(list_t *list, list_t *list6, c_uint16_t port)
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t sock_fill_scope_id_in_local(c_sockaddr_t *sa_list)
|
||||
{
|
||||
struct ifaddrs *iflist = NULL, *cur;
|
||||
int rc;
|
||||
c_sockaddr_t *addr, *ifaddr;
|
||||
|
||||
for (addr = sa_list; addr != NULL; addr = addr->next)
|
||||
{
|
||||
if (addr->c_sa_family != AF_INET6)
|
||||
continue;
|
||||
|
||||
if (!IN6_IS_ADDR_LINKLOCAL(&addr->sin6.sin6_addr))
|
||||
continue;
|
||||
|
||||
if (addr->sin6.sin6_scope_id != 0)
|
||||
continue;
|
||||
|
||||
if (iflist == NULL)
|
||||
{
|
||||
rc = getifaddrs(&iflist);
|
||||
if (rc != 0)
|
||||
{
|
||||
d_error("getifaddrs failed(%d:%s)", errno, strerror(errno));
|
||||
return CORE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
for (cur = iflist; cur != NULL; cur = cur->ifa_next)
|
||||
{
|
||||
ifaddr = (c_sockaddr_t *)cur->ifa_addr;
|
||||
|
||||
if (cur->ifa_addr == NULL) /* may happen with ppp interfaces */
|
||||
continue;
|
||||
|
||||
if (cur->ifa_addr->sa_family != AF_INET6)
|
||||
continue;
|
||||
|
||||
if (!IN6_IS_ADDR_LINKLOCAL(&ifaddr->sin6.sin6_addr))
|
||||
continue;
|
||||
|
||||
if (memcmp(&addr->sin6.sin6_addr,
|
||||
&ifaddr->sin6.sin6_addr, sizeof(struct in6_addr)) == 0)
|
||||
{
|
||||
/* Fill Scope ID in localhost */
|
||||
addr->sin6.sin6_scope_id = ifaddr->sin6.sin6_scope_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iflist)
|
||||
freeifaddrs(iflist);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t core_getaddrinfo(c_sockaddr_t **sa_list,
|
||||
int family, const char *hostname, c_uint16_t port, int flags)
|
||||
{
|
||||
|
|
|
@ -66,6 +66,9 @@ gtp_node_t *gtp_connect_to_node(list_t *list, gtp_f_teid_t *f_teid,
|
|||
rv = gtp_f_teid_to_ip(f_teid, &node->ip);
|
||||
d_assert(rv == CORE_OK, return NULL,);
|
||||
|
||||
rv = sock_fill_scope_id_in_local(node->sa_list);
|
||||
d_assert(rv == CORE_OK, return NULL,);
|
||||
|
||||
rv = gtp_client(node);
|
||||
d_assert(rv == CORE_OK, return NULL,);
|
||||
|
||||
|
@ -74,7 +77,6 @@ gtp_node_t *gtp_connect_to_node(list_t *list, gtp_f_teid_t *f_teid,
|
|||
return node;
|
||||
}
|
||||
|
||||
|
||||
status_t gtp_server_list(list_t *list, sock_handler handler)
|
||||
{
|
||||
status_t rv;
|
||||
|
|
|
@ -162,46 +162,46 @@ sgw:
|
|||
#
|
||||
# o Specify SGW addresses the GTP-C must connect to
|
||||
#
|
||||
# o One SGW is defined. If prefer_ipv4 is not true, [fec0::2] is selected.
|
||||
# o One SGW is defined. If prefer_ipv4 is not true, [fe80::2%@LO_DEV@] is selected.
|
||||
# gtpc:
|
||||
# addr:
|
||||
# - 127.0.0.2
|
||||
# - fec0::2
|
||||
# - fe80::2%@LO_DEV@
|
||||
#
|
||||
# o Two SGW are defined. MME selects SGW with round-robin manner per UE
|
||||
# gtpc:
|
||||
# - addr: 127.0.0.2
|
||||
# - addr: fec0::2
|
||||
# - addr: fe80::2%@LO_DEV@
|
||||
#
|
||||
# o Three SGW are defined. MME selects SGW with round-robin manner per UE
|
||||
# gtpc:
|
||||
# - addr
|
||||
# - 127.0.0.2
|
||||
# - fec0::2
|
||||
# - fe80::2%@LO_DEV@
|
||||
# - addr
|
||||
# - 127.0.0.12
|
||||
# - fec0::12
|
||||
# - fec0::12%@LO_DEV@
|
||||
# - name: sgw3.nextepc.org
|
||||
#
|
||||
# ------------------------ SGW --------------------------
|
||||
#
|
||||
# o Specify local addresses the GTP-C server must bind to
|
||||
#
|
||||
# o GTP-C Server(127.0.0.2:2123, [fec0::2]:2123)
|
||||
# o GTP-C Server(127.0.0.2:2123, [fe80::2%@LO_DEV@]:2123)
|
||||
# gtpc:
|
||||
# addr:
|
||||
# - 127.0.0.2
|
||||
# - fec0::2
|
||||
# - fe80::2%@LO_DEV@
|
||||
#
|
||||
# o Same configuration(127.0.0.2:2123, [fec0::2]:2123) as below.
|
||||
# o Same configuration(127.0.0.2:2123, [fe80::2%@LO_DEV@]:2123) as below.
|
||||
# gtpc:
|
||||
# - addr: 127.0.0.2
|
||||
# - addr: fec0::2
|
||||
# - addr: fe80::2%@LO_DEV@
|
||||
#
|
||||
gtpc:
|
||||
addr:
|
||||
- 127.0.0.2
|
||||
- fec0::2
|
||||
- fe80::2%@LO_DEV@
|
||||
|
||||
#
|
||||
# <GTP-U Server>>
|
||||
|
@ -224,31 +224,31 @@ pgw:
|
|||
# o Only first node is attempted. others are ignored.
|
||||
# o if HSS provide PGW addresss(per-UE), it overwrites configuration.
|
||||
#
|
||||
# o Two PGW are defined. 127.0.0.3:2123 is attempted. [::3]:2123 is ignored.
|
||||
# o Two PGW are defined. 127.0.0.3:2123 is attempted. [fe80::3%@LO_DEV@]:2123 is ignored.
|
||||
# gtpc:
|
||||
# - addr: 127.0.0.3
|
||||
# - addr: ::3
|
||||
# - addr: fe80::3%@LO_DEV@
|
||||
#
|
||||
# o One PGW is defined. if prefer_ipv4 is not true, [fec0::2] is selected.
|
||||
# o One PGW is defined. if prefer_ipv4 is not true, [fe80::2%@LO_DEV@] is selected.
|
||||
# gtpc:
|
||||
# - addr:
|
||||
# - 127.0.0.3
|
||||
# - fec0::3
|
||||
# - fe80::3%@LO_DEV@
|
||||
#
|
||||
# ------------------------ PGW --------------------------
|
||||
#
|
||||
# o Specify local addresses the GTP-C server must bind to
|
||||
#
|
||||
# o GTP-C Server(127.0.0.3:2123, [fec0::3]:2123)
|
||||
# o GTP-C Server(127.0.0.3:2123, [fe80::3%@LO_DEV@]:2123)
|
||||
# gtpc:
|
||||
# addr:
|
||||
# - 127.0.0.3
|
||||
# - fec0::3
|
||||
# - fe80::3%@LO_DEV@
|
||||
#
|
||||
gtpc:
|
||||
addr:
|
||||
- 127.0.0.3
|
||||
- fec0::3
|
||||
- fe80::3%@LO_DEV@
|
||||
|
||||
#
|
||||
# <GTP-U Server>>
|
||||
|
@ -258,10 +258,10 @@ pgw:
|
|||
# o GTP-U Server(127.0.0.3:2152, [::3]:2152)
|
||||
# gtpu:
|
||||
# - addr: 127.0.0.3
|
||||
# - addr: fec0::3
|
||||
# - addr: fe80::3%@LO_DEV@
|
||||
gtpu:
|
||||
- addr: 127.0.0.3
|
||||
- addr: fec0::3
|
||||
- addr: fe80::3%@LO_DEV@
|
||||
|
||||
#
|
||||
# <UE network>
|
||||
|
|
|
@ -17,8 +17,12 @@ else
|
|||
ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
|
||||
ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
|
||||
ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
|
||||
ifconfig lo0 inet6 fec0::2 prefixlen 128
|
||||
ifconfig lo0 inet6 fec0::3 prefixlen 128
|
||||
ifconfig lo0 inet6 fec0::4 prefixlen 128
|
||||
ifconfig lo0 inet6 fec0::5 prefixlen 128
|
||||
ifconfig lo0 inet6 delete fe80::2 prefixlen 128 2> /dev/null
|
||||
ifconfig lo0 inet6 delete fe80::3 prefixlen 128 2> /dev/null
|
||||
ifconfig lo0 inet6 delete fe80::4 prefixlen 128 2> /dev/null
|
||||
ifconfig lo0 inet6 delete fe80::5 prefixlen 128 2> /dev/null
|
||||
ifconfig lo0 inet6 add fe80::2 prefixlen 128
|
||||
ifconfig lo0 inet6 add fe80::3 prefixlen 128
|
||||
ifconfig lo0 inet6 add fe80::4 prefixlen 128
|
||||
ifconfig lo0 inet6 add fe80::5 prefixlen 128
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue