@@ -148,7 +148,7 @@ static void addNewIp(FFlist* list, const char* name, const char* addr, int type,
148148 }
149149}
150150
151- static bool isIPv6AddressPreferred (const char * ifname , struct sockaddr_in6 * addr )
151+ static bool isIPv6AddressPreferred (struct ifaddrs * ifa , struct sockaddr_in6 * addr )
152152{
153153#ifndef IN6_IS_ADDR_GLOBAL
154154#define IN6_IS_ADDR_GLOBAL (a ) \
@@ -177,7 +177,7 @@ static bool isIPv6AddressPreferred(const char* ifname, struct sockaddr_in6* addr
177177 if (sockfd < 0 ) return true; // Give up
178178
179179 struct in6_ifreq ifr6 = {};
180- ffStrCopy (ifr6 .ifr_name , ifname , IFNAMSIZ );
180+ ffStrCopy (ifr6 .ifr_name , ifa -> ifa_name , IFNAMSIZ );
181181 ifr6 .ifr_addr = * addr ;
182182
183183 if (ioctl (sockfd , SIOCGIFAFLAG_IN6 , & ifr6 ) != 0 )
@@ -228,6 +228,10 @@ static bool isIPv6AddressPreferred(const char* ifname, struct sockaddr_in6* addr
228228 return true;
229229 }
230230 return false;
231+ #elif __sun
232+ if (ifa -> ifa_flags & IFF_PREFERRED )
233+ return true;
234+ return !(ifa -> ifa_flags & (IFF_DEPRECATED | IFF_TEMPORARY | IFF_DUPLICATE ));
231235#else
232236 return true;
233237#endif
@@ -306,7 +310,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
306310 continue ;
307311
308312 struct sockaddr_in6 * ipv6 = (struct sockaddr_in6 * )ifa -> ifa_addr ;
309- if (!(options -> showType & FF_LOCALIP_TYPE_ALL_IPS_BIT ) && !isIPv6AddressPreferred (ifa -> ifa_name , ipv6 ))
313+ if (!(options -> showType & FF_LOCALIP_TYPE_ALL_IPS_BIT ) && !isIPv6AddressPreferred (ifa , ipv6 ))
310314 continue ;
311315
312316 char addressBuffer [INET6_ADDRSTRLEN + 16 ];
0 commit comments