[154358] trunk/dports/net/mtr

ryandesign at macports.org ryandesign at macports.org
Fri Oct 28 15:50:22 CEST 2016


Revision: 154358
          https://trac.macports.org/changeset/154358
Author:   ryandesign at macports.org
Date:     2016-10-28 15:50:22 +0200 (Fri, 28 Oct 2016)
Log Message:
-----------
mtr: Apply upstream patch to fix build on older systems

Resolves https://lists.macosforge.org/pipermail/macports-users/2016-October/041874.html

See https://github.com/traviscross/mtr/issues/141

Modified Paths:
--------------
    trunk/dports/net/mtr/Portfile

Added Paths:
-----------
    trunk/dports/net/mtr/files/
    trunk/dports/net/mtr/files/HAS_SCTP.patch

Modified: trunk/dports/net/mtr/Portfile
===================================================================
--- trunk/dports/net/mtr/Portfile	2016-10-28 13:14:44 UTC (rev 154357)
+++ trunk/dports/net/mtr/Portfile	2016-10-28 13:50:22 UTC (rev 154358)
@@ -30,6 +30,9 @@
 checksums           rmd160 9cc760ec31113462f9aeff94b3ba1af1cb4ed994 \
                     sha256 193947c61d23b154c8dc03677e90e8fd912f8f18567ab76ce619b7856c4af19f
 
+patch.pre_args      -p1
+patchfiles          HAS_SCTP.patch
+
 configure.args      --without-gtk
 pre-configure {
     # For some reason, config.h.in is older than aclocal.m4 and configure.ac,

Added: trunk/dports/net/mtr/files/HAS_SCTP.patch
===================================================================
--- trunk/dports/net/mtr/files/HAS_SCTP.patch	                        (rev 0)
+++ trunk/dports/net/mtr/files/HAS_SCTP.patch	2016-10-28 13:50:22 UTC (rev 154358)
@@ -0,0 +1,128 @@
+From 480fcd3c33bee378c8fead164059dad287b20dc7 Mon Sep 17 00:00:00 2001
+From: Rogier Wolff <R.E.Wolff at BitWizard.nl>
+Date: Sun, 21 Aug 2016 12:28:57 +0200
+Subject: [PATCH] fixed #141 compile without SCTP if not available
+
+---
+ mtr.c |  6 ++++++
+ net.c | 15 ++++++++++++++-
+ net.h |  6 ++++++
+ 3 files changed, 26 insertions(+), 1 deletion(-)
+
+diff --git a/mtr.c b/mtr.c
+index 201b311..914c2b4 100644
+--- a/mtr.c
++++ b/mtr.c
+@@ -524,6 +524,7 @@ void parse_arg (int argc, char **argv)
+       mtrtype = IPPROTO_TCP;
+       break;
+     case 'S':
++#ifdef HAS_SCTP
+       if (mtrtype != IPPROTO_ICMP) {
+         fprintf(stderr, "-u , -T and -S are mutually exclusive.\n");
+         exit(EXIT_FAILURE);
+@@ -532,6 +533,11 @@ void parse_arg (int argc, char **argv)
+         remoteport = 80;
+       }
+       mtrtype = IPPROTO_SCTP;
++#else
++      fprintf (stderr, "No SCTP support found at compiletime\n");
++      exit (EXIT_FAILURE);
++#endif
++      break;
+     case 'b':
+       show_ips = 1;
+       break;
+diff --git a/net.c b/net.c
+index c591acc..c94abb4 100644
+--- a/net.c
++++ b/net.c
+@@ -70,12 +70,17 @@ struct TCPHeader {
+   uint32 seq;
+ };
+ 
++// This ifdef is unnecessary. But it should trigger errors if I forget
++// an ifdef HAS_SCTP further down.  (Success! I forgot one and the compiler
++// told me the line number!)
++#ifdef HAS_SCTP 
+ /* Structure of an SCTP header */
+ struct SCTPHeader {
+   uint16 srcport;
+   uint16 dstport;
+   uint32 veri_tag;
+ };
++#endif
+ 
+ /* Structure of an IPv4 UDP pseudoheader.  */
+ struct UDPv4PHeader {
+@@ -438,6 +443,7 @@ void net_send_tcp(int index)
+   connect(s, (struct sockaddr *) &remote, len);
+ }
+ 
++#ifdef HAS_SCTP
+ /*  Attempt to connect to a SCTP port with a TTL */
+ void net_send_sctp(int index)
+ {
+@@ -556,6 +562,7 @@ void net_send_sctp(int index)
+ 
+   connect(s, (struct sockaddr *) &remote, len);
+ }
++#endif
+ 
+ /*  Attempt to find the host at a particular number of hops away  */
+ void net_send_query(int index) 
+@@ -565,10 +572,12 @@ void net_send_query(int index)
+     return;
+   }
+   
++#ifdef HAS_SCTP
+   if (mtrtype == IPPROTO_SCTP) {
+     net_send_sctp(index);
+     return;
+   }
++#endif
+ 
+   /*ok  char packet[sizeof(struct IPHeader) + sizeof(struct ICMPHeader)];*/
+   char packet[MAXPACKET];
+@@ -885,7 +894,9 @@ void net_process_return(void)
+   struct ICMPHeader *header = NULL;
+   struct UDPHeader *udpheader = NULL;
+   struct TCPHeader *tcpheader = NULL;
++#ifdef HAS_SCTP
+   struct SCTPHeader *sctpheader = NULL;
++#endif
+   struct timeval now;
+   ip_t * fromaddress = NULL;
+   int echoreplytype = 0, timeexceededtype = 0, unreachabletype = 0;
+@@ -1065,7 +1076,8 @@ void net_process_return(void)
+       seq_num = ntohs(tcpheader->srcport);
+     }
+     break;
+-    
++
++#ifdef HAS_SCTP
+   case IPPROTO_SCTP:
+     if (header->type == timeexceededtype || header->type == unreachabletype) {
+       switch ( af ) {
+@@ -1102,6 +1114,7 @@ void net_process_return(void)
+       seq_num = ntohs(sctpheader->srcport);
+     }
+     break;
++#endif
+   }
+   if (seq_num)
+     net_process_ping (seq_num, mpls, (void *) fromaddress, now);
+diff --git a/net.h b/net.h
+index 23183c1..0350a4a 100644
+--- a/net.h
++++ b/net.h
+@@ -134,3 +134,9 @@ struct mplslen {
+ };
+ 
+ void decodempls(int, char *, struct mplslen *, int);
++
++#ifdef IPPROTO_SCTP
++    #define HAS_SCTP
++#endif
++
++
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-changes/attachments/20161028/edbc89f1/attachment-0002.html>


More information about the macports-changes mailing list