pmc

package
v0.0.0-...-8995d27 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClockClassSyncPrimaryRef = 6
	ClockClassHoldover       = 7
	ClockClassDegradedA      = 52
	ClockClassDegradedB      = 187
	ClockClassDefault        = 248
	ClockClassSlaveOnly      = 255
)
View Source
const OffsetScaledLogVarianceUnknown = 0xffff
View Source
const PTP4LSocketPath = "/var/run/ptp4l"
View Source
const SizeofMgmtMsgPrefix = 52

Variables

This section is empty.

Functions

func GrandmasterSettingsBinaryMsg

func GrandmasterSettingsBinaryMsg(c *MsgPreparer, data GrandmasterSettings) ([]byte, error)

func MgmtSetBinaryMsg

func MgmtSetBinaryMsg[D MgmtData](c *MsgPreparer, data D) ([]byte, error)

Types

type Action

type Action uint8
const (
	ActionGet Action = iota
	ActionSet
	ActionResponse
	ActionCommand
	ActionAcknowledge
)

type BinaryWriterTo

type BinaryWriterTo interface {
	WriteBinaryTo(io.Writer) error
}

type Client

type Client struct {
	MsgPreparer
	T *Transport
}

func NewClient

func NewClient(cfg *ClientConfig) (*Client, error)

func (*Client) Close

func (client *Client) Close() error

func (*Client) Recv

func (client *Client) Recv(seqid uint16) (MgmtMsg, error)

func (*Client) Send

func (client *Client) Send(msg MgmtMsg) (uint16, error)

func (*Client) SendRecv

func (client *Client) SendRecv(msg MgmtMsg) (MgmtMsg, error)

type ClientConfig

type ClientConfig struct {
	RemoteSocketPath      string
	LocalSocketPathFormat string
}

func NewClientConfig

func NewClientConfig() *ClientConfig

func (*ClientConfig) SetDefaults

func (cfg *ClientConfig) SetDefaults()

type ClockAccuracy

type ClockAccuracy uint8
const (
	ClockAccuracyWithin1ps ClockAccuracy = 0x17 + iota
	ClockAccuracyWithin2point5ps
	ClockAccuracyWithin10ps
	ClockAccuracyWithin25ps
	ClockAccuracyWithin100ps
	ClockAccuracyWithin250ps
	ClockAccuracyWithin1ns
	ClockAccuracyWithin2point5ns
	ClockAccuracyWithin10ns
	ClockAccuracyWithin25ns
	ClockAccuracyWithin100ns
	ClockAccuracyWithin250ns
	ClockAccuracyWithin1us
	ClockAccuracyWithin2point5us
	ClockAccuracyWithin10us
	ClockAccuracyWithin25us
	ClockAccuracyWithin100us
	ClockAccuracyWithin250us
	ClockAccuracyWithin1ms
	ClockAccuracyWithin2point5ms
	ClockAccuracyWithin10ms
	ClockAccuracyWithin25ms
	ClockAccuracyWithin100ms
	ClockAccuracyWithin250ms
	ClockAccuracyWithin1s
	ClockAccuracyWithin10s
	ClockAccuracyGreater10s
	ClockAccuracyUnknown = 0xFE
)

func DurationToClockAccuracy

func DurationToClockAccuracy(d time.Duration) ClockAccuracy

DurationToClockAccuracy converts a time.Duration to the appropriate ClockAccuracy value, rounding up to the next available accuracy level. Returns 0 for durations <= 0 or > 10s.

func (ClockAccuracy) Description

func (a ClockAccuracy) Description() string

func (ClockAccuracy) String

func (a ClockAccuracy) String() string

type ClockIdentity

type ClockIdentity [8]byte

func AnyClockIdentity

func AnyClockIdentity() ClockIdentity

type ClockQuality

type ClockQuality struct {
	ClockClass              uint8 // in the PTP standard this is not an enumeration
	ClockAccuracy           ClockAccuracy
	OffsetScaledLogVariance uint16
}

type Control

type Control uint8
const (
	ControlMgmt Control = 0x4
)

type CurrentDS

type CurrentDS struct {
	StepsRemoved     uint16
	OffsetFromMaster TimeInterval
	MeanPathDelay    TimeInterval
}

func (CurrentDS) MgmtID

func (CurrentDS) MgmtID() MgmtID

type DefaultDS

type DefaultDS struct {
	Flags DefaultDSFlags

	NumberPorts   uint16
	Priority1     uint8
	ClockQuality  ClockQuality
	Priority2     uint8
	ClockIdentity ClockIdentity
	DomainNumber  uint8
	// contains filtered or unexported fields
}

func (DefaultDS) MgmtID

func (DefaultDS) MgmtID() MgmtID

func (DefaultDS) SlaveOnly

func (ds DefaultDS) SlaveOnly() bool

func (DefaultDS) TwoStepFlag

func (ds DefaultDS) TwoStepFlag() bool

type DefaultDSFlags

type DefaultDSFlags uint8
const (
	DefaultDSFlagTSC DefaultDSFlags = 1 << iota
	DefaultDSFlagSO
)

type GrandmasterSettings

type GrandmasterSettings struct {
	ClockQuality ClockQuality
	UTCOffset    int16
	TimeFlags    TimeFlags
	TimeSource   TimeSource
}

func (GrandmasterSettings) MgmtID

func (GrandmasterSettings) MgmtID() MgmtID
type Header struct {
	MajorSdoIDMessageType uint8
	Version               uint8
	MessageLength         uint16
	DomainNumber          uint8
	MinorSdoID            uint8
	FlagField             uint16
	CorrectionField       uint64
	MessageTypeSpecific   uint32
	SourcePortIdentity    PortIdentity
	SequenceID            uint16
	ControlField          Control
	LogMessageInterval    uint8
}

func (*Header) SetMajorSdoID

func (h *Header) SetMajorSdoID(id uint8)

func (*Header) SetMessageType

func (h *Header) SetMessageType(mt MessageType)

type MessageType

type MessageType uint8
const (
	MessageTypeMgmt MessageType = 0xD
)

type MgmtData

type MgmtData interface {
	MgmtID() MgmtID
}

type MgmtErrorID

type MgmtErrorID uint16
const (
	MEIDResponseTooBig MgmtErrorID
	MEIDNoSuchID
	MEIDWrongLength
	MEIDWrongValue
	MEIDNotSetable
	MEIDNotSupported
	MEIDUnpopulated
	MEIDGeneralError MgmtErrorID = 0xFFFE
)

func (MgmtErrorID) String

func (meid MgmtErrorID) String() string

type MgmtErrorStatus

type MgmtErrorStatus struct {
	MgmtErrorID MgmtErrorID
	MgmtID      MgmtID

	DisplayData *string
	// contains filtered or unexported fields
}

func (*MgmtErrorStatus) WriteBinaryTo

func (m *MgmtErrorStatus) WriteBinaryTo(w io.Writer) error

type MgmtErrorStatusMsg

type MgmtErrorStatusMsg = MgmtMsgWithValue[MgmtErrorStatus]

func NewMgmtErrorStatusMsg

func NewMgmtErrorStatusMsg(mes MgmtErrorStatus) *MgmtErrorStatusMsg

type MgmtID

type MgmtID uint16
const (
	MIDNullPTPManagement     MgmtID = 0x0000
	MIDDefaultDataSet        MgmtID = 0x2000
	MIDCurrentDataSet        MgmtID = 0x2001
	MIDParentDataSet         MgmtID = 0x2002
	MIDTimePropertiesDataSet MgmtID = 0x2003
	MIDUTCProperties         MgmtID = 0x2011
	MIDGrandmasterSettings   MgmtID = 0xC001 // GRANDMASTER_SETTINGS_NP of LinuxPTP
)

func ParseMID

func ParseMID(s string) (MgmtID, error)

func (MgmtID) String

func (mid MgmtID) String() string

type MgmtMsg

type MgmtMsg interface {
	encoding.BinaryMarshaler
	Prefix() *MgmtMsgPrefix
	Value() any
}

func UnmarshalMgmtMsg

func UnmarshalMgmtMsg(data []byte) (MgmtMsg, error)

type MgmtMsgPrefix

type MgmtMsgPrefix struct {
	Header
	TargetPortIdentity   PortIdentity
	StartingBoundaryHops uint8
	BoundaryHops         uint8
	ActionField          Action

	TLVType   TLVType
	TLVLength uint16
	// contains filtered or unexported fields
}

type MgmtMsgWithValue

type MgmtMsgWithValue[V any] struct {
	MgmtMsgPrefix
	V V
}

func NewMgmtGetMsg

func NewMgmtGetMsg(mid MgmtID) *MgmtMsgWithValue[MgmtID]

func NewMgmtSetMsg

func NewMgmtSetMsg[D MgmtData](data D) *MgmtMsgWithValue[MgmtValue[D]]

func (*MgmtMsgWithValue[V]) MarshalBinary

func (m *MgmtMsgWithValue[V]) MarshalBinary() ([]byte, error)

func (*MgmtMsgWithValue[V]) Prefix

func (m *MgmtMsgWithValue[V]) Prefix() *MgmtMsgPrefix

func (*MgmtMsgWithValue[T]) SetLength

func (m *MgmtMsgWithValue[T]) SetLength(l uint16)

func (*MgmtMsgWithValue[V]) Value

func (m *MgmtMsgWithValue[V]) Value() any

type MgmtValue

type MgmtValue[D MgmtData] struct {
	MgmtID MgmtID
	Data   D
}

type MsgPreparer

type MsgPreparer struct {
	PortNumber   uint16
	DomainNumber uint8
	MajorSdoID   uint8
	MinorSdoID   uint8
	// contains filtered or unexported fields
}

func (*MsgPreparer) AllocSequenceID

func (c *MsgPreparer) AllocSequenceID() uint16

func (*MsgPreparer) PrepareMsg

func (c *MsgPreparer) PrepareMsg(m MgmtMsg)

type NullPTPMgmt

type NullPTPMgmt struct{}

func (NullPTPMgmt) MgmtID

func (NullPTPMgmt) MgmtID() MgmtID

type NullPTPMgmtMsg

type NullPTPMgmtMsg = MgmtMsgWithValue[MgmtValue[NullPTPMgmt]]

type ParentDS

type ParentDS struct {
	ParentPortIdentity PortIdentity
	ParentStats        bool

	ObservedParentOffsetScaledLogVariance uint16
	ObservedParentClockPhaseChangeRate    int32
	GrandmasterPriority1                  uint8
	GrandmasterClockQuality               ClockQuality
	GrandmasterPriority2                  uint8
	GrandmasterIdentity                   ClockIdentity
	// contains filtered or unexported fields
}

func (ParentDS) MgmtID

func (ParentDS) MgmtID() MgmtID

type PortIdentity

type PortIdentity struct {
	ClockIdentity ClockIdentity
	PortNumber    uint16
}

func AnyPortIdentity

func AnyPortIdentity() PortIdentity

type TLVType

type TLVType uint16
const (
	TLVTypeMgmt            TLVType = 0x0001
	TLVTypeMgmtErrorStatus TLVType = 0x0002
)

type TimeFlags

type TimeFlags uint8

Same as high bits of FlagField in the header

const (
	Leap61 TimeFlags = 1 << iota
	Leap59
	CurrentUTCOffsetValid
	PTPTimescale
	TimeTraceable
	FrequencyTraceable
	SynchronizationUncertain
)

type TimeInterval

type TimeInterval int64

func (TimeInterval) Duration

func (ti TimeInterval) Duration() time.Duration

func (TimeInterval) Nanos

func (ti TimeInterval) Nanos() float64

func (TimeInterval) String

func (ti TimeInterval) String() string

type TimePropertiesDS

type TimePropertiesDS struct {
	CurrentUTCOffset int16
	Flags            TimePropertiesDSFlags
	TimeSource       uint8
}

func (TimePropertiesDS) MgmtID

func (TimePropertiesDS) MgmtID() MgmtID

type TimePropertiesDSFlags

type TimePropertiesDSFlags uint8
const (
	TimePropertiesDSFlagLI61 TimePropertiesDSFlags = iota
	TimePropertiesDSFlagLI59
	TimePropertiesDSFlagUTCV
	TimePropertiesDSFlagPTP
	TimePropertiesDSFlagTTRA
	TimePropertiesDSFlagFTRA
)

type TimeSource

type TimeSource uint8
const (
	TimeSourceAtomicClock        TimeSource = 0x10
	TimeSourceGNSS               TimeSource = 0x20
	TimeSourceTerrestrialRadio   TimeSource = 0x30
	TimeSourceSerialTimeCode     TimeSource = 0x39
	TimeSourcePTP                TimeSource = 0x40
	TimeSourceNTP                TimeSource = 0x50
	TimeSourceHandSet            TimeSource = 0x60
	TimeSourceOther              TimeSource = 0x90
	TimeSourceInternalOscillator TimeSource = 0xA0
	TimeSourceReserved           TimeSource = 0xFF
)

func (TimeSource) Description

func (s TimeSource) Description() string

func (TimeSource) String

func (s TimeSource) String() string

type Transport

type Transport struct {
	Conn       net.PacketConn
	RemoteAddr net.Addr
	// contains filtered or unexported fields
}

func NewUnixTransport

func NewUnixTransport(lPath, rPath string) (*Transport, error)

func (*Transport) Cleanup

func (t *Transport) Cleanup() error

This is safe to call from multiple goroutines

type UTCProperties

type UTCProperties struct {
	CurrentUTCOffset int16
	TimeFlags        TimeFlags // Only Leap59, Leap61 and CurrentUTCOffsetValid are valid here
	// contains filtered or unexported fields
}

func (UTCProperties) MgmtID

func (UTCProperties) MgmtID() MgmtID

Jump to

Keyboard shortcuts

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