/* 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 convetions 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 client_index;
    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 client_index;
  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;
};

/*
 * 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 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 */
};

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

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

/*
 * 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;
};
