Generated from Manticore v1.1.5 • 201 packages. View on pkg.go.dev

udp

import "github.com/TheManticoreProject/Manticore/network/dcerpc/v4/transport/udp"

Package udp implements the connectionless DCE/RPC datagram transport for the ncadg_ip_udp protocol sequence: RPC PDUs carried directly over UDP, with no intermediate protocol ([MS-RPCE] 2.1.1.1, [C706] Appendix I protocol identifier 0x08).

The transport uses a connected UDP socket (net.DialUDP), so it only sends to and receives from the configured server. UDP preserves message boundaries, so each Send writes one PDU datagram and each Recv returns one PDU datagram. Reliability, fragmentation, and acknowledgement are handled by the protocol machine above this transport, not here.

References:

Index

Constants

DefaultTimeout is the read/write timeout applied to each operation when no explicit deadline has been configured via SetDeadline.

const DefaultTimeout = 10 * time.Second

type Option

Option configures a Transport.

type Option func(*Transport)

func WithMaxPDUSize

func WithMaxPDUSize(n int) Option

WithMaxPDUSize sets the maximum datagram size, in bytes, that Send will transmit. Use transport.MaxPDUSizeLegacy when targeting Windows NT 4.0.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the per-operation read/write timeout. A non-positive duration disables the per-operation timeout, leaving deadline management entirely to SetDeadline.

type Transport

Transport is a connected-UDP implementation of transport.Transport for ncadg_ip_udp.

type Transport struct {
    // contains filtered or unexported fields
}

func New

func New(host string, port int, opts ...Option) *Transport

New returns an unconnected ncadg_ip_udp transport for the given host and UDP port. Call Connect before Send or Recv.

func (*Transport) Close

func (t *Transport) Close() error

Close closes the UDP socket. It is safe to call on an already-closed transport.

func (*Transport) Connect

func (t *Transport) Connect() error

Connect resolves the server address and opens the connected UDP socket. It is a no-op if already connected.

func (*Transport) IsConnected

func (t *Transport) IsConnected() bool

IsConnected reports whether the socket is open.

func (*Transport) MaxPDUSize

func (t *Transport) MaxPDUSize() int

MaxPDUSize returns the maximum datagram size, in bytes, that Send will transmit.

func (*Transport) Recv

func (t *Transport) Recv() ([]byte, error)

Recv reads and returns a single datagram.

func (*Transport) RemoteAddr

func (t *Transport) RemoteAddr() net.Addr

RemoteAddr returns the resolved server address, or nil if not connected.

func (*Transport) Send

func (t *Transport) Send(datagram []byte) (int, error)

Send writes datagram as a single UDP message. A datagram larger than MaxPDUSize is rejected, since fragmentation is the protocol machine’s responsibility.

func (*Transport) SetDeadline

func (t *Transport) SetDeadline(deadline time.Time) error

SetDeadline sets the absolute read/write deadline on the socket. When a per- operation timeout is configured (the default), Send and Recv override the read or write deadline on their next call; set the timeout to zero via WithTimeout to make SetDeadline authoritative.