+ // find or allocate a CattaInterfaceAddress struct for this address
+ if(!(ifaddr = catta_interface_monitor_get_address(m, iface, &addr))) {
+ if(!(ifaddr = catta_interface_address_new(m, iface, &addr, a->OnLinkPrefixLength))) {
+ catta_log_error("out of memory in ip_adapter_unicast_address");
+ return;
+ }
+ }
+
+ // set global scope flag
+ // XXX should we use the IP_ADAPTER_ADDRESS_DNS_ELIGIBLE flag for this?
+ // it looks like it gets set for IPv4 addresses that are not localhost
+ // and for IPv6 addresses with global scope. not sure about multicast
+ // addresses.
+ if(addr.proto == CATTA_PROTO_INET6)
+ ifaddr->global_scope = !(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr.data.data)
+ || IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr.data.data));
+ else
+ ifaddr->global_scope = 1;
+
+ // XXX debugging, remove
+ {
+ char s[CATTA_ADDRESS_STR_MAX];
+ catta_log_debug(" address: %s\n"
+ " global_scope: %d\n"
+ " flags: 0x%.4x",
+ catta_address_snprint(s, sizeof(s), &addr),
+ ifaddr->global_scope,
+ (unsigned int)a->Flags);
+ }