xrdproto

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package protocol contains the XRootD protocol specific types and methods to handle them, such as marshalling and unmarshalling requests.

Index

Constants

View Source
const RequestHeaderLength = 2 + 2

RequestHeaderLength is the length of the RequestHeader in bytes.

View Source
const ResponseHeaderLength = 2 + 2 + 4

ResponseHeaderLength is the length of the ResponseHeader in bytes.

View Source
const SecurityOverrideLength = 2

SecurityOverrideLength is the length of SecurityOverride in bytes.

Variables

This section is empty.

Functions

func Opaque

func Opaque(path string) string

Opaque returns opaque data from provided path.

func ReadRequest

func ReadRequest(r io.Reader) ([]byte, error)

ReadRequest reads a XRootD request from r. ReadRequest returns entire payload of the request including header. ReadRequest requires serialization since multiple ReadFull calls are made.

func ReadResponseWithReuse

func ReadResponseWithReuse(r io.Reader, headerBytes []byte, header *ResponseHeader) ([]byte, error)

ReadResponseWithReuse reads a XRootD response from r. A response header is read into headerBytes and unmarshaled to header for the reusing reasons. ReadResponseWithReuse returns the response body. ReadResponseWithReuse requires serialization since multiple ReadFull calls are made.

func SetOpaque

func SetOpaque(path *string, opaque string)

SetOpaque sets opaque data part in the provided path.

func WriteResponse

func WriteResponse(w io.Writer, streamID StreamID, status ResponseStatus, resp Marshaler) error

WriteResponse writes a XRootD response resp to the w. The response is directed to the stream with id equal to the streamID. The status is sent as part of response header. WriteResponse writes all data to the w as single Write call, so no serialization is required.

Types

type DataRequest

type DataRequest interface {
	// PathID returns an identifier of the socket which should be used to read or write a data.
	PathID() PathID

	// SePathID sets the identifier of the socket which should be used to read or write a data.
	SetPathID(pathID PathID)

	// Direction returns the direction of the request: either reading or writing.
	Direction() DataRequestDirection

	// PathData returns the data which should be send to the data socket.
	PathData() []byte
}

DataRequest is the request that operate over 2 sockets. One socket is used for sending the request and other is used to send or receive data.

type DataRequestDirection

type DataRequestDirection int

DataRequestDirection is the direction of the request: either reading or writing.

const (
	// DataRequestRead indicates that request has reading direction.
	// In other words, the request obtains a data from the server.
	DataRequestRead DataRequestDirection = iota

	// DataRequestWrite indicates that request has writing direction.
	// In other words, the request sends a data to the server.
	DataRequestWrite
)

type FilepathRequest

type FilepathRequest interface {
	Opaque() string          // Opaque returns opaque data from this request.
	SetOpaque(opaque string) // SetOpaque sets opaque data for this request.
}

FilepathRequest is a request that contains file paths. This interface is used to append opaque data to the request. Opaque data is received as part of the redirect response.

type Marshaler

type Marshaler interface {
	MarshalXrd(enc *xrdenc.WBuffer) error
}

Marshaler is the interface implemented by a type that can marshal itself into a binary form, following the XRootD protocol.

MarshalXrd encodes the receiver into a binary form and returns the result.

type PathID

type PathID byte

PathID is the socket identifier. It may be used in read and write requests to indicate which socket should be used for a response or as a source of data.

type Request

type Request interface {
	// ReqID uniquely identifies the type of a request.
	ReqID() uint16

	// ShouldSign indicates whether this request should be signed if security level is SignLikely.
	// For the list of actual examples see XRootD protocol specification v. 3.1.0, p.76.
	ShouldSign() bool

	Marshaler
	Unmarshaler
}

Request is a XRootD request issued to a server.

type RequestHeader

type RequestHeader struct {
	StreamID  StreamID
	RequestID uint16
}

ResponseHeader is the header that precedes all requests (we are interested in StreamID and RequestID, actual request parameters are a part of specific request).

func (RequestHeader) MarshalXrd

func (o RequestHeader) MarshalXrd(wBuffer *xrdenc.WBuffer) error

MarshalXrd implements Marshaler.

func (*RequestHeader) UnmarshalXrd

func (o *RequestHeader) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error

UnmarshalXrd implements Unmarshaler.

type RequestLevel

type RequestLevel byte

RequestLevel is the security requirement that the associated request is to have.

const (
	SignNone   RequestLevel = 0 // SignNone indicates that the request need not to be signed.
	SignLikely RequestLevel = 1 // SignLikely indicates that the request must be signed if it modifies data.
	SignNeeded RequestLevel = 2 // SignNeeded indicates that the request mush be signed.
)

type Response

type Response interface {
	RespID() uint16
	Marshaler
	Unmarshaler
}

Response is a XRootD response returned by the server

type ResponseHeader

type ResponseHeader struct {
	StreamID   StreamID
	Status     ResponseStatus
	DataLength int32
}

ResponseHeader is the header that precedes all responses (see xrootd protocol specification).

func ReadResponse

func ReadResponse(r io.Reader) (ResponseHeader, []byte, error)

ReadResponse reads a XRootD response from r. ReadResponse returns the response header and the response body. ReadResponse requires serialization since multiple ReadFull calls are made.

func (ResponseHeader) Error

func (hdr ResponseHeader) Error(data []byte) error

Error returns an error received from the server or nil if request hasn't failed.

func (ResponseHeader) MarshalXrd

func (o ResponseHeader) MarshalXrd(wBuffer *xrdenc.WBuffer) error

MarshalXrd implements xrdproto.Marshaler

func (*ResponseHeader) UnmarshalXrd

func (o *ResponseHeader) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error

UnmarshalXrd implements xrdproto.Unmarshaler

type ResponseStatus

type ResponseStatus uint16

ResponseStatus is the status code indicating how the request completed.

const (
	// Ok indicates that request fully completed and no addition responses will be forthcoming.
	Ok ResponseStatus = 0
	// OkSoFar indicates that server provides partial response and client should be prepared
	// to receive additional responses on same stream.
	OkSoFar ResponseStatus = 4000
	// Error indicates that an error occurred during request handling.
	// Error code and error message are sent as part of response (see xrootd protocol specification v3.1.0, p. 27).
	Error ResponseStatus = 4003
	// Redirect indicates that the client must re-issue the request to another server.
	Redirect ResponseStatus = 4004
	// Wait indicates that the client must wait the indicated number of seconds and retry the request.
	Wait ResponseStatus = 4005
)

type SecurityLevel

type SecurityLevel byte

SecurityLevel is the predefined security level that specifies which requests should be signed. See specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, p. 75.

const (
	// NoneLevel indicates that no request needs to be signed.
	NoneLevel SecurityLevel = 0
	// Compatible indicates that only potentially destructive requests need to be signed.
	Compatible SecurityLevel = 1
	// Standard indicates that potentially destructive requests
	// as well as certain non-destructive requests need to be signed.
	Standard SecurityLevel = 2
	// Intense indicates that request that may reveal metadata or modify data need to be signed.
	Intense SecurityLevel = 3
	// Pedantic indicates that all requests need to be signed.
	Pedantic SecurityLevel = 4
)

type SecurityOverride

type SecurityOverride struct {
	RequestIndex byte
	RequestLevel RequestLevel
}

SecurityOverride is an alteration needed to the specified predefined security level. It consists of the request index and the security requirement the associated request should have. Request index is calculated as:

(request code) - (request code of Auth request)

according to xrootd protocol specification.

func (SecurityOverride) MarshalXrd

func (o SecurityOverride) MarshalXrd(enc *xrdenc.WBuffer) error

MarshalXrd implements xrdproto.Marshaler

func (*SecurityOverride) UnmarshalXrd

func (o *SecurityOverride) UnmarshalXrd(dec *xrdenc.RBuffer) error

UnmarshalXrd implements xrdproto.Unmarshaler

type ServerError

type ServerError struct {
	Code    ServerErrorCode
	Message string
}

ServerError is the error returned by the XRootD server as part of response to the request.

func (ServerError) Error

func (err ServerError) Error() string

func (ServerError) MarshalXrd

func (o ServerError) MarshalXrd(wBuffer *xrdenc.WBuffer) error

MarshalXrd implements Marshaler.

func (*ServerError) UnmarshalXrd

func (o *ServerError) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error

UnmarshalXrd implements Unmarshaler.

type ServerErrorCode

type ServerErrorCode int32

ServerErrorCode is the code of the error returned by the XRootD server as part of response to the request.

const (
	InvalidRequest ServerErrorCode = 3006 // InvalidRequest indicates that request is invalid.
	IOError        ServerErrorCode = 3007 // IOError indicates that an IO error has occurred on the server side.
	NotAuthorized  ServerErrorCode = 3010 // NotAuthorized indicates that user was not authorized for operation.
	NotFound       ServerErrorCode = 3011 // NotFound indicates that path was not found on the remote server.
)

type ServerType

type ServerType int32

ServerType is the general server type kept for compatibility with 2.0 protocol version (see xrootd protocol specification v3.1.0, p. 5).

const (
	// LoadBalancingServer indicates whether this is a load-balancing server.
	LoadBalancingServer ServerType = iota
	// DataServer indicates whether this is a data server.
	DataServer
)

type StreamID

type StreamID [2]byte

StreamID is the binary identifier associated with a request stream.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalXrd(dec *xrdenc.RBuffer) error
}

Unmarshaler is the interface implemented by a type that can unmarshal a binary representation of itself, following the XRootD protocol.

UnmarshalXrd must be able to decode the form generated by MarshalXrd. UnmarshalXrd must copy the data if it wishes to retain the data after returning.

type WaitResponse

type WaitResponse struct {
	Duration time.Duration
}

WaitResponse is the response indicating that the client must wait and retry the request. See http://xrootd.org/doc/dev45/XRdv310.pdf, p. 35 for details.

func (WaitResponse) MarshalXrd

func (o WaitResponse) MarshalXrd(wBuffer *xrdenc.WBuffer) error

MarshalXrd implements Marshaler.

func (*WaitResponse) UnmarshalXrd

func (o *WaitResponse) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error

UnmarshalXrd implements Unmarshaler.

Directories

Path Synopsis
Package admin contains the types related to the admin request.
Package admin contains the types related to the admin request.
Package auth contains the structures describing auth request.
Package auth contains the structures describing auth request.
host
Package host contains the implementation for the "host" security provider.
Package host contains the implementation for the "host" security provider.
krb5
Package krb5 contains the implementation of krb5 (Kerberos) security provider.
Package krb5 contains the implementation of krb5 (Kerberos) security provider.
unix
Package unix contains the implementation of unix security provider.
Package unix contains the implementation of unix security provider.
Package bind contains the structures describing bind request and response.
Package bind contains the structures describing bind request and response.
Package chmod contains the structures describing chmod request.
Package chmod contains the structures describing chmod request.
Package decrypt contains the types related to the decrypt request.
Package decrypt contains the types related to the decrypt request.
Package dirlist contains the structures describing request and response for dirlist request used to obtain the contents of a directory.
Package dirlist contains the structures describing request and response for dirlist request used to obtain the contents of a directory.
Package endsess contains the types related to the endsess request.
Package endsess contains the types related to the endsess request.
Package handshake contains the structures describing request and response for handshake request (see XRootD specification).
Package handshake contains the structures describing request and response for handshake request (see XRootD specification).
Package locate contains the types related to the locate request.
Package locate contains the types related to the locate request.
Package login contains the structures describing request and response for login request.
Package login contains the structures describing request and response for login request.
Package mkdir contains the structures describing mkdir request.
Package mkdir contains the structures describing mkdir request.
Package mv contains the structures describing mv request.
Package mv contains the structures describing mv request.
Package open contains the structures describing request and response for open request.
Package open contains the structures describing request and response for open request.
Package ping contains the structures describing ping request.
Package ping contains the structures describing ping request.
Package prepare contains the types related to the prepare request.
Package prepare contains the types related to the prepare request.
Package protocol contains the structures describing request and response for protocol request (see XRootD specification).
Package protocol contains the structures describing request and response for protocol request (see XRootD specification).
Package query contains the types related to the query request.
Package query contains the types related to the query request.
Package read contains the structures describing request and response for read request.
Package read contains the structures describing request and response for read request.
Package rm contains the structures describing rm request.
Package rm contains the structures describing rm request.
Package rmdir contains the structures describing rmdir request.
Package rmdir contains the structures describing rmdir request.
Package signing contains implementation of a way to check if request should be signed according to XRootD protocol specification v.
Package signing contains implementation of a way to check if request should be signed according to XRootD protocol specification v.
Package sigver contains the structures describing sigver request.
Package sigver contains the structures describing sigver request.
Package stat contains the structures describing request and response for stat request.
Package stat contains the structures describing request and response for stat request.
Package statx contains the structures describing request and response for statx request.
Package statx contains the structures describing request and response for statx request.
Package sync contains the structures describing sync request.
Package sync contains the structures describing sync request.
Package truncate contains the structures describing truncate request.
Package truncate contains the structures describing truncate request.
Package verifyw contains the structures describing verifyw request.
Package verifyw contains the structures describing verifyw request.
Package write contains the structures describing write request.
Package write contains the structures describing write request.
Package xrdclose contains the structures describing request and response for close request.
Package xrdclose contains the structures describing request and response for close request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL