github.com/metacubex/gvisor@v0.0.0-20240320004321-933faba989ec/pkg/sentry/seccheck/sinks/remote/wire/wire.go (about)

     1  // Copyright 2022 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package wire defines structs used in the wire format for the remote checker.
    16  package wire
    17  
    18  // CurrentVersion is the current wire and protocol version.
    19  const CurrentVersion = 1
    20  
    21  // HeaderStructSize size of header struct in bytes.
    22  const HeaderStructSize = 8
    23  
    24  // Header is used to describe the message being sent to the remote process.
    25  //
    26  //	0 --------- 16 ---------- 32 ----------- 64 -----------+
    27  //	| HeaderSize | MessageType | DroppedCount | Payload... |
    28  //	+---- 16 ----+---- 16 -----+----- 32 -----+------------+
    29  //
    30  // +marshal
    31  type Header struct {
    32  	// HeaderSize is the size of the header in bytes. The payload comes
    33  	// immediately after the header. The length is needed to allow the header to
    34  	// expand in the future without breaking remotes that do not yet understand
    35  	// the new fields.
    36  	HeaderSize uint16
    37  
    38  	// MessageType describes the payload. It must be one of the pb.MessageType
    39  	// values and determine how the payload is interpreted. This is more efficient
    40  	// than using protobuf.Any because Any uses the full protobuf name to identify
    41  	// the type.
    42  	MessageType uint16
    43  
    44  	// DroppedCount is the number of points that failed to be written and had to
    45  	// be dropped. It wraps around after max(uint32).
    46  	DroppedCount uint32
    47  }