/*
 *------------------------------------------------------------------
 * api.h
 *
 * Copyright (c) 2009 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.
 *------------------------------------------------------------------
 */

#ifndef included_vlibsocket_api_h
#define included_vlibsocket_api_h

#include <vlibapi/api.h>

typedef struct
{
  /* Server port number */
  int portno;

  /* By default, localhost... */
  u32 bind_address;

  /*
   * (listen, server, client) registrations. Shared memory
   * registrations are in shared memory
   */
  vl_api_registration_t *registration_pool;
  /*
   * Chain-drag variables, so message API handlers
   * (generally) don't know whether they're talking to a socket
   * or to a shared-memory connection.
   */
  vl_api_registration_t *current_rp;
  unix_file_t *current_uf;
  /* One input buffer, shared across all sockets */
  i8 *input_buffer;
} socket_main_t;

extern socket_main_t socket_main;

void socksvr_add_pending_output (struct unix_file *uf,
				 struct vl_api_registration_ *cf,
				 u8 * buffer, uword buffer_bytes);

#define SOCKSVR_DEFAULT_PORT 32741	/* whatever */

void vl_free_socket_registration_index (u32 pool_index);
void vl_socket_process_msg (struct unix_file *uf,
			    struct vl_api_registration_ *rp, i8 * input_v);
clib_error_t *vl_socket_read_ready (struct unix_file *uf);
void vl_socket_add_pending_output (struct unix_file *uf,
				   struct vl_api_registration_ *rp,
				   u8 * buffer, uword buffer_bytes);
clib_error_t *vl_socket_write_ready (struct unix_file *uf);
void vl_socket_api_send (vl_api_registration_t * rp, u8 * elem);
void vl_socket_api_send_with_data (vl_api_registration_t * rp,
				   u8 * elem, u8 * data_vector);
void vl_socket_api_send_with_length (vl_api_registration_t * rp,
				     u8 * elem, u32 msg_length);
void vl_socket_api_send_with_length_no_free (vl_api_registration_t * rp,
					     u8 * elem, u32 msg_length);
u32 sockclnt_open_index (char *client_name, char *hostname, int port);
void sockclnt_close_index (u32 index);
void vl_client_msg_api_send (vl_api_registration_t * cm, u8 * elem);
vl_api_registration_t *sockclnt_get_registration (u32 index);
void socksvr_set_port (u16 port);
void socksvr_set_bind_address (u32 bind_address);

#endif /* included_vlibsocket_api_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
