CFLib.org – Common Function Library Project

calcNetAddress(myIP, myNetMask)

Last updated May 12, 2003

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

 
Rated 0 time(s). Average Rating: 0

Description:
calculate a network address from an IP address and a (sub)Netmask. Does not validate either input parameter.

Return Values:
Returns an IP address (string).

Example:

view plain print about
<cfoutput>
#calcNetAddress('217.136.252.232','255.255.255.197')#
</cfoutput>

Parameters:

Name Description Required
myIP IP Address. Yes
myNetMask Netmask. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * calculate a network address from an IP address and a (sub)Netmask.
 * 
 * @param myIP      IP Address. (Required)
 * @param myNetMask      Netmask. (Required)
 * @return Returns an IP address (string). 
 * @author Tanguy Rademakers (t@newmediatwins.net) 
 * @version 1, May 12, 2003 
 */

function calcNetAddress (myIP, myNetMask) {
    var NetAddress = "";
    var i = 1;
    
    for (i = 1; i lte 4; i = i + 1) {
        NetAddress = ListAppend(NetAddress, BitAnd(ListGetAt(myIP,i,'.'),ListGetAt(myNetMask,i,'.')) ,'.'); 
    }
    return NetAddress;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Adam Cameron Adam Cameron added
composeDateTime
a while ago

Chris Weller Chris Weller added
convertQueryStri...
a while ago

Greg Nettles Greg Nettles added
arrayDiff
a while ago

Nathan Dintenfass Nathan Dintenfass added
ArrayOfStructsSo...
a while ago

Top Rated

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

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Rachel Lehman deAccent
Rated 5.0, 6 time(s)

Isaac Dealey                                      countArbitraryDa...
Rated 5.0, 5 time(s)

Created by Raymond Camden / Design by Justin Johnson