multicast

package
v0.0.0-...-20ce06a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package multicast is a library for sending and receiving multicast traffic, as well as joining, leaving, and querying multicast groups.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeChecksum

func ComputeChecksum(buf []byte) uint16

ComputeChecksum returns the 16bit 1's compliment for the given byte slice

func ComputeChecksumBytes

func ComputeChecksumBytes(buf []byte) (byte, byte)

ComputeChecksumBytes returns the 16bit checksum split into high and low bytes for a given byte slice.

func GetInterface

func GetInterface(interfaceName string) (*net.Interface, error)

GetInterface returns the interface associated with the name provided. It wraps the net.InterfaceByName only adding functionality to allow the specified interface to be an empty string. This helps with command line processing where the default value is an empty string.

func IP4ToInt

func IP4ToInt(ip net.IP) uint32

IP4ToInt returns a 32bit integer representation for a given ipv4 address.

func IPList

func IPList(network string, mask int) ([]net.IP, error)

IPList will return a slice of net.IP addresses for the given ip and mask. The returned slice will be based on the network that the provided ip falls in and not necessarily the exact ip given. The returned slice will also include both the network address and the broadcast address as the first and last items of the slice.

func IPListCIDR

func IPListCIDR(address string) ([]net.IP, error)

IPListCIDR is a convenience function combining SplitCIDR and IPList. It takes an address in CIDR format and returns a slice of IPs within that range.

func IntToIP4

func IntToIP4(ipInt uint32) net.IP

IntToIP4 returns a net.IP for a given 32bit integer representing an ip address.

func Join

func Join(joinIPString string, joinPort int, interfaceName string) error

Join will use the system built in IGMP group join mechanisms to join a group. You may not see any IGMP requests sent if the system isn't ready to send them (group is currently joined, and timers are good). Join does not explicitly send a leave request.

func JoinRaw

func JoinRaw(address string, port int, interfaceName string, interval int, routerAlert bool, igmpVersion int) error

func Receive

func Receive(address string, port int, interfaceName string, showData bool) error

Receive will listen on the port and addresses provided for incoming UDP messages. Uponn receipt of a UDP message, a message will be printed to the console. If showData is true, the data contained in that message will also be printed with the assumption that the data is a string. address can be in CIDR notation, in which case all of the addresses falling within that network will be listened on

func SplitCIDR

func SplitCIDR(address string) (string, int, error)

SplitCIDR returns the ip, or network portion and the mask as 2 separate values for a given address.

Types

type ManySender

type ManySender struct {
	Addresses      *[]net.IP
	Port           int
	TTL            int
	MessagePadding int
	TOS            int
	LocalAddress   *net.UDPAddr
}

func NewManySender

func NewManySender(network string, mask int, port int, ttl int) (*ManySender, error)

func (*ManySender) SetLocalAddress

func (m *ManySender) SetLocalAddress(address string) error

func (*ManySender) SetMessagePadding

func (m *ManySender) SetMessagePadding(paddingSize int)

func (*ManySender) SetTOS

func (m *ManySender) SetTOS(tos int)

func (*ManySender) Start

func (m *ManySender) Start(message string, interval int, startValue int, numberOfMessages int)

type Packet

type Packet struct {
	TTL          int
	Port         int
	Address      net.IP
	RouterAlert  bool
	Raw          bool
	IGMPVersion  int // 1, 2, or 3
	Interface    *net.Interface
	Message      []byte
	Protocol     string // 'udp' or 'ip:2'/'ip4:2'
	LocalAddress *net.UDPAddr

	TOS int
	// contains filtered or unexported fields
}

func NewPacket

func NewPacket() *Packet

func (*Packet) AddressAndPort

func (p *Packet) AddressAndPort() string

func (*Packet) Close

func (p *Packet) Close() error

func (*Packet) ConnectRaw

func (p *Packet) ConnectRaw() error

func (*Packet) ConnectUDP

func (p *Packet) ConnectUDP() error

func (*Packet) Send

func (p *Packet) Send() error

func (*Packet) SendRaw

func (p *Packet) SendRaw() error

func (*Packet) SendUDP

func (p *Packet) SendUDP() error

func (*Packet) SetAddress

func (p *Packet) SetAddress(address string)

func (*Packet) SetMessageText

func (p *Packet) SetMessageText(message string)

type Sender

type Sender struct {
	Packet
}

func NewSender

func NewSender(address string, port int, ttl int) *Sender

func (*Sender) Forever

func (s *Sender) Forever(message string, interval int, startValue int) error

func (*Sender) Max

func (s *Sender) Max(message string, interval int, startValue int, numberOfMessages int) error

func (*Sender) One

func (s *Sender) One(message string) error

func (*Sender) SetLocalAddress

func (s *Sender) SetLocalAddress(address string) error

func (*Sender) SetMessagePadding

func (s *Sender) SetMessagePadding(paddingSize int)

func (*Sender) SetTOS

func (s *Sender) SetTOS(tos int)

Jump to

Keyboard shortcuts

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