runtimehost

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IMSRegisterResponseActionNone means the status does not imply local registration recovery.
	IMSRegisterResponseActionNone = "none"

	// IMSRegisterResponseActionReauthenticate means the UE should obtain a fresh digest challenge.
	IMSRegisterResponseActionReauthenticate = "reauthenticate"

	// IMSRegisterResponseActionRefreshIdentity means local IMS identity material should be refreshed before retrying.
	IMSRegisterResponseActionRefreshIdentity = "refresh_identity"

	// IMSRegisterResponseActionRetryWithMinExpires means the UE should honor Min-Expires and retry.
	IMSRegisterResponseActionRetryWithMinExpires = "retry_with_min_expires"

	// IMSRegisterResponseActionBackoffRetry means the UE should retry registration conservatively after delay/backoff.
	IMSRegisterResponseActionBackoffRetry = "backoff_retry"

	// IMSRegisterResponseActionRefreshSecurity means the UE should rebuild Security-Agree state before retrying.
	IMSRegisterResponseActionRefreshSecurity = "refresh_security"
)
View Source
const (
	SIMAccessRecoveryOperationISIMIdentity = "isim_identity"
	SIMAccessRecoveryOperationIMEI         = "imei"
)
View Source
const StartModeMain = "main"

Variables

View Source
var ErrAPDUBusy = errors.New("apdu busy")

Functions

func NewTraceID

func NewTraceID() string

func SafeDiagnosticError

func SafeDiagnosticError(err error) string

SafeDiagnosticError returns a redacted error string for logs, UI, and structured runtime status. It returns an empty string when err is nil.

func SafeDiagnosticString

func SafeDiagnosticString(value string) string

SafeDiagnosticString redacts subscriber identifiers, AKA/digest material, IPs, MACs, and local paths from free-form runtime diagnostic text.

func SetLogger

func SetLogger(any)

func WithTraceID

func WithTraceID(ctx context.Context, traceID string) context.Context

Types

type APDUAccess

type APDUAccess interface {
	ExecuteATSilent(cmd string, timeout time.Duration) (string, error)
	OpenLogicalChannel(aid string) (int, error)
	CloseLogicalChannel(channel int) error
	TransmitAPDU(channel int, hexAPDU string) (string, error)
}

type CRSMAccess

type CRSMAccess interface {
	ReadCRSMBinary(fileID uint16, offset, length int, pathID string) (simtransport.CRSMResult, error)
	ReadCRSMRecord(fileID uint16, record, length int, pathID string) (simtransport.CRSMResult, error)
}

type DataplanePolicy

type DataplanePolicy struct {
	Mode                 string
	TUNName              string
	TUNMTU               int
	DisableTUNRouting    bool
	TUNAddresses         []string
	TUNEPDGExclusions    []swu.EPDGRouteExclusion
	TUNRoutes            []swu.TUNRoute
	TUNRules             []swu.TUNRule
	TunnelManager        swu.TunnelManager
	TunnelManagerFactory TunnelManagerFactory
}

type DiagnosticIMSRegisterResponseDecision

type DiagnosticIMSRegisterResponseDecision struct {
	StatusCode      int
	Action          string
	Recoverable     bool
	Retry           bool
	Reauthenticate  bool
	RefreshIdentity bool
	RefreshSecurity bool
	Backoff         bool
	RetryAfter      time.Duration
	Reason          string
	Redacted        bool
}

DiagnosticIMSRegisterResponseDecision is a redacted view of an IMS REGISTER recovery decision. It is suitable for logs/UI because it carries the operational recovery action without exposing SIP identities or auth material from the response reason.

func SafeDiagnosticIMSRegisterResponseDecision

func SafeDiagnosticIMSRegisterResponseDecision(decision IMSRegisterResponseDecision, reason string) DiagnosticIMSRegisterResponseDecision

SafeDiagnosticIMSRegisterResponseDecision returns a diagnostic view of an IMS REGISTER recovery decision with optional response reason text redacted.

type DiagnosticIMSRegistrationRecoveryState

type DiagnosticIMSRegistrationRecoveryState struct {
	Attempts            int
	ConsecutiveFailures int
	LastReason          string
	LastError           string
	LastAttemptAt       time.Time
	LastSucceededAt     time.Time
	NextAttemptAt       time.Time
	LastSwitchedTarget  bool
	Redacted            bool
}

DiagnosticIMSRegistrationRecoveryState is a redacted view of ongoing IMS registration recovery bookkeeping. It preserves retry counters and timestamps while removing sensitive text from the last reason/error fields.

func SafeDiagnosticIMSRegistrationRecoveryState

func SafeDiagnosticIMSRegistrationRecoveryState(state IMSRegistrationRecoveryState) DiagnosticIMSRegistrationRecoveryState

SafeDiagnosticIMSRegistrationRecoveryState returns a diagnostic view of IMS registration recovery state with sensitive reason/error text redacted.

type DiagnosticIMSRegistrationResult

type DiagnosticIMSRegistrationResult struct {
	Registered          bool
	StatusCode          int
	Reason              string
	Server              string
	RegisteredAt        time.Time
	ExpiresAt           time.Time
	RefreshDelay        time.Duration
	NextRefreshAt       time.Time
	RecoveryState       DiagnosticIMSRegistrationRecoveryState
	VoiceTransportReady bool
	SMSTransportReady   bool
	USSDTransportReady  bool
	Redacted            bool
}

DiagnosticIMSRegistrationResult is a redacted view of an IMS registration result for support surfaces. It deliberately omits Profile and Binding, which can contain IMS identities, Contact URIs, security material, and route state.

func SafeDiagnosticIMSRegistrationResult

func SafeDiagnosticIMSRegistrationResult(result IMSRegistrationResult) DiagnosticIMSRegistrationResult

SafeDiagnosticIMSRegistrationResult returns a diagnostic summary of IMS registration without exposing raw IMS profile, binding, or SIP route data.

type DiagnosticState

type DiagnosticState struct {
	DeviceID                 string
	Phase                    Phase
	DataplaneMode            string
	SIMReady                 bool
	AccessReady              bool
	TunnelReady              bool
	IMSReady                 bool
	SMSReady                 bool
	RegStatus                int
	RegStatusText            string
	NetworkMode              string
	LastErrorClass           string
	LastError                string
	LastReason               string
	IMSRecoveryPending       bool
	IMSRecoveryRetryAfter    time.Duration
	IMSRecoveryNextAttemptAt time.Time
	IMSRecoveryReason        string
	UpdatedAt                time.Time
	Redacted                 bool
}

DiagnosticState is a redacted runtime state view intended for logs, UI state, and support diagnostics. It preserves operational state while removing common subscriber identifiers, AKA/digest material, IPs, MACs, and local paths.

func SafeDiagnosticState

func SafeDiagnosticState(state State) DiagnosticState

SafeDiagnosticState returns a diagnostic view of state with sensitive text fields redacted. It does not mutate the input State.

type Event

type Event struct {
	State State
}

type EventDispatcher

type EventDispatcher = eventhost.Dispatcher

type EventLocalNumberLearned

type EventLocalNumberLearned = eventhost.LocalNumberLearned

type EventLogNotify

type EventLogNotify = eventhost.LogNotify

type EventRuntimeStateSnapshot

type EventRuntimeStateSnapshot = eventhost.RuntimeStateSnapshot

type EventSMSReceived

type EventSMSReceived = eventhost.SMSReceived

type EventSMSSent

type EventSMSSent = eventhost.SMSSent

type EventUSSDUpdated

type EventUSSDUpdated = eventhost.USSDUpdated

type IMSMessagingRetryWorkerConfig

type IMSMessagingRetryWorkerConfig struct {
	Enabled    bool
	Interval   time.Duration
	BatchLimit int
}

type IMSRegisterResponseDecision

type IMSRegisterResponseDecision struct {
	StatusCode      int
	Action          string
	Recoverable     bool
	Retry           bool
	Reauthenticate  bool
	RefreshIdentity bool
	RefreshSecurity bool
	Backoff         bool
	RetryAfter      time.Duration
}

IMSRegisterResponseDecision is a local recovery hint for a SIP REGISTER response.

func ClassifyIMSRegisterResponse

func ClassifyIMSRegisterResponse(statusCode int, retryAfter time.Duration) IMSRegisterResponseDecision

ClassifyIMSRegisterResponse maps SIP REGISTER status codes to conservative local recovery hints.

type IMSRegistrar

type IMSRegistrar interface {
	RegisterIMS(context.Context, IMSRegistrationConfig) (IMSRegistrationResult, error)
}

type IMSRegistrationConfig

type IMSRegistrationConfig struct {
	DeviceID    string
	TraceID     string
	Profile     identity.Profile
	Prepared    *identity.PreparedSession
	SIM         SIMAdapter
	Access      ModemAccess
	NetworkMode string
	Dataplane   DataplanePolicy
	Tunnel      swu.TunnelResult
	Proxy       *ProxyConfig
}

type IMSRegistrationRecoveryState

type IMSRegistrationRecoveryState struct {
	Attempts            int
	ConsecutiveFailures int
	LastReason          string
	LastError           string
	LastAttemptAt       time.Time
	LastSucceededAt     time.Time
	NextAttemptAt       time.Time
	LastSwitchedTarget  bool
}

type IMSRegistrationResult

type IMSRegistrationResult struct {
	Registered     bool
	StatusCode     int
	Reason         string
	Server         string
	Profile        voiceclient.IMSProfile
	Binding        voiceclient.RegistrationBinding
	RegisteredAt   time.Time
	ExpiresAt      time.Time
	RefreshDelay   time.Duration
	NextRefreshAt  time.Time
	RecoveryState  IMSRegistrationRecoveryState
	VoiceTransport voiceclient.SIPRequestTransport
	SMSTransport   messaging.SMSTransport
	USSDTransport  messaging.USSDTransport
	Close          func(context.Context) error
	Recover        func(context.Context) (IMSRegistrationResult, error)
}

type IdentityReader

type IdentityReader interface {
	GetISIMIdentity() (identity.Identity, error)
}

type Instance

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

func Start

func Start(ctx context.Context, req StartRequest) (*Instance, error)

func (*Instance) AddObserver

func (i *Instance) AddObserver(o Observer)

func (*Instance) CancelVoiceCall

func (i *Instance) CancelVoiceCall(ctx context.Context, info voicehost.DialogInfo) error

func (*Instance) CancelVoiceCallWithResult

func (i *Instance) CancelVoiceCallWithResult(ctx context.Context, info voicehost.DialogInfo) (voicehost.DialogInfoResult, error)

func (*Instance) DiagnosticState

func (i *Instance) DiagnosticState() DiagnosticState

func (*Instance) DrainIMSMessagingRetries

func (i *Instance) DrainIMSMessagingRetries(ctx context.Context, now time.Time, limit int) ([]messaging.IMSMessagingRetryReplayResult, error)

func (*Instance) EndVoiceCall

func (i *Instance) EndVoiceCall(ctx context.Context, info voicehost.DialogInfo) error

func (*Instance) EndVoiceCallWithResult

func (i *Instance) EndVoiceCallWithResult(ctx context.Context, info voicehost.DialogInfo) (voicehost.DialogInfoResult, error)

func (*Instance) GetSMSDeliveryStatus

func (i *Instance) GetSMSDeliveryStatus(messageID string) (*messaging.DeliveryStatus, error)

func (*Instance) HandleIMSBye

func (*Instance) HandleIMSInfo

func (*Instance) HandleIMSMessage

func (*Instance) HandleIncomingSMS

func (i *Instance) HandleIncomingSMS(ctx context.Context, msg messaging.IncomingSMS) error

func (*Instance) HandleSMSDeliveryReport

func (i *Instance) HandleSMSDeliveryReport(ctx context.Context, report messaging.SMSDeliveryReport) (messaging.DeliveryPartMatch, error)

func (*Instance) Obs

func (i *Instance) Obs() map[string]interface{}

func (*Instance) SendDialogAutoDTMF

func (*Instance) SendDialogDTMF

func (*Instance) SendDialogHold

func (*Instance) SendDialogInfo

func (*Instance) SendDialogMessage

func (*Instance) SendDialogNotify

func (*Instance) SendDialogOptions

func (*Instance) SendDialogPrack

func (*Instance) SendDialogRefer

func (*Instance) SendDialogResume

func (*Instance) SendDialogUpdate

func (*Instance) SendSMSWithOptions

func (i *Instance) SendSMSWithOptions(ctx context.Context, to, text string, opts messaging.SendOptions) (messaging.SendOutcome, error)

func (*Instance) Service

func (i *Instance) Service() *messaging.Service

func (*Instance) SetNotifier

func (i *Instance) SetNotifier(fn func(string))

func (*Instance) SetSMSNotifier

func (i *Instance) SetSMSNotifier(fn func(deviceID, sender, content string, ts time.Time))

func (*Instance) StartOutboundCall

func (*Instance) State

func (i *Instance) State() State

func (*Instance) Status

func (i *Instance) Status() string

func (*Instance) Stop

func (i *Instance) Stop(ctx context.Context) error

func (*Instance) TriggerMOBIKE

func (i *Instance) TriggerMOBIKE(oldIP, newIP string) error

type Modem

type Modem interface {
	DeviceID() string
	IsHealthy() bool
	IsSimInserted() bool
	QuerySIMInserted() (bool, error)
	GetRegStatus() (int, string)
	GetNetworkMode() string
	Stop()
}

type ModemAccess

type ModemAccess interface {
	GetISIMIdentity() (identity.Identity, error)
	RuntimeModem() Modem
}

func NewModemAccessAdapter

func NewModemAccessAdapter(m Modem) ModemAccess

func NewModemAccessAdapterWithRecovery

func NewModemAccessAdapterWithRecovery(m Modem, recovery SIMAccessRecoveryOptions) ModemAccess

type ModuleEvent

type ModuleEvent = eventhost.Event

type Observer

type Observer interface {
	OnRuntimeEvent(context.Context, Event)
}

type ObserverFunc

type ObserverFunc func(context.Context, Event)

func (ObserverFunc) OnRuntimeEvent

func (f ObserverFunc) OnRuntimeEvent(ctx context.Context, ev Event)

type Phase

type Phase string
const (
	PhaseStarting Phase = "starting"
	PhaseSIMReady Phase = "sim_ready"
	PhaseReady    Phase = "ready"
	PhaseStopped  Phase = "stopped"
	PhaseError    Phase = "error"
)

type PrepareStartInput

type PrepareStartInput = identity.PrepareStartInput

type ProxyConfig

type ProxyConfig struct {
	ID       string
	URL      string
	Address  string
	Addr     string
	Username string
	Password string
	Country  string
	Enabled  bool
}

type SIMAccessRecoveryHook

type SIMAccessRecoveryHook interface {
	RecoverSIMAccess(req SIMAccessRecoveryRequest) error
}

type SIMAccessRecoveryOptions

type SIMAccessRecoveryOptions struct {
	AllowVendorSpecific bool
	ControlPortType     string
	DryRun              bool
	Delay               simtransport.ATRecoveryDelayFunc
}

type SIMAccessRecoveryRequest

type SIMAccessRecoveryRequest struct {
	Operation          string
	Attempt            int
	Class              simtransport.RecoveryClass
	Err                error
	Decision           simtransport.ControlPortRecoveryDecision
	DestructiveAllowed bool
}

type SIMAdapter

type SIMAdapter interface {
	GetIMSI() (string, error)
	CalculateAKA(rand16, autn16 []byte) (swusim.AKAResult, error)
	Close() error
}

func NewReaderSIMAdapter

func NewReaderSIMAdapter(provider swusim.AKAProvider) SIMAdapter

type SessionConfig

type SessionConfig struct {
	DeviceID      string
	TraceID       string
	Profile       identity.Profile
	Prepared      *identity.PreparedSession
	DataplaneMode string
	Proxy         *ProxyConfig
}

type StartRequest

type StartRequest struct {
	Mode                       string
	DeviceID                   string
	TraceID                    string
	Profile                    identity.Profile
	Prepared                   *identity.PreparedSession
	NetworkMode                string
	VoiceGateway               *voicehost.Gateway
	SIM                        SIMAdapter
	Access                     ModemAccess
	Dataplane                  DataplanePolicy
	Proxy                      *ProxyConfig
	EAPReauthentication        swu.EAPReauthenticationState
	OnEAPReauthenticationState func(swu.EAPReauthenticationState)
	TunnelManager              swu.TunnelManager
	TunnelManagerFactory       TunnelManagerFactory
	IMSRegistrar               IMSRegistrar
	VoiceTransport             voiceclient.SIPRequestTransport
	VoiceUserAgent             string
	VoiceSessionExpires        int
	VoiceMediaRelay            *voicehost.RTPRelayConfig
	SMSTransport               messaging.SMSTransport
	USSDTransport              messaging.USSDTransport
	DeliveryStore              messaging.DeliveryStore
	IMSMessagingRetryWorker    IMSMessagingRetryWorkerConfig
	Dispatch                   eventhost.Dispatcher
	BeforeStart                func(context.Context, SessionConfig) error
	ShouldRun                  func() bool
}

type State

type State struct {
	DeviceID                 string
	Phase                    Phase
	DataplaneMode            string
	SIMReady                 bool
	AccessReady              bool
	TunnelReady              bool
	IMSReady                 bool
	SMSReady                 bool
	RegStatus                int
	RegStatusText            string
	NetworkMode              string
	LastErrorClass           string
	LastError                string
	LastReason               string
	IMSRecoveryPending       bool
	IMSRecoveryRetryAfter    time.Duration
	IMSRecoveryNextAttemptAt time.Time
	IMSRecoveryReason        string
	UpdatedAt                time.Time
}

type TunnelManagerFactory

type TunnelManagerFactory func(StartRequest) (swu.TunnelManager, error)

type WireIMSRegistrar

type WireIMSRegistrar struct {
	Transport              voiceclient.SIPRegisterTransport
	TransportFactory       IMSRegisterTransportFactory
	VoiceTransport         voiceclient.SIPRequestTransport
	VoiceFactory           IMSVoiceTransportFactory
	SMSTransport           messaging.SMSTransport
	SMSFactory             IMSSMSTransportFactory
	USSDTransport          messaging.USSDTransport
	USSDFactory            IMSUSSDTransportFactory
	RegistrarURI           string
	ContactURI             string
	ContactHost            string
	ContactPort            int
	Network                string
	ServerAddr             string
	LocalAddr              string
	Resolver               voiceclient.SIPServerResolver
	Timeout                time.Duration
	Expires                int
	DisableRefresh         bool
	RefreshInterval        time.Duration
	RefreshLead            time.Duration
	RefreshRetryInterval   time.Duration
	RecoveryBackoffInitial time.Duration
	RecoveryBackoffMax     time.Duration
	DisableKeepalive       bool
	KeepaliveInterval      time.Duration
	UserAgent              string
	CallID                 string
	CNonce                 string
	RetransmitInterval     time.Duration
	MaxRetransmitInterval  time.Duration
	MaxRetransmits         int
	SecurityPlanInstaller  voiceclient.SecurityPlanInstaller
}

func (WireIMSRegistrar) RegisterIMS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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