go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/admin/admin.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package admin contains the types related to the admin request. 6 // See xrootd protocol specification (http://xrootd.org/doc/dev45/XRdv310.pdf, p. 37) for more details. 7 package admin // import "go-hep.org/x/hep/xrootd/xrdproto/admin" 8 9 import ( 10 "go-hep.org/x/hep/xrootd/internal/xrdenc" 11 ) 12 13 // RequestID is the id of the request, it is sent as part of message. 14 // See xrootd protocol specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, 2.3 Client Request Format. 15 const RequestID uint16 = 3020 16 17 // Request holds the admin request parameters. 18 type Request struct { 19 _ [16]byte 20 Req string 21 } 22 23 // ReqID implements xrdproto.Request.ReqID. 24 func (req *Request) ReqID() uint16 { return RequestID } 25 26 // ShouldSign implements xrdproto.Request.ShouldSign. 27 func (*Request) ShouldSign() bool { return false } 28 29 // MarshalXrd implements xrdproto.Marshaler. 30 func (o Request) MarshalXrd(w *xrdenc.WBuffer) error { 31 w.Next(16) 32 w.WriteStr(o.Req) 33 return nil 34 } 35 36 // UnmarshalXrd implements xrdproto.Unmarshaler. 37 func (o *Request) UnmarshalXrd(r *xrdenc.RBuffer) error { 38 r.Skip(16) 39 o.Req = r.ReadStr() 40 return nil 41 } 42 43 // Response is the response issued by the server to an admin request. 44 type Response struct { 45 Data []byte 46 } 47 48 // RespID implements xrdproto.Response.RespID. 49 func (*Response) RespID() uint16 { return RequestID } 50 51 // MarshalXrd implements xrdproto.Marshaler. 52 func (o Response) MarshalXrd(w *xrdenc.WBuffer) error { 53 w.WriteBytes(o.Data) 54 return nil 55 } 56 57 // UnmarshalXrd implements xrdproto.Unmarshaler. 58 func (o *Response) UnmarshalXrd(r *xrdenc.RBuffer) error { 59 o.Data = make([]byte, r.Len()) 60 r.ReadBytes(o.Data) 61 return nil 62 }