diff --git a/t/neo/marshal.go b/t/neo/marshal.go index cc5a27c2940434e338f062b34259de120016ac39..1b6637a25283c66abbf4f048c94ca398c36c6ab4 100644 --- a/t/neo/marshal.go +++ b/t/neo/marshal.go @@ -80,3 +80,69 @@ func (p *Ping) NEODecode(data []byte) (int, error) { func (p *CloseClient) NEODecode(data []byte) (int, error) { return 0 /* + TODO variable part */, nil } +func (p *RequestIdentification) NEODecode(data []byte) (int, error) { + p.ProtocolVersion = BigEndian.Uint32(data[0:]) + p.NodeType = int32(BigEndian.Uint32(data[4:])) + p.UUID = int32(BigEndian.Uint32(data[8:])) + { + l := BigEndian.Uint32(data[12:]) + data = data[16:] + if len(data) < l { + return 0, ErrDecodeOverflow + } + p.Address.Host = string(data[:l]) + data = data[l:] + } + p.Address.Port = BigEndian.Uint16(data[0:]) + { + l := BigEndian.Uint32(data[2:]) + data = data[6:] + if len(data) < l { + return 0, ErrDecodeOverflow + } + p.Name = string(data[:l]) + data = data[l:] + } + p.IdTimestamp = float64_NEODecode(data[0:]) + return 8 /* + TODO variable part */, nil +} +func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { + p.NodeType = int32(BigEndian.Uint32(data[0:])) + p.MyUUID = int32(BigEndian.Uint32(data[4:])) + p.NumPartitions = BigEndian.Uint32(data[8:]) + p.NumReplicas = BigEndian.Uint32(data[12:]) + p.YourUUID = int32(BigEndian.Uint32(data[16:])) + { + l := BigEndian.Uint32(data[20:]) + data = data[24:] + if len(data) < l { + return 0, ErrDecodeOverflow + } + p.Primary.Host = string(data[:l]) + data = data[l:] + } + p.Primary.Port = BigEndian.Uint16(data[0:]) + { + l := BigEndian.Uint32(data[2:]) + data = data[6:] + p.KnownMasterList = make([]struct { + neo.Address + UUID neo.UUID + }, l) + for i := 0; i < l; i++ { + { + l := BigEndian.Uint32(data[0:]) + data = data[4:] + if len(data) < l { + return 0, ErrDecodeOverflow + } + p.KnownMasterList[i].Address.Host = string(data[:l]) + data = data[l:] + } + p.KnownMasterList[i].Address.Port = BigEndian.Uint16(data[0:]) + p.KnownMasterList[i].UUID = int32(BigEndian.Uint32(data[2:])) + data = data[6:] + } + } + return 0 /* + TODO variable part */, nil +} diff --git a/t/neo/proto.go b/t/neo/proto.go index 0b5f769da2f165b2c6588c6cb81b4030805f9d34..bab918c6c3f5184305d023d269c5fe1cef4a84af 100644 --- a/t/neo/proto.go +++ b/t/neo/proto.go @@ -208,7 +208,6 @@ type Ping struct { type CloseClient struct { } -/* // Request a node identification. This must be the first packet for any // connection. Any -> Any. type RequestIdentification struct { @@ -234,6 +233,7 @@ type AcceptIdentification struct { } } +/* // Ask current primary master's uuid. CTL -> A. type PrimaryMaster struct { } diff --git a/t/neo/protogen.go b/t/neo/protogen.go index 39bdc8ed74f1ecdd56bb73b91b6c1a4fe8d1bfb8..0ba3d3e8083ed7abefa32332b1f5140068b0d26f 100644 --- a/t/neo/protogen.go +++ b/t/neo/protogen.go @@ -268,7 +268,7 @@ func gendecode(typespec *ast.TypeSpec) string { d.emitobjtype("p", obj, typ) - d.emit("return %v /* + TODO variable part */, nil", d.n) + d.emit("return %v /* + TODO variable part */, nil", d.n) // FIXME n is wrong after reset d.emit("}") return d.buf.String()