BACnet.Protocol.HostNPort (bacstack v0.1.0-dev.1)

Copy Markdown View Source

A BACnetHostNPort describes a host address together with a UDP (or equivalent) port number. It is used in several Network Port object properties, most notably:

  • BACnet_IP_Global_Address - the public-side address of a NAT-traversing port
  • FD_BBMD_Address - the BBMD with which a foreign device registers

The host portion is a CHOICE that can be:

  • :none - no address is known / not configured (port should be 0)
  • an IP address (:ip_address, OCTET STRING, typically 4 or 16 octets)
  • a DNS host name (:name, CharacterString)

ASN.1 (ASHRAE 135)

BACnetHostAddress ::= CHOICE {
    none       [0] NULL,
    ip-address [1] OCTET STRING,
    name       [2] CharacterString
}

BACnetHostNPort ::= SEQUENCE {
    host [0] BACnetHostAddress,
    port [1] Unsigned16
}

Summary

Types

The host part of a HostNPort.

t()

A BACnetHostNPort value.

Functions

Encodes a BACnetHostNPort into application tags encoding (list of tags).

Parses a BACnetHostNPort from application tags encoding.

Validates whether the given HostNPort is well-formed.

Types

host()

@type host() :: :none | {:ip_address, :inet.ip_address()} | {:name, String.t()}

The host part of a HostNPort.

  • :none - no address configured
  • {:ip_address, :inet.ip_address()} - raw IP address octets (IPv4 = 4 bytes, IPv6 = 16 bytes)
  • {:name, String.t()} - DNS host name (RFC 1123)

t()

@type t() :: %BACnet.Protocol.HostNPort{host: host(), port: 0..65535}

A BACnetHostNPort value.

Functions

encode(hnp, opts \\ [])

@spec encode(t(), Keyword.t()) ::
  {:ok, BACnet.Protocol.ApplicationTags.encoding_list()} | {:error, term()}

Encodes a BACnetHostNPort into application tags encoding (list of tags).

parse(tags)

Parses a BACnetHostNPort from application tags encoding.

Zero length hostnames ({:name, _}) will automatically be rewritten to :none. Some BACnet devices use invalid zero length hostnames instead of using :none, so we allow communication with those by changing them to :none. You can disable this behaviour by setting the application env :bacstack, :hostnport_disable_host_zero_rewrite to true

valid?(host_n_port)

@spec valid?(t()) :: boolean()

Validates whether the given HostNPort is well-formed.