MCPcopy Create free account
hub / github.com/Merovius/nbd / decodeOption

Function decodeOption

types.go:42–69  ·  view source on GitHub ↗
(e *encoder)

Source from the content-addressed store, hash-verified

40}
41
42func decodeOption(e *encoder) (uint32, interface{}, errno) {
43 magic := e.uint64()
44 if magic != optMagic {
45 e.check(fmt.Errorf("invalid option magic 0x%x", magic))
46 }
47 option := e.uint32()
48 length := e.uint32()
49 if length > maxOptionLength {
50 return option, nil, errTooBig
51 }
52 var o interface{ decode(*encoder, uint32) errno }
53 switch option {
54 case cOptExportName:
55 o = new(optExportName)
56 case cOptAbort:
57 o = new(optAbort)
58 case cOptList:
59 o = new(optList)
60 case cOptInfo:
61 o = &optInfo{done: false}
62 case cOptGo:
63 o = &optInfo{done: true}
64 }
65 if o == nil {
66 return option, nil, errUnsup
67 }
68 return option, o, o.decode(e, length)
69}
70
71const (
72 cOptExportName = 1

Callers 1

serverHandshakeFunction · 0.85

Calls 3

uint64Method · 0.80
uint32Method · 0.80
decodeMethod · 0.65

Tested by

no test coverage detected