<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/12830" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2006-12-14T14:01:12-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/12830</id>

		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2006-12-14T14:01:12-04:00</updated>

		<published>2006-12-14T14:01:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68964#p68964</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68964#p68964"/>
		<title type="html"><![CDATA[converting dotted quad ip to longip?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68964#p68964"><![CDATA[
<blockquote class="uncited"><div>masking with 0xffffffff does the <em class="text-italics">format %u</em> trick</div></blockquote>format %u is the only way to make it work in tcl &lt;= 8.3.2 (and possibly even higher versions) - i don't know when they changed this, but <a href="http://wiki.tcl.tk/10786" class="postlink">this</a> page suggests a variant of the problem is still present in 8.4.3<div class="codebox"><p>Code: </p><pre><code>% info patchlevel8.3.2% a2n 128.0.0.0-2147483648</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Thu Dec 14, 2006 2:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2006-12-14T13:16:48-04:00</updated>

		<published>2006-12-14T13:16:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68961#p68961</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68961#p68961"/>
		<title type="html"><![CDATA[converting dotted quad ip to longip?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68961#p68961"><![CDATA[
as ever, user has the more elegant solution <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>nevertheless, the [expr] version is correct as is:<div class="codebox"><p>Code: </p><pre><code>% a2n 128.0.0.02147483648% n2a 2147483648128.0.0.0</code></pre></div>masking with 0xffffffff does the <em class="text-italics">format %u</em> trick<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Thu Dec 14, 2006 1:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-12-14T07:27:47-04:00</updated>

		<published>2006-12-14T07:27:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68956#p68956</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68956#p68956"/>
		<title type="html"><![CDATA[converting dotted quad ip to longip?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68956#p68956"><![CDATA[
Sweet. Thanks demond &amp; user <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Thu Dec 14, 2006 7:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2006-12-14T05:59:21-04:00</updated>

		<published>2006-12-14T05:59:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68955#p68955</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68955#p68955"/>
		<title type="html"><![CDATA[converting dotted quad ip to longip?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68955#p68955"><![CDATA[
<blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>proc a2n {s} {   foreach {a b c d} [split $s .] {return [expr 0xFFFFFFFF&amp;(($a&lt;&lt;24)+($b&lt;&lt;16)+($c&lt;&lt;8)+$d)]}}</code></pre></div></div></blockquote>try <div class="codebox"><p>Code: </p><pre><code>a2n 128.0.0.0</code></pre></div> (if the number is treated as a signed 32 bit integer, you'll get an overflow for ips &gt;= 128.0.0.0) you need to format the output to be an unsigned int (format %u)<br><br>Here's a couple of procs doing the same thing without expr <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><div class="codebox"><p>Code: </p><pre><code>proc dec2dot dec {join [scan [format %08x $dec] %2x%2x%2x%2x] .}proc dot2dec dot {format %u [eval format 0x%02x%02x%02x%02x [split $dot .]]}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Thu Dec 14, 2006 5:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2006-12-14T05:28:26-04:00</updated>

		<published>2006-12-14T05:28:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68954#p68954</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68954#p68954"/>
		<title type="html"><![CDATA[converting dotted quad ip to longip?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68954#p68954"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc n2a {n} {   foreach i {24 16 8 0} {append s [format %d. [expr ($n&gt;&gt;$i)&amp;0xFF]]}   return [string trimright $s .]}proc a2n {s} {   foreach {a b c d} [split $s .] {return [expr 0xFFFFFFFF&amp;(($a&lt;&lt;24)+($b&lt;&lt;16)+($c&lt;&lt;8)+$d)]}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Thu Dec 14, 2006 5:28 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-12-14T02:20:15-04:00</updated>

		<published>2006-12-14T02:20:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68952#p68952</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68952#p68952"/>
		<title type="html"><![CDATA[converting dotted quad ip to longip?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68952#p68952"><![CDATA[
After reading a post in the egghelp forum about the "longip" used in eggdrop's logs for dcc chat connects, I did a little research and came across a bit of code to convert longip to dotted quad's, and vice versa. However, the piece called "inet_addr" that's supposed to convert dotted quad ip's to longip's doesn't seem to use the same base, or something. I'm not familiar with the 'binary' command well enough to figure this out.<br><br>Here's the relevent piece of code:<div class="codebox"><p>Code: </p><pre><code># convert dotted quad ip to long ipproc inet_addr { ipaddr } {        set addr [binary format c4 [split $ipaddr .]]        binary scan $addr i bin        return $bin}</code></pre></div>The other segment is called inet_ntoa:<div class="codebox"><p>Code: </p><pre><code># convert long ip to dotted quad ipproc inet_ntoa { ipaddr } {        set bin [binary format i $ipaddr]        binary scan $bin cccc a b c d        set a [expr { ($a + 0x100) % 0x100 }]        set b [expr { ($b + 0x100) % 0x100 }]        set c [expr { ($c + 0x100) % 0x100 }]        set d [expr { ($d + 0x100) % 0x100 }]        #        # Note: this is what was in the original, it presents the dotted quad ip *backwards*...        # I don't know if that is how inet_ntoa normally behaves -rosc        #return "$a.$b.$c.$d"        #        # So, for my purposes, I present the dotted quad ip in the right order.        return "$d.$c.$b.$a"}</code></pre></div>When I take a longip from eggdrop's log, and run it through the inet_ntoa, that works just fine, I get my dotted quad IP back as it should. <br><br>But, if I then take my dotted quad IP and try to run it through the inet_addr proc, it produces a number nowhere near the number eggdrop uses in its log.<br><br>For example:<br><br>&lt;rosc&gt; .long2quad 3473389373   (this is the number in eggdrop's log)<br>&lt;TheEntity&gt; Long IP To Dotted Quad IP: 207.7.183.61<br><br>&lt;rosc&gt; .quad2long 207.7.183.61<br>&lt;TheEntity&gt; Dotted Quad IP To Long IP: 1035405263<br><br>Curiously, if I then run that longip back through, I get my ip back, backwards:<br><br>&lt;rosc&gt; .long2quad 1035405263<br>&lt;TheEntity&gt; Long IP To Dotted Quad IP: 61.183.7.207<br><br>My question is, how to fix the proc inet_addr thing to give me the same longip number that eggdrop itself uses? I'm guessing that the proc as written, uses a different base than what eggdrop is using.<br><br>BTW, I found the above bits of code here:<br><a href="http://www.mail-archive.com/aolserver@listserv.aol.com/msg02599.html" class="postlink">http://www.mail-archive.com/aolserver@l ... 02599.html</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Thu Dec 14, 2006 2:20 am</p><hr />
]]></content>
	</entry>
	</feed>
