interop

package
v3.17.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// LoRaAllianceJoinEUIDomain is the LoRa Alliance domain used for JoinEUI resolution.
	LoRaAllianceJoinEUIDomain = "joineuis." + loRaAllianceDomain

	// LoRaAllianceNetIDDomain is the LoRa Alliance domain used for NetID resolution.
	LoRaAllianceNetIDDomain = "netids." + loRaAllianceDomain
)
View Source
const (
	// InteropClientConfigurationName represents the filename of interop client configuration.
	InteropClientConfigurationName = "config.yml"
	// SenderClientCAsConfigurationName represents the filename of sender client CAs configuration.
	SenderClientCAsConfigurationName = "config.yml"
)
View Source
const (
	// ProtocolV1_0 is LoRaWAN Backend Interfaces (TS002) 1.0.
	ProtocolV1_0 = "1.0"
	// ProtocolV1_1 is LoRaWAN Backend Interfaces (TS002) 1.1.x.
	ProtocolV1_1 = "1.1"
)

Variables

View Source
var (
	ErrNoAction           = errors.DefineAborted("no_action", "no action")
	ErrMIC                = errors.DefineInvalidArgument("mic", "MIC failed")
	ErrFrameReplayed      = errors.DefineAborted("frame_replayed", "frame replayed")
	ErrJoinReq            = errors.DefineAborted("join_req", "join-request failed")
	ErrNoRoamingAgreement = errors.DefineFailedPrecondition("no_roaming_agreement", "no roaming agreement")
	ErrDeviceRoaming      = errors.DefineFailedPrecondition("device_roaming", "device roaming disallowed")
	ErrRoamingActivation  = errors.DefineFailedPrecondition("roaming_activation", "roaming activation disallowed")
	ErrActivation         = errors.DefineFailedPrecondition("activation", "activation disallowed")
	ErrUnknownDevEUI      = errors.DefineNotFound("unknown_dev_eui", "unknown DevEUI")
	ErrUnknownDevAddr     = errors.DefineNotFound("unknown_dev_addr", "unknown DevAddr")
	ErrUnknownSender      = errors.DefineNotFound("unknown_sender", "unknown sender")
	ErrUnknownReceiver    = errors.DefineNotFound("unknown_receiver", "unknown receiver")
	ErrDeferred           = errors.DefineAborted("deferred", "deferred")
	ErrTransmitFailed     = errors.DefineAborted("transmit_failed", "transmit failed")
	ErrFPort              = errors.DefineInvalidArgument("f_port", "invalid FPort")
	ErrProtocolVersion    = errors.DefineInvalidArgument("protocol_version", "invalid protocol version")
	ErrStaleDeviceProfile = errors.DefineFailedPrecondition("stale_device_profile", "stale device profile")
	ErrMalformedMessage   = errors.DefineInvalidArgument("malformed_message", "malformed message")
	ErrFrameSize          = errors.DefineInvalidArgument("frame_size", "frame size error")
)

Functions

func GeneratedSessionKeyID

func GeneratedSessionKeyID(id []byte) bool

GeneratedSessionKeyID returns whether the session key ID is generated locally and not by the Join Server.

func JoinServerFQDN

func JoinServerFQDN(eui types.EUI64, domain string) string

JoinServerFQDN constructs Join Server FQDN using specified EUI under domain according to LoRaWAN Backend Interfaces specification. If domain is empty, LoRaAllianceJoinEUIDomain is used.

func NewContextWithApplicationServerAuthInfo added in v3.15.2

func NewContextWithApplicationServerAuthInfo(parent context.Context, authInfo *ApplicationServerAuthInfo) context.Context

NewContextWithApplicationServerAuthInfo returns a derived context with the given authentication information of the Application Server.

func NewContextWithNetworkServerAuthInfo added in v3.15.2

func NewContextWithNetworkServerAuthInfo(parent context.Context, authInfo *NetworkServerAuthInfo) context.Context

NewContextWithNetworkServerAuthInfo returns a derived context with the given authentication information of the Network Server.

Types

type AppSKeyAns

type AppSKeyAns struct {
	JsAsMessageHeader
	Result       Result
	DevEUI       EUI64
	AppSKey      KeyEnvelope
	SessionKeyID Buffer
}

AppSKeyAns is an answer to an AppSKeyReq message.

type AppSKeyReq

type AppSKeyReq struct {
	AsJsMessageHeader
	DevEUI       EUI64
	SessionKeyID Buffer
}

AppSKeyReq is a AppSKey request message.

type ApplicationServerAuthInfo added in v3.15.2

type ApplicationServerAuthInfo struct {
	ASID      string
	Addresses []string
}

ApplicationServerAuthInfo contains the authentication information of an Application Server.

func ApplicationServerAuthInfoFromContext added in v3.15.2

func ApplicationServerAuthInfoFromContext(ctx context.Context) (*ApplicationServerAuthInfo, bool)

ApplicationServerAuthInfoFromContext returns the authentication information of the Application Server from context.

type AsJsMessageHeader

type AsJsMessageHeader struct {
	MessageHeader
	SenderID string
	// ReceiverID is a JoinEUI.
	ReceiverID EUI64
}

AsJsMessageHeader contains the message header for AS to JS messages.

type AsMessageHeader added in v3.15.2

type AsMessageHeader struct {
	MessageHeader
}

AsMessageHeader contains the message header for AS messages.

type Authorizer added in v3.15.2

type Authorizer struct{}

Authorizer authorizes requests handled by the interop server.

func (Authorizer) RequireASID added in v3.15.2

func (a Authorizer) RequireASID(ctx context.Context, id string) error

RequireID returns an error if the given AS-ID is not authorized in the context.

func (Authorizer) RequireAddress added in v3.15.2

func (a Authorizer) RequireAddress(ctx context.Context, addr string) error

RequireAddress returns an error if the given address is not authorized in the context.

func (Authorizer) RequireAuthorized added in v3.15.2

func (a Authorizer) RequireAuthorized(ctx context.Context) error

RequireAuthorized returns an error if the given context is not authorized as neither Network Server nor Application Server.

func (Authorizer) RequireNetID added in v3.15.2

func (a Authorizer) RequireNetID(ctx context.Context, netID types.NetID) error

RequireID returns an error if the given NetID is not authorized in the context.

type Buffer

type Buffer []byte

Buffer is a binary buffer that is represented as hexadecimal in text.

func (Buffer) MarshalText added in v3.15.2

func (b Buffer) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Buffer) UnmarshalText added in v3.15.2

func (b *Buffer) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Client

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

func NewClient

func NewClient(ctx context.Context, conf config.InteropClient, httpClientProvider httpclient.Provider) (*Client, error)

NewClient return new interop client.

func (Client) GetAppSKey

func (cl Client) GetAppSKey(ctx context.Context, asID string, req *ttnpb.SessionKeyRequest) (*ttnpb.AppSKeyResponse, error)

GetAppSKey performs AppSKey request to Join Server associated with req.JoinEUI.

func (Client) HandleJoinRequest

func (cl Client) HandleJoinRequest(ctx context.Context, netID types.NetID, req *ttnpb.JoinRequest) (*ttnpb.JoinResponse, error)

HandleJoinRequest performs Join request to Join Server associated with req.JoinEUI.

type Component added in v3.12.0

type Component interface {
	httpclient.Provider
	Context() context.Context
	RateLimiter() ratelimit.Interface
}

Component represents the Component to the Interop Server.

type DevAddr

type DevAddr types.DevAddr

DevAddr is a LoRaWAN DevAddr.

func (DevAddr) MarshalText added in v3.15.2

func (n DevAddr) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*DevAddr) UnmarshalText added in v3.15.2

func (n *DevAddr) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type EUI64

type EUI64 types.EUI64

EUI64 is an 64-bit EUI, e.g. a DevEUI or JoinEUI.

func (EUI64) MarshalText added in v3.15.2

func (n EUI64) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*EUI64) UnmarshalText added in v3.15.2

func (n *EUI64) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type ErrorMessage

type ErrorMessage struct {
	MessageHeader
	Result Result
}

ErrorMessage is a message with raw header and a result field.

type HomeNSAns

type HomeNSAns struct {
	JsNsMessageHeader
	Result Result
	HNSID  *EUI64 `json:",omitempty"`
	HNetID NetID
}

HomeNSAns is an answer to a HomeNSReq message.

type HomeNSReq

type HomeNSReq struct {
	NsJsMessageHeader
	DevEUI EUI64
}

HomeNSReq is a NetID request message.

type IdentityServer added in v3.15.2

type IdentityServer interface {
	HomeNSRequest(context.Context, *HomeNSReq) (*TTIHomeNSAns, error)
}

IdentityServer represents an Identity Server.

type JoinAns

type JoinAns struct {
	JsNsMessageHeader
	PHYPayload   Buffer
	Result       Result
	Lifetime     uint32
	SNwkSIntKey  *KeyEnvelope `json:",omitempty"`
	FNwkSIntKey  *KeyEnvelope `json:",omitempty"`
	NwkSEncKey   *KeyEnvelope `json:",omitempty"`
	NwkSKey      *KeyEnvelope `json:",omitempty"`
	AppSKey      *KeyEnvelope `json:",omitempty"`
	SessionKeyID Buffer       `json:",omitempty"`
}

JoinAns is an answer to a JoinReq message.

type JoinReq

type JoinReq struct {
	NsJsMessageHeader
	MACVersion MACVersion
	PHYPayload Buffer
	DevEUI     EUI64
	DevAddr    DevAddr
	DLSettings Buffer
	RxDelay    ttnpb.RxDelay
	CFList     Buffer
}

JoinReq is a join-request message.

type JoinServer

type JoinServer interface {
	JoinRequest(context.Context, *JoinReq) (*JoinAns, error)
	AppSKeyRequest(context.Context, *AppSKeyReq) (*AppSKeyAns, error)
	HomeNSRequest(context.Context, *HomeNSReq) (*TTIHomeNSAns, error)
}

JoinServer represents a Join Server as specified in LoRaWAN Backend Interfaces.

type JsAsMessageHeader

type JsAsMessageHeader struct {
	MessageHeader
	// SenderID is a JoinEUI.
	SenderID   EUI64
	ReceiverID string
}

JsAsMessageHeader contains the message header for JS to AS messages.

type JsNsMessageHeader

type JsNsMessageHeader struct {
	MessageHeader
	// SenderID is a JoinEUI.
	SenderID     EUI64
	ReceiverID   NetID
	ReceiverNSID *EUI64 `json:",omitempty"`
}

JsNsMessageHeader contains the message header for JS to NS messages.

type KeyEnvelope

type KeyEnvelope ttnpb.KeyEnvelope

KeyEnvelope contains a (encrypted) key.

func (KeyEnvelope) MarshalJSON

func (k KeyEnvelope) MarshalJSON() ([]byte, error)

MarshalJSON marshals the key envelope to JSON.

func (*KeyEnvelope) UnmarshalJSON

func (k *KeyEnvelope) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the key envelope from JSON.

type MACVersion

type MACVersion ttnpb.MACVersion

MACVersion is the MAC version.

func (MACVersion) MarshalText added in v3.15.2

func (v MACVersion) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*MACVersion) UnmarshalText added in v3.15.2

func (v *MACVersion) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type MessageHeader

type MessageHeader struct {
	ProtocolVersion ProtocolVersion
	TransactionID   uint32
	MessageType     MessageType
	SenderID,
	ReceiverID string
	SenderNSID    *EUI64       `json:",omitempty"`
	ReceiverNSID  *EUI64       `json:",omitempty"`
	SenderToken   Buffer       `json:",omitempty"`
	ReceiverToken Buffer       `json:",omitempty"`
	VSExtension   *VSExtension `json:",omitempty"`
}

MessageHeader is the common LoRaWAN Backend Interfaces message header.

func (MessageHeader) AnswerHeader

func (h MessageHeader) AnswerHeader() (MessageHeader, error)

AnswerHeader returns the header of the answer message.

type MessageType

type MessageType string

MessageType is the message type.

const (
	MessageTypeJoinReq     MessageType = "JoinReq"
	MessageTypeJoinAns     MessageType = "JoinAns"
	MessageTypeRejoinReq   MessageType = "RejoinReq"
	MessageTypeRejoinAns   MessageType = "RejoinAns"
	MessageTypeAppSKeyReq  MessageType = "AppSKeyReq"
	MessageTypeAppSKeyAns  MessageType = "AppSKeyAns"
	MessageTypePRStartReq  MessageType = "PRStartReq"
	MessageTypePRStartAns  MessageType = "PRStartAns"
	MessageTypePRStopReq   MessageType = "PRStopReq"
	MessageTypePRStopAns   MessageType = "PRStopAns"
	MessageTypeHRStartReq  MessageType = "HRStartReq"
	MessageTypeHRStartAns  MessageType = "HRStartAns"
	MessageTypeHRStopReq   MessageType = "HRStopReq"
	MessageTypeHRStopAns   MessageType = "HRStopAns"
	MessageTypeHomeNSReq   MessageType = "HomeNSReq"
	MessageTypeHomeNSAns   MessageType = "HomeNSAns"
	MessageTypeProfileReq  MessageType = "ProfileReq"
	MessageTypeProfileAns  MessageType = "ProfileAns"
	MessageTypeXmitDataReq MessageType = "XmitDataReq"
	MessageTypeXmitDataAns MessageType = "XmitDataAns"
)

LoRaWAN Backend Interfaces message types.

func (MessageType) Answer added in v3.15.2

func (m MessageType) Answer() (MessageType, bool)

Answer returns the answer message type. If the message type is not a request, this method returns false.

func (MessageType) IsRequest added in v3.15.2

func (m MessageType) IsRequest() bool

IsRequest returns whether the message type is a request that has an answer message type defined.

func (MessageType) ToJoinServer added in v3.15.2

func (m MessageType) ToJoinServer() bool

ToJoinServer indicates whether the message goes to a Join Server. If this method returns true, the message's ReceiverID must be a JoinEUI.

func (MessageType) Validate added in v3.15.2

func (m MessageType) Validate(version ProtocolVersion) error

Validate returns an error if the message type is not valid for the given protocol version.

type NetID

type NetID types.NetID

NetID is a LoRaWAN NetID.

func (NetID) MarshalText added in v3.15.2

func (n NetID) MarshalText() ([]byte, error)

MarshalJSON marshals the NetID to text.

func (*NetID) UnmarshalText added in v3.15.2

func (n *NetID) UnmarshalText(data []byte) error

UnmarshalText unmarshals the NetID from text.

type NetworkServerAuthInfo added in v3.15.2

type NetworkServerAuthInfo struct {
	NetID     types.NetID
	Addresses []string
}

NetworkServerAuthInfo contains the authentication information of a Network Server.

func NetworkServerAuthInfoFromContext added in v3.15.2

func NetworkServerAuthInfoFromContext(ctx context.Context) (*NetworkServerAuthInfo, bool)

NetworkServerAuthInfoFromContext returns the authentication information of the Network Server from context.

func (NetworkServerAuthInfo) Require added in v3.15.2

func (n NetworkServerAuthInfo) Require(netID types.NetID, nsID *EUI64) error

Require returns an error if the given NetID or NSID does not match.

type NsJsMessageHeader

type NsJsMessageHeader struct {
	MessageHeader
	SenderID NetID
	// ReceiverID is a JoinEUI.
	ReceiverID EUI64
	SenderNSID *EUI64 `json:",omitempty"`
}

NsJsMessageHeader contains the message header for NS to JS messages.

type NsMessageHeader added in v3.15.2

type NsMessageHeader struct {
	MessageHeader
	SenderID   NetID
	SenderNSID *EUI64 `json:",omitempty"`
}

NsMessageHeader contains the message header for NS messages.

type ProtocolVersion added in v3.15.2

type ProtocolVersion string

ProtocolVersion is the LoRaWAN Backend Interfaces protocol version.

func (ProtocolVersion) SupportsNSID added in v3.15.2

func (p ProtocolVersion) SupportsNSID() bool

SupportsNSID returns true if the protocol version supports Network Server IDs (NSID).

func (*ProtocolVersion) UnmarshalYAML added in v3.15.2

func (p *ProtocolVersion) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type Registerer

type Registerer interface {
	RegisterInterop(s *Server)
}

Registerer allows components to register their interop services to the web server.

type Result

type Result struct {
	ResultCode  ResultCode
	Description string `json:",omitempty"`
}

Result contains the result of an operation.

type ResultCode

type ResultCode string

ResultCode is the result of an answer message.

const (
	ResultSuccess              ResultCode = "Success"
	ResultNoAction             ResultCode = "NoAction"
	ResultMICFailed            ResultCode = "MICFailed"
	ResultFrameReplayed        ResultCode = "FrameReplayed"
	ResultJoinReqFailed        ResultCode = "JoinReqFailed"
	ResultNoRoamingAgreement   ResultCode = "NoRoamingAgreement"
	ResultDevRoamingDisallowed ResultCode = "DevRoamingDisallowed"
	ResultRoamingActDisallowed ResultCode = "RoamingActDisallowed"
	ResultActivationDisallowed ResultCode = "ActivationDisallowed"
	ResultUnknownDevEUI        ResultCode = "UnknownDevEUI"
	ResultUnknownDevAddr       ResultCode = "UnknownDevAddr"
	ResultUnknownSender        ResultCode = "UnknownSender"
	ResultUnkownReceiver       ResultCode = "UnkownReceiver" // sic
	// ResultUnknownReceiver is not specified in LoRaWAN Backend Interfaces 1.0 but is processed as ResultUnkownReceiver.
	ResultUnknownReceiver        ResultCode = "UnknownReceiver"
	ResultDeferred               ResultCode = "Deferred"
	ResultXmitFailed             ResultCode = "XmitFailed"
	ResultInvalidFPort           ResultCode = "InvalidFPort"
	ResultInvalidProtocolVersion ResultCode = "InvalidProtocolVersion"
	ResultStaleDeviceProfile     ResultCode = "StaleDeviceProfile"
	ResultMalformedRequest       ResultCode = "MalformedRequest"
	ResultMalformedMessage       ResultCode = "MalformedMessage"
	ResultFrameSizeError         ResultCode = "FrameSizeError"
	ResultOther                  ResultCode = "Other"
)

type Server

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

Server is the server.

func NewServer

func NewServer(c Component, contextFillers []fillcontext.Filler, conf config.InteropServer) (*Server, error)

NewServer builds a new server.

func (*Server) ClientCAPool added in v3.15.2

func (s *Server) ClientCAPool() *x509.CertPool

ClientCAPool returns a certificate pool of all configured client CAs.

func (*Server) RegisterIS added in v3.15.2

func (s *Server) RegisterIS(is IdentityServer)

RegisterIS registers the Identity Server for answering to HomeNSRequest.

func (*Server) RegisterJS

func (s *Server) RegisterJS(js JoinServer)

RegisterJS registers the Join Server for AS-JS, hNS-JS and vNS-JS messages. If an Identity Server is registered with RegisterIS, the Identity Server takes precedence for handling HomeNSRequest.

func (*Server) SenderClientCAs

func (s *Server) SenderClientCAs(ctx context.Context, senderID string) ([]*x509.Certificate, error)

SenderClientCAs returns the client certificate authorities that are trusted for the given SenderID. The SenderID is typically a NetID, but an AS-ID or JoinEUI can also be used to trust Application Servers and Join Servers respectively.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the HTTP request.

type TTIHomeNSAns added in v3.15.2

type TTIHomeNSAns struct {
	HomeNSAns
	// HTenantID is the Tenant ID within a host HNetID.
	HTenantID string
	// HNSAddress is the Home Network Server address.
	HNSAddress string
}

TTIHomeNSAns is HomeNSAns with vendor extension of The Things Industries.

func (TTIHomeNSAns) MarshalJSON added in v3.15.2

func (m TTIHomeNSAns) MarshalJSON() ([]byte, error)

func (*TTIHomeNSAns) UnmarshalJSON added in v3.15.2

func (m *TTIHomeNSAns) UnmarshalJSON(data []byte) error

type TTIVendorID added in v3.15.2

type TTIVendorID VendorID

func (TTIVendorID) MarshalText added in v3.15.2

func (v TTIVendorID) MarshalText() ([]byte, error)

MarshalText returns the vendor ID of The Things Industries.

func (*TTIVendorID) UnmarshalText added in v3.15.2

func (v *TTIVendorID) UnmarshalText(data []byte) error

UnmarshalText returns an error if the vendor ID is not of The Things Industries.

type VSExtension added in v3.15.2

type VSExtension struct {
	VendorID VendorID
}

VSExtension is a vendor-specific extension.

type VendorID added in v3.15.2

type VendorID [3]byte

VendorID is an IEEE MAC-L (OUI) assignment to indicate the vendor.

func (VendorID) IsTheThingsIndustries added in v3.15.2

func (v VendorID) IsTheThingsIndustries() bool

IsTheThingsIndustries returns true if the vendor ID is The Things Industries.

func (VendorID) MarshalText added in v3.15.2

func (v VendorID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*VendorID) UnmarshalText added in v3.15.2

func (v *VendorID) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

Jump to

Keyboard shortcuts

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