patch-acinclude_m4 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. --- Libnet-1.0.2a.orig/acinclude.m4 2000-12-12 19:31:54.000000000 +0100
  2. +++ Libnet-1.0.2a/acinclude.m4 2009-06-12 21:48:27.000000000 +0200
  3. @@ -30,65 +30,43 @@ AC_DEFUN(AC_LIBNET_CHECK_PF_PACKET,
  4. *)
  5. cat > pf_packet-test.c << EOF
  6. -#include <net/if.h>
  7. -#if (__GLIBC__)
  8. -#include <netinet/if_ether.h>
  9. -#include <net/if_arp.h>
  10. +#include <stdio.h>
  11. +#include <errno.h>
  12. +#include <stdlib.h>
  13. +#include <netinet/in.h>
  14. +#include <sys/socket.h>
  15. +#include <features.h> /* for the glibc version number */
  16. +#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
  17. +#include <netpacket/packet.h>
  18. +#include <net/ethernet.h> /* the L2 protocols */
  19. #else
  20. -#include <linux/if_arp.h>
  21. -#include <linux/if_ether.h>
  22. +#include <asm/types.h>
  23. +#include <linux/if_packet.h>
  24. +#include <linux/if_ether.h> /* The L2 protocols */
  25. #endif
  26. -#if (PF_PACKET)
  27. +
  28. #ifndef SOL_PACKET
  29. #define SOL_PACKET 263
  30. #endif /* SOL_PACKET */
  31. -#include <linux/if_packet.h>
  32. -#endif
  33. -#include "./include/libnet.h"
  34. int
  35. main()
  36. {
  37. -#if (PF_PACKET)
  38. int fd;
  39. - struct sockaddr_ll sa;
  40. - struct ifreq ifr;
  41. - struct packet_mreq mr;
  42. - char *device ="lo";
  43. fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  44. if (fd == -1)
  45. {
  46. - printf("choked");
  47. - exit (EXIT_FAILURE);
  48. - }
  49. -
  50. - memset(&sa, 0, sizeof(sa));
  51. - strcpy(ifr.ifr_name, device);
  52. - if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0)
  53. - {
  54. - printf("choked");
  55. - exit (EXIT_FAILURE);
  56. - }
  57. - sa.sll_family = AF_PACKET;
  58. - sa.sll_ifindex = ifr.ifr_ifindex;
  59. - sa.sll_protocol = htons(ETH_P_ALL);
  60. -
  61. - memset(&mr, 0, sizeof (mr));
  62. - mr.mr_ifindex = sa.sll_ifindex;
  63. - mr.mr_type = PACKET_MR_ALLMULTI;
  64. -
  65. - if (setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, (char *)&mr,
  66. - sizeof (mr)) < 0)
  67. - {
  68. - printf("choked\n");
  69. + if (errno == EPERM)
  70. + {
  71. + /* user's UID != 0 */
  72. + printf("probably");
  73. + exit (EXIT_FAILURE);
  74. + }
  75. + printf("no");
  76. exit (EXIT_FAILURE);
  77. }
  78. - /* yay. we made it and it workz! */
  79. printf("yes");
  80. -#else /* PF_PACKET */
  81. - printf("no");
  82. -#endif
  83. exit (EXIT_SUCCESS);
  84. }
  85. EOF
  86. @@ -104,16 +82,21 @@ EOF
  87. if test $ac_libnet_have_pf_packet = choked; then
  88. AC_MSG_RESULT(test program choked... assuming no)
  89. elif test $ac_libnet_have_pf_packet = yes; then
  90. - AC_DEFINE(HAVE_PF_PACKET)
  91. + AC_MSG_RESULT(yes)
  92. LIBNET_CONFIG_DEFINES="$LIBNET_CONFIG_DEFINES -DHAVE_PF_PACKET"
  93. + elif test $ac_libnet_have_pf_packet = probably; then
  94. + AC_MSG_RESULT(test program got EPERM... assuming yes)
  95. + elif test $ac_libnet_have_pf_packet = no; then
  96. + AC_MSG_RESULT(no)
  97. fi
  98. - if test $ac_libnet_have_pf_packet != choked; then
  99. - AC_MSG_RESULT($ac_libnet_have_pf_packet)
  100. - fi
  101. rm -f pf_packet-test* core core.pf_packet-test
  102. ;;
  103. esac])
  104. +
  105. + if test $ac_libnet_have_pf_packet = yes -o $ac_libnet_have_pf_packet = probably; then
  106. + AC_DEFINE(HAVE_PF_PACKET)
  107. + fi
  108. ])
  109. dnl
  110. @@ -279,6 +262,8 @@ dnl
  111. AC_DEFUN(AC_LIBNET_ENDIAN_CHECK,
  112. [AC_MSG_CHECKING(machine endianess)
  113. + AC_CACHE_VAL(ac_cv_libnet_endianess,
  114. + [
  115. cat > conftest.c << EOF
  116. # include <stdio.h>
  117. @@ -332,6 +317,7 @@ dnl failed to compile for some reason
  118. fi
  119. rm -f conftest* core core.conftest
  120. + ])
  121. AC_MSG_RESULT($ac_cv_libnet_endianess)
  122. if test $ac_cv_libnet_endianess = big ; then