Documentation ¶
Index ¶
Constants ¶
View Source
const ( PacketTypeResponse uint8 = 1 PacketTypeError uint8 = 2 PacketTypeMessage uint8 = 6 PacketTypeTransfer uint8 = 7 )
View Source
const ( ErrTemporaryUnreachable = "T00" ErrFinalNotAccepted = "F00" ErrFinalInvalidFields = "F01" ErrFinalTransferNotFound = "F03" ErrFinalInvalidFulfillment = "F04" ErrFinalDuplicateID = "F05" ErrFinalAlreadyRolledBack = "F06" ErrFinalAlreadyFulfilled = "F07" ErrFinalInsufficientBalance = "F08" )
Variables ¶
View Source
var ( ErrPacketTypeNotSupported = errors.New("packet type not supported") ErrPacketMissingOER = errors.New("packet type missing OER interface") )
View Source
var ( ErrorCodeToName = map[string]string{ ErrTemporaryUnreachable: "UnreachableError", ErrFinalNotAccepted: "NotAcceptedError", ErrFinalInvalidFields: "InvalidFieldsError", ErrFinalTransferNotFound: "TransferNotFoundError", ErrFinalInvalidFulfillment: "InvalidFulfillmentError", ErrFinalDuplicateID: "DuplicateIdError", ErrFinalAlreadyRolledBack: "AlreadyRolledBackError", ErrFinalAlreadyFulfilled: "AlreadyFulfilledError", ErrFinalInsufficientBalance: "InsufficientBalanceError", } )
View Source
var ( PacketTypeToString = map[uint8]string{ PacketTypeResponse: "response", PacketTypeError: "error", PacketTypeMessage: "message", PacketTypeTransfer: "transfer", } )
Functions ¶
Types ¶
type Authenticator ¶
Authenticator presents a way of one conn presenting its authentication details to the other e.g. a key which would enable only the key holders to connect to a specific connector
type ContentType ¶
type ContentType byte
const ( ContentApplicationOctetStream ContentType = iota ContentTextPlainUTF8 ContentApplicationJSON )
type ErrorPacket ¶
type ErrorPacket struct { Id uint32 Code string TriggeredAt time.Time Data []byte ProtocolData ProtocolData }
func (*ErrorPacket) ID ¶
func (p *ErrorPacket) ID() uint32
func (*ErrorPacket) MarshalOER ¶
func (p *ErrorPacket) MarshalOER(enc *oer.Encoder) error
OER marshaling TODO(uh): Think of a way to generate this with go:generate. Maybe use struct tags or comments? Do not use reflection.
func (*ErrorPacket) ProtoData ¶
func (p *ErrorPacket) ProtoData() ProtocolData
func (*ErrorPacket) Type ¶
func (p *ErrorPacket) Type() uint8
func (*ErrorPacket) UnmarshalOER ¶
func (p *ErrorPacket) UnmarshalOER(dec *oer.Decoder) error
TODO(uh): Set the id
type MessagePacket ¶
type MessagePacket struct { Id uint32 ProtocolData ProtocolData }
func BuildAuthenticationPacket ¶
func BuildAuthenticationPacket(id uint32, data *AuthData) *MessagePacket
func (*MessagePacket) ID ¶
func (p *MessagePacket) ID() uint32
func (*MessagePacket) MarshalOER ¶
func (p *MessagePacket) MarshalOER(enc *oer.Encoder) error
func (*MessagePacket) ProtoData ¶
func (p *MessagePacket) ProtoData() ProtocolData
func (*MessagePacket) Type ¶
func (p *MessagePacket) Type() uint8
func (*MessagePacket) UnmarshalOER ¶
func (p *MessagePacket) UnmarshalOER(dec *oer.Decoder) error
type Packet ¶
type Packet interface { ID() uint32 Type() uint8 ProtoData() ProtocolData }
func DecodePacket ¶
DecodePacket decodes and reconstructs a BTP packet from an OER reader.
type ProtocolData ¶
type ProtocolData []*ProtocolDataEntry
type ProtocolDataEntry ¶
type ProtocolDataEntry struct { Name string ContentType ContentType Data []byte }
func (*ProtocolDataEntry) Decode ¶
func (pd *ProtocolDataEntry) Decode(dst protocolDataEntry) (err error)
type ResponsePacket ¶
type ResponsePacket struct { Id uint32 ProtocolData ProtocolData }
func (*ResponsePacket) ID ¶
func (p *ResponsePacket) ID() uint32
func (*ResponsePacket) MarshalOER ¶
func (p *ResponsePacket) MarshalOER(enc *oer.Encoder) error
func (*ResponsePacket) ProtoData ¶
func (p *ResponsePacket) ProtoData() ProtocolData
func (*ResponsePacket) Type ¶
func (p *ResponsePacket) Type() uint8
func (*ResponsePacket) UnmarshalOER ¶
func (p *ResponsePacket) UnmarshalOER(dec *oer.Decoder) error
type StaticAuthenticator ¶
type StaticAuthenticator struct {
User, Token string
}
func (*StaticAuthenticator) Authenticate ¶
func (s *StaticAuthenticator) Authenticate(req *AuthData) bool
type TransferPacket ¶
type TransferPacket struct { Id uint32 Amount uint64 ProtocolData ProtocolData }
TODO(uh): Why is this something that should be needed by the BTP protocol?
func (*TransferPacket) ID ¶
func (p *TransferPacket) ID() uint32
func (*TransferPacket) MarshalOER ¶
func (p *TransferPacket) MarshalOER(enc *oer.Encoder) error
func (*TransferPacket) ProtoData ¶
func (p *TransferPacket) ProtoData() ProtocolData
func (*TransferPacket) Type ¶
func (p *TransferPacket) Type() uint8
func (*TransferPacket) UnmarshalOER ¶
func (p *TransferPacket) UnmarshalOER(dec *oer.Decoder) error
Click to show internal directories.
Click to hide internal directories.