gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/test/packetimpact/proto/posix_server.proto (about) 1 // Copyright 2020 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 syntax = "proto3"; 16 17 package posix_server; 18 19 message SockaddrIn { 20 int32 family = 1; 21 uint32 port = 2; 22 bytes addr = 3; 23 } 24 25 message SockaddrIn6 { 26 uint32 family = 1; 27 uint32 port = 2; 28 uint32 flowinfo = 3; 29 bytes addr = 4; 30 uint32 scope_id = 5; 31 } 32 33 message Sockaddr { 34 oneof sockaddr { 35 SockaddrIn in = 1; 36 SockaddrIn6 in6 = 2; 37 } 38 } 39 40 message Timeval { 41 int64 seconds = 1; 42 int64 microseconds = 2; 43 } 44 45 message SockOptVal { 46 oneof val { 47 bytes bytesval = 1; 48 int32 intval = 2; 49 Timeval timeval = 3; 50 } 51 } 52 53 // Request and Response pairs for each Posix service RPC call, sorted. 54 55 message AcceptRequest { 56 int32 sockfd = 1; 57 } 58 59 message AcceptResponse { 60 int32 fd = 1; 61 int32 errno_ = 2; // "errno" may fail to compile in c++. 62 Sockaddr addr = 3; 63 } 64 65 message BindRequest { 66 int32 sockfd = 1; 67 Sockaddr addr = 2; 68 } 69 70 message BindResponse { 71 int32 ret = 1; 72 int32 errno_ = 2; // "errno" may fail to compile in c++. 73 } 74 75 message CloseRequest { 76 int32 fd = 1; 77 } 78 79 message CloseResponse { 80 int32 ret = 1; 81 int32 errno_ = 2; // "errno" may fail to compile in c++. 82 } 83 84 message ConnectRequest { 85 int32 sockfd = 1; 86 Sockaddr addr = 2; 87 } 88 89 message ConnectResponse { 90 int32 ret = 1; 91 int32 errno_ = 2; // "errno" may fail to compile in c++. 92 } 93 94 message GetSockNameRequest { 95 int32 sockfd = 1; 96 } 97 98 message GetSockNameResponse { 99 int32 ret = 1; 100 int32 errno_ = 2; // "errno" may fail to compile in c++. 101 Sockaddr addr = 3; 102 } 103 104 message GetSockOptRequest { 105 int32 sockfd = 1; 106 int32 level = 2; 107 int32 optname = 3; 108 int32 optlen = 4; 109 enum SockOptType { 110 UNSPECIFIED = 0; 111 BYTES = 1; 112 INT = 2; 113 TIME = 3; 114 } 115 SockOptType type = 5; 116 } 117 118 message GetSockOptResponse { 119 int32 ret = 1; 120 int32 errno_ = 2; // "errno" may fail to compile in c++. 121 SockOptVal optval = 3; 122 } 123 124 message ListenRequest { 125 int32 sockfd = 1; 126 int32 backlog = 2; 127 } 128 129 message ListenResponse { 130 int32 ret = 1; 131 int32 errno_ = 2; // "errno" may fail to compile in c++. 132 } 133 134 // The events field is overloaded: when used for request, it is copied into the 135 // events field of posix struct pollfd; when used for response, it is filled by 136 // the revents field from the posix struct pollfd. 137 message PollFd { 138 int32 fd = 1; 139 uint32 events = 2; 140 } 141 142 message PollRequest { 143 repeated PollFd pfds = 1; 144 int32 timeout_millis = 2; 145 } 146 147 message PollResponse { 148 int32 ret = 1; 149 int32 errno_ = 2; // "errno" may fail to compile in c++. 150 repeated PollFd pfds = 3; 151 } 152 153 message SendRequest { 154 int32 sockfd = 1; 155 bytes buf = 2; 156 int32 flags = 3; 157 } 158 159 message SendResponse { 160 int32 ret = 1; 161 int32 errno_ = 2; // "errno" may fail to compile in c++. 162 } 163 164 message SendToRequest { 165 int32 sockfd = 1; 166 bytes buf = 2; 167 int32 flags = 3; 168 Sockaddr dest_addr = 4; 169 } 170 171 message SendToResponse { 172 int32 ret = 1; 173 int32 errno_ = 2; // "errno" may fail to compile in c++. 174 } 175 176 message SetNonblockingRequest { 177 int32 fd = 1; 178 bool nonblocking = 2; 179 } 180 181 message SetNonblockingResponse { 182 int32 ret = 1; 183 int32 errno_ = 2; // "errno" may fail to compile in c++. 184 // The failed fcntl cmd. 185 string cmd = 3; 186 } 187 188 message SetSockOptRequest { 189 int32 sockfd = 1; 190 int32 level = 2; 191 int32 optname = 3; 192 SockOptVal optval = 4; 193 } 194 195 message SetSockOptResponse { 196 int32 ret = 1; 197 int32 errno_ = 2; // "errno" may fail to compile in c++. 198 } 199 200 message SocketRequest { 201 int32 domain = 1; 202 int32 type = 2; 203 int32 protocol = 3; 204 } 205 206 message SocketResponse { 207 int32 fd = 1; 208 int32 errno_ = 2; // "errno" may fail to compile in c++. 209 } 210 211 message ShutdownRequest { 212 int32 fd = 1; 213 int32 how = 2; 214 } 215 216 message ShutdownResponse { 217 int32 ret = 1; 218 int32 errno_ = 2; // "errno" may fail to compile in c++. 219 } 220 221 message RecvRequest { 222 int32 sockfd = 1; 223 int32 len = 2; 224 int32 flags = 3; 225 } 226 227 message RecvResponse { 228 int32 ret = 1; 229 int32 errno_ = 2; // "errno" may fail to compile in c++. 230 bytes buf = 3; 231 } 232 233 service Posix { 234 // Call accept() on the DUT. 235 rpc Accept(AcceptRequest) returns (AcceptResponse); 236 // Call bind() on the DUT. 237 rpc Bind(BindRequest) returns (BindResponse); 238 // Call close() on the DUT. 239 rpc Close(CloseRequest) returns (CloseResponse); 240 // Call connect() on the DUT. 241 rpc Connect(ConnectRequest) returns (ConnectResponse); 242 // Call getsockname() on the DUT. 243 rpc GetSockName(GetSockNameRequest) returns (GetSockNameResponse); 244 // Call getsockopt() on the DUT. 245 rpc GetSockOpt(GetSockOptRequest) returns (GetSockOptResponse); 246 // Call listen() on the DUT. 247 rpc Listen(ListenRequest) returns (ListenResponse); 248 // Call poll() on the DUT. Only pollfds that have non-empty revents are 249 // returned, the only way to tie the response back to the original request 250 // is using the fd number. 251 rpc Poll(PollRequest) returns (PollResponse); 252 // Call send() on the DUT. 253 rpc Send(SendRequest) returns (SendResponse); 254 // Call sendto() on the DUT. 255 rpc SendTo(SendToRequest) returns (SendToResponse); 256 // Set/Clear O_NONBLOCK flag on the requested fd. This is needed because the 257 // operating system on DUT may have a different definition for O_NONBLOCK, it 258 // is not sound to assemble flags on testbench. 259 rpc SetNonblocking(SetNonblockingRequest) returns (SetNonblockingResponse); 260 // Call setsockopt() on the DUT. 261 rpc SetSockOpt(SetSockOptRequest) returns (SetSockOptResponse); 262 // Call socket() on the DUT. 263 rpc Socket(SocketRequest) returns (SocketResponse); 264 // Call shutdown() on the DUT. 265 rpc Shutdown(ShutdownRequest) returns (ShutdownResponse); 266 // Call recv() on the DUT. 267 rpc Recv(RecvRequest) returns (RecvResponse); 268 }