mdns

package
v0.0.0-...-e789601 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2018 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagQR Flags = 32768
	FlagAA       = 1024
	FlagTC       = 512
	FlagRD       = 256
	FlagRA       = 128
	FlagAD       = 32
	FlagCD       = 16

	RCodeNoError  = 0
	RCodeFormErr  = 1
	RCodeServFail = 2
	RCodeNXDomain = 3
	RCodeNotImpl  = 4
	RCodeRefused  = 5
)
View Source
const (
	TypeNone  Type = 0
	TypeA          = 1
	TypeCNAME      = 5
	TypePTR        = 12
	TypeHINFO      = 13
	TypeTXT        = 16
	TypeAAAA       = 28
	TypeSRV        = 33
	TypeOPT        = 41
	TypeAny        = 255
)
View Source
const (
	ClassInet    Class = 1
	ClassNone          = 254
	ClassAny           = 255
	ClassUnicast       = 1 << 15
)

Variables

This section is empty.

Functions

func JoinGroup

func JoinGroup(p *ipv4.PacketConn, msg *syscall.NetlinkMessage, group net.Addr) error

func LeaveGroup

func LeaveGroup(p *ipv4.PacketConn, msg *syscall.NetlinkMessage, group net.Addr) error

func MonitorNetwork

func MonitorNetwork(p *ipv4.PacketConn, group net.Addr) error

func NewClient

func NewClient(addr string) (*net.UDPAddr, *ipv4.PacketConn, error)

func NewConn

func NewConn(addr string) (*net.UDPAddr, *ipv4.PacketConn, error)

func NewServer

func NewServer(addr string) (*net.UDPAddr, *ipv4.PacketConn, error)

func Pack

func Pack(msg *Message) ([]byte, error)

func PackName

func PackName(w io.Writer, name []byte) error

func PackString

func PackString(w io.Writer, str string) error

func PackStruct

func PackStruct(r io.Writer, data interface{}) error

func SendRecursiveRequest

func SendRecursiveRequest(msg *Message, q *Question) uint16

func Serve

func Serve(p *ipv4.PacketConn, maddr *net.UDPAddr, localname string, silent, forward bool)

func UnpackName

func UnpackName(r io.Reader) ([]byte, error)

func UnpackNameAt

func UnpackNameAt(r io.ReaderAt, off int64) ([]byte, error)

func UnpackString

func UnpackString(r io.Reader) (string, error)

func UnpackStruct

func UnpackStruct(r io.Reader, data interface{}) error

func Write

func Write(p *ipv4.PacketConn, addr *net.UDPAddr, msg *Message) error

Types

type A

type A struct {
	Addr net.IP `mdns:"a"`
}

func NewA

func NewA(addr net.IP) *A

func (*A) Len

func (rr *A) Len() uint16

func (*A) String

func (rr *A) String() string

type AAAA

type AAAA struct {
	Addr net.IP `mdns:"aaaa"`
}

func NewAAAA

func NewAAAA(addr net.IP) *AAAA

func (*AAAA) Len

func (rr *AAAA) Len() uint16

func (*AAAA) String

func (rr *AAAA) String() string

type CNAME

type CNAME struct {
	CNAME []byte `mdns:"name"`
}

func NewCNAME

func NewCNAME(cname string) *CNAME

func (*CNAME) Len

func (rr *CNAME) Len() uint16

func (*CNAME) String

func (rr *CNAME) String() string

type Class

type Class uint16

func (Class) String

func (c Class) String() string

type Flags

type Flags uint16

func (Flags) RCode

func (t Flags) RCode() uint8

func (Flags) RCodeString

func (t Flags) RCodeString() string

func (Flags) String

func (t Flags) String() string

type HINFO

type HINFO struct {
	CPU string
	OS  string
}

func NewHINFO

func NewHINFO() *HINFO

func (*HINFO) Len

func (rr *HINFO) Len() uint16

func (*HINFO) String

func (rr *HINFO) String() string
type Header struct {
	Id    uint16
	Flags Flags

	QDCount uint16
	ANCount uint16
	NSCount uint16
	ARCount uint16
}

type Message

type Message struct {
	Header     Header
	Question   []*Question
	Answer     []*Record
	Authority  []*Record
	Additional []*Record
}

func Read

func SendRequest

func SendRequest(req *Message) (*Message, error)

func Unpack

func Unpack(pkt []byte) (*Message, error)

func (*Message) AppendAN

func (msg *Message) AppendAN(an *Record)

func (*Message) AppendQD

func (msg *Message) AppendQD(qd *Question)

func (*Message) String

func (m *Message) String() string

type OPT

type OPT struct {
	Code   uint16
	OptLen uint16
	OPT    []byte `mdns:"opt"`
}

func (*OPT) Len

func (rr *OPT) Len() uint16

func (*OPT) String

func (rr *OPT) String() string

type PTR

type PTR struct {
	PTRNAME []byte `mdns:"name"`
}

func (*PTR) Len

func (rr *PTR) Len() uint16

func (*PTR) String

func (rr *PTR) String() string

type Question

type Question struct {
	Name  []byte `mdns:"name"`
	Type  Type
	Class Class
}

func NewQD

func NewQD(name []byte, t Type, class Class) *Question

type RData

type RData interface {
	Len() uint16
	String() string
}

type Record

type Record struct {
	Name  []byte `mdns:"name"`
	Type  Type
	Class Class
	TTL   uint32
	RDLen uint16
	RData RData `mdns:"rdata"`
}

func NewAN

func NewAN(name []byte, class Class, ttl uint32, rd RData) *Record

type SRV

type SRV struct {
	Priority uint16
	Weight   uint16
	Port     uint16
	Target   []byte `mdns:"name"`
}

func (*SRV) Len

func (rr *SRV) Len() uint16

func (*SRV) String

func (rr *SRV) String() string

type TXT

type TXT struct {
	TXT string
}

func (*TXT) Len

func (rr *TXT) Len() uint16

func (*TXT) String

func (rr *TXT) String() string

type Type

type Type uint16

func (Type) MakeRR

func (t Type) MakeRR() RData

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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