Bitvantage / InternetProtocol.NetworkPrefix

A library for working with IPv4 and IPV6 network prefixes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bitvantage.InternetProtocol.NetworkPrefix

A library for working with IPv4 and IPV6 network prefixes.

Installing via NuGet Package Manager

PM> NuGet\Install-Package Bitvantage.InternetProtocol.NetworkPrefix

Quick Start

// create a new network prefix
var prefix = NetworkPrefix.Parse("10.0.0.0/24");

// get the total number of host addresses in a network
var totalHosts = prefix.TotalHosts;

// get the total number of addresses in a network
var totalAddresses = prefix.TotalAddresses;

// iterate through each host address
foreach(var address in prefix.Hosts()
	Console.WriteLine(address);

// determine if a prefix is contained by a different prefix
var prefixContainsPrefix = prefix.Contains("10.0.0.0/25");

// determine if a IP address is contained by a prefix
var prefixContainsHost = prefix.Contains(IPAddress.Parse("10.0.0.100");

About

A library for working with IPv4 and IPV6 network prefixes.

License:GNU Affero General Public License v3.0


Languages

Language:C# 100.0%