Skip to content

Commit

Permalink
event log decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-primrose committed May 21, 2024
1 parent 9365153 commit c624523
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/common/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)})
Expand Down
19 changes: 19 additions & 0 deletions pkg/wsman/amt/messagelog/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package messagelog

import "encoding/base64"

const (
AMTMessageLog string = "AMT_MessageLog"
GetRecords string = "GetRecords"
Expand Down Expand Up @@ -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)

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 decodedEventRecord declared and not used Raw Output: pkg/wsman/amt/messagelog/decoder.go:419:3: decodedEventRecord declared and not used

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 decodedEventRecord declared and not used Raw Output: pkg/wsman/amt/messagelog/decoder.go:419:3: decodedEventRecord declared and not used

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, windows-2019)

decodedEventRecord declared and not used

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, windows-2022)

decodedEventRecord declared and not used

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, ubuntu-22.04)

decodedEventRecord declared and not used

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, ubuntu-20.04)

decodedEventRecord declared and not used

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.21.x, ubuntu-20.04)

decodedEventRecord declared and not used

Check failure on line 419 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.21.x, ubuntu-22.04)

decodedEventRecord declared and not used
if err != nil {
continue
}

eventLogRecord := EventLogRecord{}

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 eventLogRecord declared and not used Raw Output: pkg/wsman/amt/messagelog/decoder.go:424:3: eventLogRecord declared and not used

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 eventLogRecord declared and not used Raw Output: pkg/wsman/amt/messagelog/decoder.go:424:3: eventLogRecord declared and not used

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, windows-2019)

eventLogRecord declared and not used

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, windows-2022)

eventLogRecord declared and not used

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, ubuntu-22.04)

eventLogRecord declared and not used

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, ubuntu-20.04)

eventLogRecord declared and not used

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.21.x, ubuntu-20.04)

eventLogRecord declared and not used

Check failure on line 424 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.21.x, ubuntu-22.04)

eventLogRecord declared and not used
const TimeStamp = common.ReadBufferIntX(eventRecord, 0)

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 undefined: common) (typecheck) Raw Output: pkg/wsman/amt/messagelog/decoder.go:425:21: undefined: common) (typecheck) "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/messagelog" ^

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 undefined: common (typecheck) Raw Output: pkg/wsman/amt/messagelog/decoder.go:425:21: undefined: common (typecheck) /*********************************************************************

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, windows-2019)

undefined: common

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, windows-2022)

undefined: common

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, ubuntu-22.04)

undefined: common

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.20.x, ubuntu-20.04)

undefined: common

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.21.x, ubuntu-20.04)

undefined: common

Check failure on line 425 in pkg/wsman/amt/messagelog/decoder.go

View workflow job for this annotation

GitHub Actions / runner / build and tests (1.21.x, ubuntu-22.04)

undefined: common

}

return records, nil
}
18 changes: 18 additions & 0 deletions pkg/wsman/amt/messagelog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c624523

Please sign in to comment.