Very Low Activity

Project Summary

  Analyzed 3 days ago based on code collected 3 days ago.

scala-ipv4 is a Scala library for IPv4 related concepts such as IP addresses, network masks, address pools, etc.

Key ConceptsIpAddressIpAddress represents an IPv4 address.

val address = new IpAddress("192.168.0.1")IpAddress can be used to make calculations on IP addresses, such as finding the next address.

val address = new IpAddress("192.168.0.1")
val next = address + 1
println(next == new IpAddress("192.168.0.2")) // prints trueIpAddressRangeIpAddressRange represents a continuous range of consecutive addresses.

val range = new IpAddressRange(new IpAddress("192.168.0.1"), new IpAddress("192.168.0.5"))
println(range.contains(new IpAddress("192.168.0.3")) // prints trueIpNetworkMaskIpNetworkMask represents a network mask, to be used in an IpNetwork.

val mask1 = new IpNetworkMask("255.255.255.128")
val mask2 = IpNetworkMask.fromPrefixLength(25)
println(mask1 == mask2) // prints true

val invalid = new IpNetworkMask("255.255.255.100") // throws exception
IpNetworkAn IpNetwork is a range (extends IpAddressRange) that can be expressed as a network address and a network mask.

val network1 = new IpNetwork(new IpAddress("192.168.0.0"), new IpNetworkMask("255.255.255.0"))
val network2 = new IpNetwork("192.168.0.0/24")
println(network1 == network2) // prints trueIpAddressPoolAn IpAddressPool is like a range (extends IpAddressRange) of which certain addresses are "allocated" and other are "free".

var pool = new IpAddressPool(new IpAddress("1.2.3.4"), new IpAddress("1.2.3.10"))
println(pool.isFree(new IpAddress("1.2.3.6"))) // prints true
pool.allocate(new IpAddress("1.2.3.6")) match {
case (newPool, allocated) => {
println(newPool.isFree(new IpAddress("1.2.3.6"))) // prints false
}
}And Much MoreMuch more can be done with these types. Have a look at the scaladoc or the test sources (especially the ones ending in "Example") to get an idea of the possibilities.

Share

In a Nutshell, scala-ipv4...

 

Activity

30 Day Summary Apr 17 2013 — May 17 2013

12 Month Summary May 17 2012 — May 17 2013

  • 0 Commits Down -1 (100%) from previous 12 months
  • 0 Contributors Down -1 (100%) from previous 12 months

Community

Ratings

Be the first to rate this project
 
Click to add your rating
 
Review this Project!
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.