File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 4141#ifdef HAVE_SYS_IOCCOM_H
4242#include <sys/ioccom.h>
4343#endif
44+
45+ /*
46+ * On most supported platforms <sys/ioctl.h> also defines the SIOCGIF* macros.
47+ * However, on Haiku, illumos and Solaris the macros need <sys/sockio.h>,
48+ * which does not exist in AIX 7, HP-UX 11, GNU/Hurd and Linux (both GNU and
49+ * musl libc).
50+ */
51+ #if defined(HAVE_SOLARIS ) || defined(__HAIKU__ ) || defined(__sun ) || defined(__SVR4 )
52+ #include <sys/sockio.h>
53+ #endif
54+
4455#include <sys/utsname.h>
4556
4657#if defined(__FreeBSD__ ) && defined(SIOCIFCREATE2 )
@@ -654,6 +665,7 @@ check_interface_exists(const char *name, char *errbuf)
654665 memset (& ifr , 0 , sizeof (ifr ));
655666 pcapint_strlcpy (ifr .ifr_name , name , sizeof (ifr .ifr_name ));
656667
668+ #ifdef SIOCGIFFLAGS
657669 if (ioctl (fd , SIOCGIFFLAGS , & ifr ) < 0 ) {
658670 int save_errno = errno ;
659671 close (fd );
@@ -669,6 +681,13 @@ check_interface_exists(const char *name, char *errbuf)
669681 return PCAP_ERROR ;
670682 }
671683 }
684+ #else
685+ /*
686+ * SIOCGIFFLAGS not available on this platform.
687+ * We can't reliably check interface existence without privileges,
688+ * so we skip the check and let the BPF bind operation handle it.
689+ */
690+ #endif
672691
673692 close (fd );
674693 return 0 ;
You can’t perform that action at this time.
0 commit comments