Browsing projects by Tag(s)

Select a tag to browse associated projects and drill deeper into the tag cloud.

Showing page 1 of 1

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 ... [More] 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. [Less]

0
 
  0 reviews  |  0 users  |  1,073 lines of code  |  0 current contributors  |  Analyzed 6 days ago
 
 
 
 

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.