datalink

package
v0.0.0-...-af9153e Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: GPL-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

	// Received is delivered by Receive immediately. Inject holds replies until Send.
	Received []ReceivedMessage

	MyAddress        *btypes.Address
	BroadcastAddress *btypes.Address
	// contains filtered or unexported fields
}
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) Inject

func (m *MockDataLink) Inject(msgs ...ReceivedMessage)

Inject queues replies. They are delivered on the next Send, after the request exists.

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