<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Monaco;
panose-1:2 0 5 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:Calibri;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:Calibri;
color:windowtext;}
p.p1, li.p1, div.p1
{mso-style-name:p1;
margin:0cm;
margin-bottom:.0001pt;
background:black;
font-size:7.5pt;
font-family:Monaco;
color:whitesmoke;}
span.s1
{mso-style-name:s1;}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
p.p2, li.p2, div.p2
{mso-style-name:p2;
margin:0cm;
margin-bottom:.0001pt;
background:black;
font-size:7.5pt;
font-family:Monaco;
color:whitesmoke;}
span.msoIns
{mso-style-type:export-only;
mso-style-name:"";
text-decoration:underline;
color:teal;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:Calibri;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">I spent a couple of hours to be able to compile and run RADVD version 2.* on a Mac OS/X...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">One issue was the lack of support of clock_gettime() on Mac OS/X and the other issue was that BSD embeds the interface index into the 3<sup>rd</sup> & 4<sup>th</sup> bytes of the source and destination link-local
addresses (weird, really weird IMHO). <a href="https://www.freebsd.org/doc/en/books/developers-handbook/ipv6.html#ipv6-scope-index">
https://www.freebsd.org/doc/en/books/developers-handbook/ipv6.html#ipv6-scope-index</a>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">When fixing those two issues, wireshard 2.* runs fine on Mac OS/X :-)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Here are the changes (I used __MACH__ but could be __BSD__ or whatever):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">In UTILS.C, adding:<o:p></o:p></span></p>
<p class="p1"><span class="s1">#ifdef __MACH__</span><o:p></o:p></p>
<p class="p1"><span class="s1">int clock_gettime(int clk_id, struct timespec *t){</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">mach_timebase_info_data_t timebase;</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">mach_timebase_info(&timebase);</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">uint64_t time;</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">time = mach_absolute_time();</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom);</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9);</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">t->tv_sec = seconds;</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">t->tv_nsec = nseconds;</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">return 0;</span><o:p></o:p></p>
<p class="p1"><span class="s1">}</span><o:p></o:p></p>
<p class="p1"><span class="s1">#endif</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">In SEND.C, function SEND_RA:<o:p></o:p></span></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">char dest_text[INET6_ADDRSTRLEN] = {""};</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">char src_text[INET6_ADDRSTRLEN] = {""};</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">addrtostr(dest, dest_text, INET6_ADDRSTRLEN);</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">addrtostr(iface->props.if_addr_rasrc, src_text, INET6_ADDRSTRLEN);</span><o:p></o:p></p>
<p class="p1"><span class="s1">#ifdef __MACH__</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">/* Probably not the most suitable place to change the source Link Local address...</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">but see https://www.freebsd.org/doc/en/books/developers-handbook/ipv6.html#ipv6-scope-index */</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">iface->props.if_addr_rasrc->s6_addr[3] = iface->props.if_index % 256 ;</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">iface->props.if_addr_rasrc->s6_addr[2] = iface->props.if_index >> 8 ;</span><o:p></o:p></p>
<p class="p1"><span class="s1">#endif</span><o:p></o:p></p>
<p class="p2"><o:p> </o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">// Build RA header</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">struct safe_buffer *ra_hdr = new_safe_buffer();</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">add_ra_header(ra_hdr, &iface->ra_header_info, iface->state_info.cease_adv);</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">In SEND.C, function REALLY_SEND:<o:p></o:p></span></p>
<p class="p1"><o:p> </o:p></p>
<p class="p2"><span class="s1">#ifdef HAVE_SIN6_SCOPE_ID</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">if (IN6_IS_ADDR_LINKLOCAL(&addr.sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&addr.sin6_addr)) {</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">dlog(LOG_DEBUG, 5, "sending to a link scoped address for interface #%d", props->if_index) ;</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">addr.sin6_scope_id = props->if_index;</span><o:p></o:p></p>
<p class="p2"><span class="s1">#ifdef __MACH__</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">/* According to https://www.freebsd.org/doc/en/books/developers-handbook/ipv6.html#ipv6-scope-index, BSD (including Mac OS/X needs to embed the interface index in the
address !!! */</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">addr.sin6_addr.s6_addr[3] = props->if_index % 256 ;</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">addr.sin6_addr.s6_addr[2] = props->if_index >> 8 ;</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">char dest_text[INET6_ADDRSTRLEN] = {""};</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">addrtostr(&addr.sin6_addr, dest_text, INET6_ADDRSTRLEN);</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">dlog(LOG_DEBUG, 5, "modified link-local destination address for BSD -> %s", dest_text) ;</span><o:p></o:p></p>
<p class="p2"><span class="s1">#endif</span><o:p></o:p></p>
<p class="p2"><span class="apple-converted-space"> </span><span class="s1">}</span><o:p></o:p></p>
<p class="p2"><span class="s1">#endif</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Hope this helps<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">-éric<o:p></o:p></span></p>
</div>
</body>
</html>