native

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package native contains the private libubus bridge used by the public module.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupported is returned when native libubus support was not compiled.
	ErrUnsupported = errors.New("native ubus is unavailable")
	// ErrClosed is returned after the native event loop has begun shutting down.
	ErrClosed = errors.New("native ubus engine is closed")
)

Functions

This section is empty.

Types

type Callbacks

type Callbacks interface {
	ConnectionState(connected bool, status int)
	Incoming(Incoming)
	Event(listenerID uint64, name, body string)
	SubscriptionState(subscriptionID uint64, connected bool, targetID uint32, status int)
	SubscribersChanged(publicationID uint64, active bool)
	MonitorRecord(MonitorRecord)
}

Callbacks receives copied native events. Implementations must return quickly and must not run user code on the uloop thread.

type Engine

type Engine interface {
	Close() error
	Lookup(context.Context, string) ([]LookupObject, error)
	Invoke(context.Context, string, string, string, int) (InvokeResult, error)
	AddObject(context.Context, uint64, string, []MethodSpec) error
	RemoveObject(context.Context, uint64) error
	CompleteIncoming(context.Context, uint64, int, string, int) error
	AddEvent(context.Context, uint64, string) error
	RemoveEvent(context.Context, uint64) error
	SendEvent(context.Context, string, string) error
	AddSubscription(context.Context, uint64, string) error
	RemoveSubscription(context.Context, uint64) error
	Notify(context.Context, uint64, string, string, bool) (NotifyReport, error)
	StartMonitor(context.Context) error
	StopMonitor(context.Context) error
}

Engine is the internal, platform-specific native connection.

func Open

func Open(ctx context.Context, options Options, callbacks Callbacks) (Engine, error)

Open creates the Linux cgo engine and waits for its initial ubus connection.

type FieldSpec

type FieldSpec struct {
	Name string
	Type uint8
}

FieldSpec is one native blobmsg policy entry.

type Incoming

type Incoming struct {
	ID      uint64
	OwnerID uint64
	Kind    IncomingKind
	Object  string
	Method  string
	Peer    uint32
	User    string
	Group   string
	ACLObj  string
	JSON    string
	FD      int
}

Incoming is a fully copied request awaiting deferred completion.

type IncomingKind

type IncomingKind uint8

IncomingKind identifies the owner and semantics of an incoming request.

const (
	// IncomingMethod is a call to a published object method.
	IncomingMethod IncomingKind = iota
	// IncomingNotification is a notification delivered to a subscriber.
	IncomingNotification
)

type InvokeResult

type InvokeResult struct {
	JSON string
	FD   int
}

InvokeResult contains copied response JSON and an owned descriptor.

type LookupObject

type LookupObject struct {
	ID        uint32
	TypeID    uint32
	Path      string
	Signature string
}

LookupObject is one copied native lookup result.

type MethodSpec

type MethodSpec struct {
	Name   string
	Fields []FieldSpec
	Tags   uint64
	Mask   uint64
}

MethodSpec is one method registered on a native object.

type MonitorRecord

type MonitorRecord struct {
	Sequence uint32
	Client   uint32
	Peer     uint32
	Send     bool
	Type     uint32
	JSON     string
}

MonitorRecord is one parsed native monitor envelope.

type NotifyReport

type NotifyReport struct {
	Results []NotifyResult
	Replies []string
}

NotifyReport separates attributable statuses from unattributed reply data.

type NotifyResult

type NotifyResult struct {
	Subscriber uint32
	Status     int
}

NotifyResult contains one subscriber's native completion status.

type Options

type Options struct {
	Socket         string
	Reconnect      bool
	ReconnectDelay time.Duration
}

Options controls the native event loop and reconnection behavior.

type StatusError

type StatusError struct {
	Op     string
	Status int
}

StatusError carries a native ubus status from the bridge.

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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