ipsubnet

package module
v0.0.0-...-30bc98f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2017 License: MIT Imports: 3 Imported by: 5

README

IPv4 Subnet Calculator (GO)

Network calculator for subnet mask and other classless (CIDR) network information.

Build Status GoDoc license

Calculations
  • IP address network subnet masks, network and host portions, and provides aggregated reports.
  • Subnet mask
  • Network portion
  • Host portion
  • Number of IP addresses in the network
  • Number of addressable hosts in the network
  • IP address range
  • Broadcast address

Provides each data in dotted quads, hexadecimal, and binary formats, as well as array of quads.

Usages

Install
go get -u github.com/brotherpowers/ipsubnet
Get Started
import "github.com/brotherpowers/ipsubnet"

sub := ipsubnet.SubnetCalculator("192.168.112.203", 23)
Get Network Information
sub.GetNumberIPAddresses();      // 512
sub.GetNumberAddressableHosts(); // 510
sub.GetIPAddressRange();         // [ 192.168.112.0, 192.168.113.255 ]
sub.GetNetworkSize();            // 23
sub.GetBroadcastAddress();       // 192.168.113.255
Get IP Address
sub.GetIPAddress();       // 192.168.112.203
sub.GetIPAddressQuads();  // [ 192, 168, 112, 203 ]
sub.GetIPAddressHex();    // C0A870CB
sub.GetIPAddressBinary(); // 11000000101010000111000011001011
Get Subnet Mask
sub.GetSubnetMask();       // 255.255.254.0
sub.GetSubnetMaskQuads();  // [ 255, 255, 254, 0 ]
sub.GetSubnetMaskHex();    // FFFFFE00
sub.GetSubnetMaskBinary(); // 11111111111111111111111000000000
Get Network Portion
sub.GetNetworkPortion();       // 192.168.112.0
sub.GetNetworkPortionQuads();  // [ 192, 168, 112, 0 ]
sub.GetNetworkPortionHex();    // C0A87000
sub.GetNetworkPortionBinary(); // 11000000101010000111000000000000
Get Host Portion
sub.GetHostPortion();       // 0.0.0.203
sub.GetHostPortionQuads();  // [ 0, 0, 0, 203 ]
sub.GetHostPortionHex();    // 000000CB
sub.GetHostPortionBinary(); // 00000000000000000000000011001011

Based On

IPv4 Subnet Calculator ( PHP )

License

IPv4 Subnet Calculator (GO) is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ip

type Ip struct {
	// contains filtered or unexported fields
}

func SubnetCalculator

func SubnetCalculator(ip string, networkSize int) *Ip

func (*Ip) GetBroadcastAddress

func (s *Ip) GetBroadcastAddress() string

func (*Ip) GetHostPortion

func (s *Ip) GetHostPortion() string

func (*Ip) GetHostPortionBinary

func (s *Ip) GetHostPortionBinary() string

func (*Ip) GetHostPortionHex

func (s *Ip) GetHostPortionHex() string

func (*Ip) GetHostPortionQuards

func (s *Ip) GetHostPortionQuards() []int

func (*Ip) GetIPAddress

func (s *Ip) GetIPAddress() string

func (*Ip) GetIPAddressBinary

func (s *Ip) GetIPAddressBinary() string

func (*Ip) GetIPAddressHex

func (s *Ip) GetIPAddressHex() string

func (*Ip) GetIPAddressQuads

func (s *Ip) GetIPAddressQuads() []int

func (*Ip) GetIPAddressRange

func (s *Ip) GetIPAddressRange() []string

func (*Ip) GetNetworkPortion

func (s *Ip) GetNetworkPortion() string

func (*Ip) GetNetworkPortionBinary

func (s *Ip) GetNetworkPortionBinary() string

func (*Ip) GetNetworkPortionHex

func (s *Ip) GetNetworkPortionHex() string

func (*Ip) GetNetworkPortionQuards

func (s *Ip) GetNetworkPortionQuards() []int

func (*Ip) GetNetworkSize

func (s *Ip) GetNetworkSize() int

func (*Ip) GetNumberAddressableHosts

func (s *Ip) GetNumberAddressableHosts() int

func (*Ip) GetNumberIPAddresses

func (s *Ip) GetNumberIPAddresses() int

func (*Ip) GetSubnetMask

func (s *Ip) GetSubnetMask() string

func (*Ip) GetSubnetMaskBinary

func (s *Ip) GetSubnetMaskBinary() string

func (*Ip) GetSubnetMaskHex

func (s *Ip) GetSubnetMaskHex() string

func (*Ip) GetSubnetMaskQuards

func (s *Ip) GetSubnetMaskQuards() []int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL