Temporarily add go-agentx (w/ fixes to lexico ordering)

This commit is contained in:
Pim van Pelt
2025-06-09 17:14:28 +02:00
parent 824496c402
commit 771cc6ff48
45 changed files with 2477 additions and 0 deletions

View File

@ -0,0 +1,38 @@
// Copyright 2018 The agentx authors
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.
package pdu
import (
"fmt"
)
// HeaderPacket defines a container structure for a header and a packet.
type HeaderPacket struct {
Header *Header
Packet Packet
}
// MarshalBinary returns the pdu packet as a slice of bytes.
func (hp *HeaderPacket) MarshalBinary() ([]byte, error) {
payloadBytes, err := hp.Packet.MarshalBinary()
if err != nil {
return nil, err
}
hp.Header.Version = 1
hp.Header.Type = hp.Packet.Type()
hp.Header.PayloadLength = uint32(len(payloadBytes))
result, err := hp.Header.MarshalBinary()
if err != nil {
return nil, err
}
return append(result, payloadBytes...), nil
}
func (hp *HeaderPacket) String() string {
return fmt.Sprintf("[head %v, body %v]", hp.Header, hp.Packet)
}