Documentation ¶
Index ¶
- Constants
- Variables
- func GeneratedSessionKeyID(id []byte) bool
- func JoinServerFQDN(eui types.EUI64, domain string) string
- func NewContextWithApplicationServerAuthInfo(parent context.Context, authInfo *ApplicationServerAuthInfo) context.Context
- func NewContextWithNetworkServerAuthInfo(parent context.Context, authInfo *NetworkServerAuthInfo) context.Context
- type AppSKeyAns
- type AppSKeyReq
- type ApplicationServerAuthInfo
- type AsJsMessageHeader
- type AsMessageHeader
- type Authorizer
- type Buffer
- type Client
- type Component
- type DevAddr
- type EUI64
- type ErrorMessage
- type HomeNSAns
- type HomeNSReq
- type IdentityServer
- type JoinAns
- type JoinReq
- type JoinServer
- type JsAsMessageHeader
- type JsNsMessageHeader
- type KeyEnvelope
- type MACVersion
- type MessageHeader
- type MessageType
- type NetID
- type NetworkServerAuthInfo
- type NsJsMessageHeader
- type NsMessageHeader
- type ProtocolVersion
- type Registerer
- type Result
- type ResultCode
- type Server
- func (s *Server) ClientCAPool() *x509.CertPool
- func (s *Server) RegisterIS(is IdentityServer)
- func (s *Server) RegisterJS(js JoinServer)
- func (s *Server) SenderClientCAs(ctx context.Context, senderID string) ([]*x509.Certificate, error)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type TTIHomeNSAns
- type TTIVendorID
- type VSExtension
- type VendorID
Constants ¶
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 )
const ( // InteropClientConfigurationName represents the filename of interop client configuration. InteropClientConfigurationName = "config.yml" // SenderClientCAsConfigurationName represents the filename of sender client CAs configuration. SenderClientCAsConfigurationName = "config.yml" )
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 ¶
var ( ErrNoAction = errors.DefineAborted("no_action", "no action") ErrMIC = errors.DefineCorruption("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 ¶
GeneratedSessionKeyID returns whether the session key ID is generated locally and not by the Join Server.
func JoinServerFQDN ¶
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
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
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
MarshalText implements encoding.TextMarshaler.
func (*Buffer) UnmarshalText ¶ added in v3.15.2
UnmarshalText implements encoding.TextUnmarshaler.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
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 { Context() context.Context RateLimiter() ratelimit.Interface HTTPClient(context.Context) (*http.Client, error) }
Components represents the Component to the Interop Server.
type DevAddr ¶
DevAddr is a LoRaWAN DevAddr.
func (DevAddr) MarshalText ¶ added in v3.15.2
MarshalText implements encoding.TextMarshaler.
func (*DevAddr) UnmarshalText ¶ added in v3.15.2
UnmarshalText implements encoding.TextUnmarshaler.
type EUI64 ¶
EUI64 is an 64-bit EUI, e.g. a DevEUI or JoinEUI.
func (EUI64) MarshalText ¶ added in v3.15.2
MarshalText implements encoding.TextMarshaler.
func (*EUI64) UnmarshalText ¶ added in v3.15.2
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 ¶
NetID is a LoRaWAN NetID.
func (NetID) MarshalText ¶ added in v3.15.2
MarshalJSON marshals the NetID to text.
func (*NetID) UnmarshalText ¶ added in v3.15.2
UnmarshalText unmarshals the NetID from text.
type NetworkServerAuthInfo ¶ added in v3.15.2
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.
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
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 ¶
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.
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
IsTheThingsIndustries returns true if the vendor ID is The Things Industries.
func (VendorID) MarshalText ¶ added in v3.15.2
MarshalText implements encoding.TextMarshaler.
func (*VendorID) UnmarshalText ¶ added in v3.15.2
UnmarshalText implements encoding.TextUnmarshaler.