datalink

package
v0.0.0-...-3b05dbf Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPort = 0xBAC0 //47808

DefaultPort that BacnetIP will use if a port is not given. Valid ports for the bacnet protocol is between 0xBAC0 and 0xBAC9

Variables

This section is empty.

Functions

func FindCIDRAddress

func FindCIDRAddress(inter string) (string, error)

FindCIDRAddress find out CIDR address from net interface

func IPPortToAddress

func IPPortToAddress(ip net.IP, port int) *btypes.Address

IPPortToAddress converts a given udp address into a bacnet address

func UDPToAddress

func UDPToAddress(n *net.UDPAddr) *btypes.Address

UDPToAddress converts a given udp address into a bacnet address

Types

type DataLink interface {
	GetMyAddress() *btypes.Address
	GetBroadcastAddress() *btypes.Address
	Send(data []byte, npdu *btypes.NPDU, dest *btypes.Address) (int, error)
	Receive(data []byte) (*btypes.Address, int, error)
	Close() error
}
func NewPcapDataLink(inter string, port int, timeout time.Duration) (link DataLink, err error)
func NewUDPDataLink(inter string, port int) (link DataLink, err error)

NewUDPDataLink returns udp listener pass in your iface port by name, see an alternative NewUDPDataLinkFromIP if you wish to pass in by ip and subnet

  • inter: eth0
  • addr: 47808

func NewUDPDataLinkFromIP

func NewUDPDataLinkFromIP(addr string, subNet, port int) (link DataLink, err error)

NewUDPDataLinkFromIP returns udp listener

  • addr: 192.168.15.10
  • subNet: 24
  • addr: 47808
type MockDataLink struct {
	// Messages that have been sent with the Send method
	Sent []SentMessage

	// Messages that we are simulating receiving with the Receive method
	Received []ReceivedMessage

	MyAddress        *btypes.Address
	BroadcastAddress *btypes.Address
}
func NewMockDataLink() *MockDataLink

func (*MockDataLink) Close

func (m *MockDataLink) Close() error

func (*MockDataLink) GetBroadcastAddress

func (m *MockDataLink) GetBroadcastAddress() *btypes.Address

func (*MockDataLink) GetMyAddress

func (m *MockDataLink) GetMyAddress() *btypes.Address

func (*MockDataLink) Receive

func (m *MockDataLink) Receive(data []byte) (*btypes.Address, int, error)

func (*MockDataLink) Send

func (m *MockDataLink) Send(data []byte, npdu *btypes.NPDU, dest *btypes.Address) (int, error)

type ReceivedMessage

type ReceivedMessage struct {
	Data  []byte
	Src   *btypes.Address
	Error error
}

type SentMessage

type SentMessage struct {
	Data []byte
	NPDU *btypes.NPDU
	Dest *btypes.Address
}

Jump to

Keyboard shortcuts

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