CFLib.org – Common Function Library Project

IPclass(ip)

Last updated February 14, 2004

author

del usr

Version: 1 | Requires: CF5 | Library: NetLib

Description:
Converts an IP address to a network class.

Return Values:
Returns a string.

Example:

<cfset varip = "192.168.0.1">
<cfset varclass = ipclass("192.168.0.1")>
<cfoutput>
	IP: #varip#<br />
	Class: #varclass#<br />
</cfoutput>

Parameters:

Name Description Required
ip IP address. Yes

Full UDF Source:

/**
 * Converts an IP address to a network class.
 * 
 * @param ip 	 IP address. (Required)
 * @return Returns a string. 
 * @author del usr (delusrexpert@hotmail.com) 
 * @version 1, February 14, 2004 
 */
function IPclass(ip) {
	var myint = listFirst(ip, ".");
	if (myint GTE 1 and myint LTE 127) return "Class A";
	if (myint GTE 128 and myint LTE 191) return "Class B";
	if (myint GTE 192 and myint LTE 223) return "Class C";
	if (myint GTE 224 and myint LTE 239) return "Class D";
	if (myint GTE 240 and myint LTE 255) return "Class E";
}
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