<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[154358] trunk/dports/net/mtr</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/154358">154358</a></dd>
<dt>Author</dt> <dd>ryandesign@macports.org</dd>
<dt>Date</dt> <dd>2016-10-28 15:50:22 +0200 (Fri, 28 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>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</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportsnetmtrPortfile">trunk/dports/net/mtr/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/dports/net/mtr/files/</li>
<li><a href="#trunkdportsnetmtrfilesHAS_SCTPpatch">trunk/dports/net/mtr/files/HAS_SCTP.patch</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportsnetmtrPortfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/net/mtr/Portfile (154357 => 154358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -30,6 +30,9 @@
</span><span class="cx"> checksums           rmd160 9cc760ec31113462f9aeff94b3ba1af1cb4ed994 \
</span><span class="cx">                     sha256 193947c61d23b154c8dc03677e90e8fd912f8f18567ab76ce619b7856c4af19f
</span><span class="cx"> 
</span><ins>+patch.pre_args      -p1
+patchfiles          HAS_SCTP.patch
+
</ins><span class="cx"> configure.args      --without-gtk
</span><span class="cx"> pre-configure {
</span><span class="cx">     # For some reason, config.h.in is older than aclocal.m4 and configure.ac,
</span></span></pre></div>
<a id="trunkdportsnetmtrfilesHAS_SCTPpatch"></a>
<div class="addfile"><h4>Added: trunk/dports/net/mtr/files/HAS_SCTP.patch (0 => 154358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,128 @@
</span><ins>+From 480fcd3c33bee378c8fead164059dad287b20dc7 Mon Sep 17 00:00:00 2001
+From: Rogier Wolff <R.E.Wolff@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
++
++
</ins></span></pre>
</div>
</div>

</body>
</html>