/* Hey Emacs use -*- mode: C -*- */
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * 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.
 */

option version = "2.0.0";

/*
 * Define services not following the normal conventions here
 */
service {
  rpc memclnt_rx_thread_suspend returns null;
  rpc memclnt_read_timeout returns null;
  rpc rx_thread_exit returns null;
  rpc trace_plugin_msg_ids returns null;
};

/*
 * Create a client registration 
 */
manual_print 
define memclnt_create {
    u32 context;                /* opaque value to be returned in the reply */
    i32 ctx_quota;              /* requested punt context quota */
    u64 input_queue;            /* client's queue */
    u8 name[64];                /* for show, find by name, whatever */
    u32 api_versions[8];        /* client-server pairs use as desired */
};

define memclnt_create_reply {
    u32 context;                /* opaque value from the create request */
    i32 response;               /* Non-negative = success */
    u64 handle;                 /* handle by which vlib knows this client */
    u32 index;                  /* index, used e.g. by API trace replay */
    u64 message_table;          /* serialized message table in shmem */
};

/*
 * Delete a client registration 
 */
manual_print
define memclnt_delete {
    u32 index;                  /* index, used e.g. by API trace replay */
    u64 handle;               /* handle by which vlib knows this client */
};

define memclnt_delete_reply {
    i32 response;               /* Non-negative = success */
    u64 handle;               /* in case the client wonders */
};

/*
 * Client RX thread exit
 */
define rx_thread_exit {
    u8 dummy;
};

/*
 * Client RX thread suspend
 */
define memclnt_rx_thread_suspend {
    u8 dummy;
};

/*
 * Client read timeout
 */
define memclnt_read_timeout {
    u8 dummy;
};

/*
 * RPC
 */
autoreply define rpc_call {
    u32 client_index;
    u32 context;
    u64 function;
    u8 multicast;
    u8 need_barrier_sync;
    u8 send_reply;
    u32 data_len;
    u8 data[data_len];
};

/*
 * Lookup message-ID base by name
 */
define get_first_msg_id {
    u32 client_index;
    u32 context;
    u8 name[64];
};

define get_first_msg_id_reply {
    u32 context;
    i32 retval;
    u16 first_msg_id;
};

/*
 * Get API version table (includes built-in and plugins)
 */
typeonly define module_version {
  u32 major;
  u32 minor;
  u32 patch;
  u8 name[64];
};
define api_versions {
  u32 client_index;
  u32 context;
};
define api_versions_reply {
  u32 context;
  i32 retval;
  u32 count;
  vl_api_module_version_t api_versions[count];
};

/*
 * Trace the plugin message-id allocator
 * so we stand a chance of dealing with different sets of plugins
 * at api trace replay time
 */

manual_print define trace_plugin_msg_ids
{
    u32 client_index;
    u32 context;
    u8 plugin_name[128];
    u16 first_msg_id;
    u16 last_msg_id;
};

typedef message_table_entry
{
  u16 index;
  u8 name[64];
};

/*
 * Create a socket client registration. 
 */
define sockclnt_create {
    u32 context;                /* opaque value to be returned in the reply */
    u8 name[64];                /* for show, find by name, whatever */
};

define sockclnt_create_reply {
    u32 client_index;
    u32 context;                /* opaque value from the create request */
    i32 response;               /* Non-negative = success */
    u32 index;                  /* index, used e.g. by API trace replay */
    u16 count;
    vl_api_message_table_entry_t message_table[count];
};

/*
 * Delete a client registration 
 */
define sockclnt_delete {
    u32 client_index;
    u32 context;
    u32 index;                  /* index, used e.g. by API trace replay */
};

define sockclnt_delete_reply {
    u32 context;
    i32 response;               /* Non-negative = success */
};

/*
 * Initialize shm api over socket api
 */
autoreply define sock_init_shm {
    u32 client_index;
    u32 context;
    u32 requested_size;
    u8 nitems;
    u64 configs[nitems];
};

/* define sock_init_shm_reply {
    u32 client_index;
    u32 context;
    i32 retval;
}; */

/*
 * Memory client ping / response
 * Only sent on inactive connections
 */
autoreply define memclnt_keepalive
{
  u32 client_index;
  u32 context;
};
