CFLib.org – Common Function Library Project

IPDottedDecimal2IPAddress(ipValue)

Last updated September 27, 2002

Version: 1 | Requires: ColdFusion 5 | Library: NetLib

 
Rated 0 time(s). Average Rating: 0

Description:
Use IPDottedDecimal2IPAddress to convert an IP dotted decimal value to an IP address string. Storing decimal values in a database and making comparisons with them is more efficient than using IP address strings.

Return Values:
Returns a string.

Example:

view plain print about
<cfoutput>
#IPDottedDecimal2IPAddress( -1062731769)#
</cfoutput>

Parameters:

Name Description Required
ipValue Dotted decimal value of IP address. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Converts a 32-bit dotted decimal IP number to an IP address.
 * 
 * @param ipValue      Dotted decimal value of IP address. (Required)
 * @return Returns a string. 
 * @author Jonathan Pickard (j_pickard@hotmail.com) 
 * @version 1, September 27, 2002 
 */

function IPDottedDecimal2IPAddress( ipvalue ) {
    var ipAddress = "";
    var lBitMasks = "24,16,8,0";
    var i = 1;

    for ( ; i LTE 4; i = i + 1 )
    {
        ipAddress = ipAddress & "." & BitMaskRead( ipvalue, ListGetAt( lBitMasks, i ), 8 );
    }
    ipAddress = Right( ipAddress, Len( ipAddress ) - 1 );

    return ipAddress;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
12 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson