CFLib.org – Common Function Library Project

calcNetAddress(myIP, myNetMask)

Last updated May 12, 2003
Download UDF

author

Tanguy Rademakers                                 Tanguy Rademakers

Version: 1 | Requires: ColdFusion 5 | 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:

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

Search CFLib.org


Latest Additions

Raymond Compton Raymond Compton added
structBlend
19 day(s) ago

Duncan Duncan added
IsZIPUK
19 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
25 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson