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

Implements

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.ASN | IPNumType.IPv4 | IPNumType.IPv6 = 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>
  • Parameters

    • ipv4BinaryString: string

    Returns Array<Octet>

Private constructFromBigIntegerValue

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

    • ipv4Number: BigInteger

    Returns [BigInteger, Array<Octet>]

Private constructFromDecimalDottedString

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

    • ipString: string

    Returns [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

hasNext

  • hasNext(): boolean

hasPrevious

  • hasPrevious(): boolean

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
  • Returns this IPv4 number as a IPv4-Mapped IPv6 Address

    The IPv4-Mapped IPv6 Address allows an IPv4 number to be embedded within an IPv6 number

    {@see https://tools.ietf.org/html/rfc4291#section-2.5.5} for more information on the IPv4-Mapped IPv6 Address

    Returns IPv6

    an IPv6 number with the IPv4 embedded within it

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

Generated using TypeDoc