diff --git a/pkg/common/decoder.go b/pkg/common/decoder.go index f70b0139..2d9e25f1 100644 --- a/pkg/common/decoder.go +++ b/pkg/common/decoder.go @@ -28,6 +28,11 @@ func ReadIntX(v string, p int) int { return int(v[p+3])*0x1000000 + int(v[p+2])<<16 + int(v[p+1])<<8 + int(v[p]) } +// ReadBufferShort reads a short value from a byte array at position p. +func ReadBufferIntX(v []byte, p int) int { + return int(v[p+3])*0x1000000 + int(v[p+2])<<16 + int(v[p+1])<<8 + int(v[p]) +} + // ShortToStr converts a short value to a string. func ShortToStr(v int) string { return string([]byte{byte((v >> 8) & 0xFF), byte(v & 0xFF)}) diff --git a/pkg/wsman/amt/messagelog/decoder.go b/pkg/wsman/amt/messagelog/decoder.go index 7b79491b..b9b5945f 100644 --- a/pkg/wsman/amt/messagelog/decoder.go +++ b/pkg/wsman/amt/messagelog/decoder.go @@ -5,6 +5,8 @@ package messagelog +import "encoding/base64" + const ( AMTMessageLog string = "AMT_MessageLog" GetRecords string = "GetRecords" @@ -409,3 +411,20 @@ func (p PositionToFirstRecordReturnValue) String() string { return ValueNotFound } + +func convertToEventLogResult(eventlogdata []string) ([]EventLogRecord, error) { + records := []EventLogRecord{} + + for _, eventRecord := range eventlogdata { + decodedEventRecord, err := base64.StdEncoding.DecodeString(eventRecord) + if err != nil { + continue + } + + eventLogRecord := EventLogRecord{} + const TimeStamp = common.ReadBufferIntX(eventRecord, 0) + + } + + return records, nil +} diff --git a/pkg/wsman/amt/messagelog/types.go b/pkg/wsman/amt/messagelog/types.go index 8b9a4f47..83513900 100644 --- a/pkg/wsman/amt/messagelog/types.go +++ b/pkg/wsman/amt/messagelog/types.go @@ -81,6 +81,24 @@ type ( ReturnValue PositionToFirstRecordReturnValue `xml:"ReturnValue"` // ValueMap={0, 1, 2} Values={Completed with No Error, Not Supported, No record exists} } + EventLogRecord struct { + DeviceAddress int + EventSensorType int + EventType int + EventOffset int + EventSourceType int + EventSeverity int + SensorNumber int + Entity int + EntityInstance int + EventData []int + TimeStamp string + } + + EventSeverity struct { + + } + // Capabilities is an array of integers indicating the Log capabilities. Capabilities int