diff --git a/connections/implementation/proto/offline_wire_formats.proto b/connections/implementation/proto/offline_wire_formats.proto index b93c47b7..a60d339c 100644 --- a/connections/implementation/proto/offline_wire_formats.proto +++ b/connections/implementation/proto/offline_wire_formats.proto @@ -119,6 +119,11 @@ message ConnectionResponseFrame { } optional ResponseStatus response = 3; optional OsInfo os_info = 4; + // A bitmask value to indicate which medium supports Multiplex transmission + // feature. Each supporting medium could utilize one bit starting from the + // least significant bit in this field. Refer to ClientProxy.java for the bit + // usages. + optional int32 multiplex_socket_bitmask = 5; } message PayloadTransferFrame { diff --git a/proto/errorcode/error_code_enums.proto b/proto/errorcode/error_code_enums.proto index 3b328b79..120566b5 100644 --- a/proto/errorcode/error_code_enums.proto +++ b/proto/errorcode/error_code_enums.proto @@ -563,4 +563,12 @@ enum Description { FEATURE_USB_HOST_NOT_SUPPORTED = 177; FEATURE_USB_ACCESSORY_NOT_SUPPORTED = 178; FEATURE_USB_PORTS_NOT_FOUND = 179; + MULTIPLEX_SOCKET_UNKNOWN_ERROR = 180; + MULTIPLEX_SOCKET_NOT_LISTENING = 181; + MULTIPLEX_SOCKET_DISABLED = 182; + MULTIPLEX_SOCKET_TIMEOUT = 183; + MULTIPLEX_SOCKET_IOEXCEPTION = 184; + MULTIPLEX_SOCKET_UNKNOWN_RESPONSE_CODE = 185; + MULTIPLEX_SOCKET_EXECUTION_EXCEPTION = 186; + MULTIPLEX_SOCKET_INTERRUPTED_EXCEPTION = 187; } diff --git a/proto/mediums/BUILD b/proto/mediums/BUILD index 7e8acaaf..9f917770 100644 --- a/proto/mediums/BUILD +++ b/proto/mediums/BUILD @@ -16,6 +16,13 @@ licenses(["notice"]) package(default_visibility = ["//visibility:public"]) +proto_library( + name = "multiplex_frames_proto", + srcs = [ + "multiplex_frames.proto", + ], +) + proto_library( name = "nfc_frames_proto", srcs = [ diff --git a/proto/mediums/multiplex_frames.proto b/proto/mediums/multiplex_frames.proto new file mode 100644 index 00000000..5eb09b15 --- /dev/null +++ b/proto/mediums/multiplex_frames.proto @@ -0,0 +1,84 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package location.nearby.mediums; + +option optimize_for = LITE_RUNTIME; +option java_outer_classname = "MultiplexFramesProto"; +option java_package = "com.google.location.nearby.mediums.proto"; +option objc_class_prefix = "GNCM"; + +// The frame used to transmit any type of frame on a virtual socket. +message MultiplexFrame { + enum MultiplexFrameType { + UNKNOWN_FRAME_TYPE = 0; + CONTROL_FRAME = 1; + DATA_FRAME = 2; + } + + optional MultiplexFrameHeader header = 1; + optional MultiplexFrameType frame_type = 2; + oneof Frame { + MultiplexControlFrame control_frame = 3; + MultiplexDataFrame data_frame = 4; + } +} + +message MultiplexFrameHeader { + optional bytes service_id_hash = 1; +} + +// The control frame to establish, accept, reject or disconnect the virtual +// socket. +message MultiplexControlFrame { + enum MultiplexControlFrameType { + UNKNOWN_CONTROL_FRAME_TYPE = 0; + CONNECTION_REQUEST = 1; + CONNECTION_RESPONSE = 2; + DISCONNECTION = 3; + } + + optional MultiplexControlFrameType control_frame_type = 1; + + // Exactly one of the following fields will be set. + oneof Frame { + ConnectionRequestFrame connection_request_frame = 2; + ConnectionResponseFrame connection_response_frame = 3; + DisconnectFrame disconnect_frame = 4; + } +} + +// The frame to request a virtual socket for the service ID. +message ConnectionRequestFrame {} + +// The frame to accept or reject the CONNECTION_REQUEST. +message ConnectionResponseFrame { + enum ConnectionResponseCode { + UNKNOWN_RESPONSE_CODE = 0; + CONNECTION_ACCEPTED = 1; + NOT_LISTENING = 2; + } + + optional ConnectionResponseCode connection_response_code = 1; +} + +// The frame to disconnect the virtual socket. +message DisconnectFrame {} + +// The data frame used to transmit the data type bytes on a virtual socket. +message MultiplexDataFrame { + optional bytes data = 1; +}