Skip to content

Commit

Permalink
URIDevicePath
Browse files Browse the repository at this point in the history
  • Loading branch information
blnidson76 committed Jul 8, 2024
1 parent c4b5dff commit 792b630
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions efi/efitypes/efidevicepath/messagingpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import (
)

const (
MACAddressSubType = 11
IPv4DeviceSubType = 12
SATADeviceSubType = 18
URIDeviceSubType = 10
MACAddressSubType = 11
IPv4DeviceSubType = 12
SATADeviceSubType = 18
VENDORDeviceSubType = 24
)

func ParseMessagingDevicePath(r io.Reader, h Head) (p DevicePath, err error) {
Expand All @@ -36,6 +38,8 @@ func ParseMessagingDevicePath(r io.Reader, h Head) (p DevicePath, err error) {
p = &IPv4DevicePath{Head: h}
case SATADeviceSubType:
p = &SATADevicePath{Head: h}
case URIDeviceSubType:
p = &URIDevicePath{Head: h}
default:
p = &UnrecognizedDevicePath{Head: h}
}
Expand Down Expand Up @@ -122,3 +126,26 @@ func (p *IPv4DevicePath) ReadFrom(r io.Reader) (n int64, err error) {
}
return
}

type URIDevicePath struct {
Head
URI []byte
}

func (p *URIDevicePath) Text() string {
return fmt.Sprintf("URI: %s", string(p.URI))
}

func (p *URIDevicePath) GetHead() *Head {
return &p.Head
}

func (p *URIDevicePath) ReadFrom(r io.Reader) (n int64, err error) {
fr := efireader.NewFieldReader(r, &n)
p.URI = make([]byte, p.Length-4)

if err = fr.ReadFields(&p.URI); err != nil {
return
}
return
}

0 comments on commit 792b630

Please sign in to comment.