1// Copyright 2020 The Pigweed Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); you may not 4// use this file except in compliance with the License. You may obtain a copy of 5// the License at 6// 7// https://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, WITHOUT 11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12// License for the specific language governing permissions and limitations under 13// the License. 14syntax = "proto3"; 15 16package pw.rpc.internal; 17 18option java_package = "dev.pigweed.pw_rpc.internal"; 19 20enum PacketType { 21 // To simplify identifying the origin of a packet, client-to-server packets 22 // use even numbers and server-to-client packets use odd numbers. 23 24 // Client-to-server packets 25 26 // The client invokes an RPC. Always the first packet. 27 REQUEST = 0; 28 29 // A message in a client stream. Always sent after a REQUEST and before a 30 // CLIENT_STREAM_END. 31 CLIENT_STREAM = 2; 32 33 // The client received a packet for an RPC it did not request. 34 CLIENT_ERROR = 4; 35 36 // Deprecated, do not use. Send a CLIENT_ERROR with status CANCELLED instead. 37 // TODO(pwbug/512): Remove this packet type. 38 DEPRECATED_CANCEL = 6; 39 40 // A client stream has completed. 41 CLIENT_STREAM_END = 8; 42 43 // Server-to-client packets 44 45 // The RPC has finished. 46 RESPONSE = 1; 47 48 // Deprecated, do not use. Formerly was used as the last packet in a server 49 // stream. 50 // TODO(pwbug/512): Remove this packet type. 51 DEPRECATED_SERVER_STREAM_END = 3; 52 53 // The server was unable to process a request. 54 SERVER_ERROR = 5; 55 56 // A message in a server stream. 57 SERVER_STREAM = 7; 58} 59 60message RpcPacket { 61 // The type of packet. Determines which other fields are used. 62 PacketType type = 1; 63 64 // Channel through which the packet is sent. 65 uint32 channel_id = 2; 66 67 // Hash of the fully-qualified name of the service with which this packet is 68 // associated. For RPC packets, this is the service that processes the packet. 69 fixed32 service_id = 3; 70 71 // Hash of the name of the method which should process this packet. 72 fixed32 method_id = 4; 73 74 // The packet's payload, which is an encoded protobuf. 75 bytes payload = 5; 76 77 // Status code for the RPC response or error. 78 uint32 status = 6; 79 80 // Unique identifier for the call that initiated this RPC. Optionally set by 81 // the client in the initial request and sent in all subsequent client 82 // packets; echoed by the server. 83 uint32 call_id = 7; 84} 85