Last active
December 31, 2015 13:19
-
-
Save elad-yosifon/7992405 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @param {number} i | |
* @returns {string} | |
*/ | |
function INET_NTOA(i) | |
{ | |
var ip = []; | |
ip[0] = (i >> 24) & 0xFF; | |
ip[1] = (i >> 16) & 0xFF; | |
ip[2] = (i >> 8) & 0xFF; | |
ip[3] = i & 0xFF; | |
return ip.join('.'); | |
} | |
/** | |
* | |
* @param {string} ip | |
* @returns {number} | |
*/ | |
function INET_ATON(ip) | |
{ | |
var octets = ip.split('.'); | |
var number = 0; | |
number |= octets[3]; | |
number |= (octets[2] << 8); | |
number |= (octets[1] << 16); | |
number += (octets[0] * (1 << 24)); | |
return number; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment