CFLib.org – Common Function Library Project

calcNetAddress(myIP, myNetMask)

Last updated May 12, 2003

author

Tanguy Rademakers

Version: 1 | Requires: CF5 | Library: NetLib

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:

<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:

/**
 * 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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson