/* ========================= eCAL LICENSE =================================
 *
 * Copyright (C) 2016 - 2019 Continental Corporation
 *
 * 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
 * 
 *      http://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.
 *
 * ========================= eCAL LICENSE =================================
*/

syntax = "proto3";

package eCAL.pb;

message ServiceHeader
{
  enum eCallState
  {
    none     = 0;
    executed = 1;
    failed   = 2;
  }

  string           hname       =  1;  // host name
  string           sname       =  2;  // service name
  string           sid         =  7;  // service id
  string           mname       =  3;  // method name
  string           error       =  4;  // error message
  int32            id          =  5;  // session id
  eCallState       state       =  6;  // method call state
}

message Request                       // client request
{
  ServiceHeader    header      =  1;  // common service header
  bytes            request     =  2;  // request payload
}

message Response                      // server response
{
  ServiceHeader    header      =  1;  // common service header
  bytes            response    =  2;  // response payload
  int64            ret_state   =  3;  // callback return state
}

message Method                        // method
{
  string           mname       =  1;  // method name
  string           req_type    =  2;  // request type
  bytes            req_desc    =  5;  // request descriptor
  string           resp_type   =  3;  // response type
  bytes            resp_desc   =  6;  // response descriptor
  int64            call_count  =  4;  // call counter
}

message Service                       // service
{
  int32            rclock      =  1;  // registration clock
  string           hname       =  2;  // host name
  string           pname       =  3;  // process name
  string           uname       =  4;  // unit name
  int32            pid         =  5;  // process id
  string           sname       =  6;  // service name
  string           sid         =  9;  // service id
  repeated Method  methods     =  8;  // list of methods

  // transport specific parameter (for internal use)
  uint32           version     = 10;  // service protocol version
  uint32           tcp_port_v0 =  7;  // the tcp port used for that service
  uint32           tcp_port_v1 = 11;  // the tcp port used for that service
}

message Client                        // client
{
  int32            rclock      =  1;  // registration clock
  string           hname       =  2;  // host name
  string           pname       =  3;  // process name
  string           uname       =  4;  // unit name
  int32            pid         =  5;  // process id
  string           sname       =  6;  // service name
  string           sid         =  7;  // service id

  // transport specific parameter (for internal use)
  uint32           version     =  8;  // client protocol version
}
