Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IPv4

Represents an IPv4 number. A 32 bit number that is used to uniquely identify a device that is part of a computer network that uses the internet protocol for communication.

see

https://en.wikipedia.org/wiki/IPv4

see

https://www.rfc-editor.org/info/rfc791

Hierarchy

Index

Constructors

constructor

  • new IPv4(ipValue: string | BigInteger): IPv4
  • Constructor for an IPv4 number.

    Parameters

    • ipValue: string | BigInteger

      value to construct an IPv4 from. The given value can either be numeric or string. If a string is given then it needs to be in dot-decimal notation

    Returns IPv4

Properties

bitSize

bitSize: number = 32

The number of bits needed to represents the value of the IPv4 number

maximumBitSize

maximumBitSize: BigInteger = Validator.THIRTY_TWO_BIT_SIZE

The maximum bit size (i.e. binary value) of the IPv4 number in BigInteger

octets

octets: Array<Octet> = []

An array of Octet's

type

{Array} the octets that makes up the IPv4 number

separator

separator: string = "."

The string character used to separate the individual octets when the IPv4 is rendered as strings

type

{string} The string character used to separate the individual octets when rendered as strings

type

type: IPNumType = IPNumType.IPv4

The type of IP number. Value is one of the values of the IPNumType enum

type

{IPNumType} the type of IP number

value

value: BigInteger

The decimal value represented by the IPv4 number in BigInteger

Methods

Private binaryStringToDecimalOctets

  • binaryStringToDecimalOctets(ipv4BinaryString: string): Array<Octet>

Private constructFromBigIntegerValue

  • constructFromBigIntegerValue(ipv4Number: BigInteger): [BigInteger, Array<Octet>]

Private constructFromDecimalDottedString

  • constructFromDecimalDottedString(ipString: string): [BigInteger, Array<Octet>]

getOctets

  • getOctets(): Array<Octet>
  • Gets the individual Octet that makes up the IPv4 number

    Returns Array<Octet>

    The individual Octet that makes up the IPv4 number

getValue

  • getValue(): BigInteger
  • Gets the numeric value of an IP number as {@link BigInteger}

    Returns BigInteger

    the numeric value of an IP number.

hasNext

  • hasNext(): boolean
  • Checks if an IP number has a value greater than the present value

    Returns boolean

    true, if there is a value greater than the present value. Returns false otherwise.

hasPrevious

  • hasPrevious(): boolean
  • Checks if an IP number has a value lesser than the present value

    Returns boolean

    true, if there is a value lesser than the present value. Returns false otherwise.

isEquals

  • Checks if the given IP number, is equals to the current IP number

    Parameters

    • anotherIPNum: AbstractIPNum

      the other IP number to compare with

    Returns boolean

    true if the given IP number is equals

isGreaterThan

  • Checks if the given IP number is greater than this current IP number

    Parameters

    • anotherIPNum: AbstractIPNum

      the other IP number to compare with

    Returns boolean

    true if the given IP number is greater than this current one. False otherwise.

isGreaterThanOrEquals

  • Checks if the given IP number is greater than or equals to this current IP number

    Parameters

    • anotherIPNum: AbstractIPNum

      the other IP number to compare with

    Returns boolean

    {boolean} true if the given IP number is greater than or equals to this current one. False otherwise.

isLessThan

  • Checks if the given IP number is lesser than this current IP number

    Parameters

    • anotherIPNum: AbstractIPNum

      the other IP number to compare with

    Returns boolean

    true if the given IP number is less than this current one. False otherwise.

isLessThanOrEquals

  • Checks if the given IP number is less than or equals to this current IP number

    Parameters

    • anotherIPNum: AbstractIPNum

      the other IP number to compare with

    Returns boolean

    true if the given IP number is less than or equals to this current one. False otherwise.

nextIPNumber

  • nextIPNumber(): IPv4

previousIPNumber

  • previousIPNumber(): IPv4

toBinaryString

  • toBinaryString(): string

toIPv4MappedIPv6

  • toIPv4MappedIPv6(): IPv6

toString

  • toString(): string
  • A string representation of the IPv4 number. The string representation is in dot-decimal notation

    Returns string

    The string representation in dot-decimal notation

Static fromBigInteger

  • fromBigInteger(bigIntValue: BigInteger): IPv4
  • A convenience method for creating an IPv4 by providing the decimal value of the IP number in BigInteger

    Parameters

    • bigIntValue: BigInteger

      the decimal value of the IP number in BigInteger

    Returns IPv4

    the IPv4 instance

Static fromBinaryString

  • fromBinaryString(ipBinaryString: string): IPv4
  • A convenience method for creating an IPv4 from binary string

    Parameters

    • ipBinaryString: string

      the binary string representing the IPv4 number to be created

    Returns IPv4

    the IPv4 instance

Static fromDecimalDottedString

  • fromDecimalDottedString(ipString: string): IPv4

Static fromString

  • fromString(ipString: string): IPv4
  • Alias for IPv4.fromDecimalDottedString.

    Parameters

    • ipString: string

      the IP number in dot-decimal notation

    Returns IPv4

    the IPv4 instance

Generated using TypeDoc