libatbus_message_handle

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateAccessDataSignature

func CalculateAccessDataSignature(_ *protocol.AccessData, accessToken []byte, plaintext string) []byte

CalculateAccessDataSignature computes the signature for the given plaintext.

It mirrors C++:

signature = HMAC-SHA256(plaintext, access_token)

and truncates access_token length to 32868 bytes.

func DispatchMessage

func DispatchMessage(n types.Node, conn types.Connection, m *Message, status int, errcode error_code.ErrorType) error_code.ErrorType

func GenerateAccessData

func GenerateAccessData(ad *protocol.AccessData, busID types.BusIdType, nonce1, nonce2 uint64, accessTokens [][]byte, hd *protocol.CryptoHandshakeData)

GenerateAccessData fills protocol.AccessData and appends one signature entry per token.

It mirrors the C++ overload that takes crypto_handshake_data.

func GenerateAccessDataForCustomCommand

func GenerateAccessDataForCustomCommand(ad *protocol.AccessData, busID types.BusIdType, nonce1, nonce2 uint64, accessTokens [][]byte, cs *protocol.CustomCommandData)

GenerateAccessDataForCustomCommand mirrors the C++ overload that takes custom_command_data.

func GenerateAccessDataWithTimestamp

func GenerateAccessDataWithTimestamp(ad *protocol.AccessData, busID types.BusIdType, nonce1, nonce2 uint64, accessTokens [][]byte, hd *protocol.CryptoHandshakeData, timestamp int64)

GenerateAccessDataWithTimestamp is like GenerateAccessData but allows specifying a fixed timestamp. This is primarily useful for cross-language compatibility testing.

func GetBodyName

func GetBodyName(bodyCase int) string

GetBodyName returns the protobuf full name of the oneof field for message_body.

This mirrors C++ `message_handler::get_body_name()` which uses the protobuf descriptor's `FieldDescriptor::full_name()`.

func MakeAccessDataPlaintextFromCustomCommand

func MakeAccessDataPlaintextFromCustomCommand(busID types.BusIdType, ad *protocol.AccessData, cs *protocol.CustomCommandData) string

MakeAccessDataPlaintextFromCustomCommand builds the signed plaintext string.

C++ rules:

"<timestamp>:<nonce1>-<nonce2>:<bus_id>:<sha256_hex(concat(commands.arg))>"

func MakeAccessDataPlaintextFromHandshake

func MakeAccessDataPlaintextFromHandshake(busID types.BusIdType, ad *protocol.AccessData, hd *protocol.CryptoHandshakeData) string

MakeAccessDataPlaintextFromHandshake builds the signed plaintext string.

C++ rules:

  • If public_key is empty: "<timestamp>:<nonce1>-<nonce2>:<bus_id>"
  • Else: "<timestamp>:<nonce1>-<nonce2>:<bus_id>:<type>:<sha256_hex(public_key)>"

func PackMessage

func PackMessage(connCtx types.ConnectionContext, msg *types.Message, protocolVersion int32, maxBodySize int) (*buffer.StaticBufferBlock, error_code.ErrorType)

PackMessage packs a Message and returns the binary data in a StaticBufferBlock.

maxBodySize bounds the body size before packing. If maxBodySize <= 0, the limit is not checked.

func SendCustomCommandResponse

func SendCustomCommandResponse(n types.Node, conn types.Connection, rspData [][]byte, t int32,
	errcode error_code.ErrorType, messageSequence uint64, fromBusId types.BusIdType,
) error_code.ErrorType

func SendMessage

func SendMessage(n types.Node, conn types.Connection, m *types.Message) error_code.ErrorType

func SendPing

func SendPing(n types.Node, conn types.Connection, messageSequence uint64) error_code.ErrorType

func SendRegister

func SendRegister(bodyType types.MessageBodyType, n types.Node, conn types.Connection, errcode error_code.ErrorType, messageSequence uint64) error_code.ErrorType

func SendTransferResponse

func SendTransferResponse(n types.Node, m *Message, errcode error_code.ErrorType) error_code.ErrorType

func UnpackMessage

func UnpackMessage(connCtx types.ConnectionContext, data []byte, maxBodySize int) (*types.Message, error_code.ErrorType)

UnpackMessage decodes binary data and populates a Message.

This function calls ConnectionContext.UnpackMessage internally. maxBodySize follows the C++ signature: it bounds the decoded body size. If maxBodySize <= 0, the limit is not checked.

Types

type DispatchHandleSet

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

Receiver declares message receive handlers. Implementations can be provided by higher-level packages.

type HandlerFn

type HandlerFn func(n types.Node, conn types.Connection, msg *Message, status int, errcode error_code.ErrorType) error_code.ErrorType

HandlerFn matches the C++ handler signature shape.

type Message

type Message = types.Message

Message is an alias to types.Message for convenience.

func NewMessage

func NewMessage() *Message

NewMessage creates a new empty Message.

Jump to

Keyboard shortcuts

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