]> The Tcpdump Group git mirrors - tcpdump/commitdiff
adopt MacOS deprecation workaround from FreeRADIUS
authorDenis Ovsienko <[email protected]>
Wed, 16 Oct 2013 13:59:13 +0000 (17:59 +0400)
committerDenis Ovsienko <[email protected]>
Fri, 18 Oct 2013 05:24:37 +0000 (09:24 +0400)
A MacOS build of tcpdump used to produce deprecation warnings on OpenSSL
function calls. Alan DeKok explained that this is the effect of Apple's
modifications to OpenSSL and that the very same problem has already been
solved in FreeRADIUS server source code with pre-processor macros.

Copy the macros into tcpdump header file and make use of them around the
functions that call OpenSSL functions.

print-esp.c
print-tcp.c
signature.c
tcpdump-stdinc.h

index 5e8f282cc1f1c5d4dcb24eaa63a5bfd8248cddd1..2c143cd6a575431ead790d71ce8a8aef5454743b 100644 (file)
@@ -93,6 +93,7 @@ struct sa_list {
 /*
  * this will adjust ndo_packetp and ndo_snapend to new buffer!
  */
+USES_APPLE_DEPRECATED_API
 int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
                                      int initiator,
                                      u_char spii[8], u_char spir[8],
@@ -142,6 +143,7 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
        return 1;
        
 }
+USES_APPLE_RST
 
 static void esp_print_addsa(netdissect_options *ndo,
                            struct sa_list *sa, int sa_def)
@@ -218,6 +220,7 @@ int espprint_decode_hex(netdissect_options *ndo,
  * decode the form:    SPINUM@IP <tab> ALGONAME:0xsecret
  */
 
+USES_APPLE_DEPRECATED_API
 static int
 espprint_decode_encalgo(netdissect_options *ndo,
                        char *decode, struct sa_list *sa)
@@ -283,6 +286,7 @@ espprint_decode_encalgo(netdissect_options *ndo,
 
        return 1;
 }
+USES_APPLE_RST
 
 /*
  * for the moment, ignore the auth algorith, just hard code the authenticator
@@ -483,12 +487,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
        esp_print_addsa(ndo, &sa1, sa_def);
 }
 
+USES_APPLE_DEPRECATED_API
 static void esp_init(netdissect_options *ndo _U_)
 {
 
        OpenSSL_add_all_algorithms();
        EVP_add_cipher_alias(SN_des_ede3_cbc, "3des");
 }
+USES_APPLE_RST
 
 void esp_print_decodesecret(netdissect_options *ndo)
 {
@@ -518,6 +524,9 @@ void esp_print_decodesecret(netdissect_options *ndo)
 
 #endif
 
+#ifdef HAVE_LIBCRYPTO
+USES_APPLE_DEPRECATED_API
+#endif
 int
 esp_print(netdissect_options *ndo,
          const u_char *bp, const int length, const u_char *bp2
@@ -691,6 +700,9 @@ esp_print(netdissect_options *ndo,
 fail:
        return -1;
 }
+#ifdef HAVE_LIBCRYPTO
+USES_APPLE_RST
+#endif
 
 /*
  * Local Variables:
index b12fb9a6605ed78bedbc35ee6d8f8b0b18667454..f8e0ee723518bac5bd0d2d8addbb4c816ad32cd9 100644 (file)
@@ -774,6 +774,7 @@ print_tcp_rst_data(register const u_char *sp, u_int length)
 }
 
 #ifdef HAVE_LIBCRYPTO
+USES_APPLE_DEPRECATED_API
 static int
 tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
                      const u_char *data, int length, const u_char *rcvsig)
@@ -860,6 +861,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
         else
                 return (SIGNATURE_INVALID);
 }
+USES_APPLE_RST
 #endif /* HAVE_LIBCRYPTO */
 
 /*
index c55645fe2bdf9687239f499cc59420b4fcadf347..b2a7084a899073378f68f96ef4c921c968032382 100644 (file)
@@ -48,6 +48,7 @@ const struct tok signature_check_values[] = {
  * Compute a HMAC MD5 sum.
  * Taken from rfc2104, Appendix.
  */
+USES_APPLE_DEPRECATED_API
 static void
 signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *key,
                            unsigned int key_len, u_int8_t *digest)
@@ -110,6 +111,7 @@ signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *ke
     MD5_Update(&context, digest, 16);     /* then results of 1st hash */
     MD5_Final(digest, &context);          /* finish up 2nd pass */
 }
+USES_APPLE_RST
 #endif
 
 #ifdef HAVE_LIBCRYPTO
index eb6c9428d9064260a68948128a3a8df3921fa656..91f3361bc77bf75a5956481d4e51032537daa455 100644 (file)
@@ -232,4 +232,50 @@ typedef char* caddr_t;
 #define FALSE 0
 #endif
 
+/*
+ * The Apple deprecation workaround macros below were adopted from the
+ * FreeRADIUS server code under permission of Alan DeKok and Arran Cudbard-Bell.
+ */
+
+#define XSTRINGIFY(x) #x
+
+/*
+ *     Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8
+ */
+#define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y)
+#define DIAG_DO_PRAGMA(x) _Pragma (#x)
+
+#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
+#  define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
+#  if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#    define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+#    define DIAG_ON(x) DIAG_PRAGMA(pop)
+#  else
+#    define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+#    define DIAG_ON(x)  DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x))
+#  endif
+#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208)
+#  define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
+#  define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+#  define DIAG_ON(x) DIAG_PRAGMA(pop)
+#else
+#  define DIAG_OFF(x)
+#  define DIAG_ON(x)
+#endif
+
+/*
+ *     For dealing with APIs which are only deprecated in OSX (like the OpenSSL API)
+ */
+#ifdef __APPLE__
+#  define USES_APPLE_DEPRECATED_API DIAG_OFF(deprecated-declarations)
+#  define USES_APPLE_RST DIAG_ON(deprecated-declarations)
+#else
+#  define USES_APPLE_DEPRECATED_API
+#  define USES_APPLE_RST
+#endif
+
+/*
+ * end of Apple deprecation workaround macros
+ */
+
 #endif /* tcpdump_stdinc_h */