CUBRID Engine  latest
cas_network.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <poll.h>
#include "porting.h"
#include "cas_common.h"
#include "cas_network.h"
#include "cas.h"
#include "broker_env_def.h"
#include "cas_execute.h"
#include "error_code.h"
#include "broker_util.h"

Go to the source code of this file.

Macros

#define SELECT_MASK   fd_set
 
#define READ_FROM_NET(sd, buf, size)
 
#define WRITE_TO_NET(sd, buf, size)
 

Functions

static int write_buffer (SOCKET sock_fd, const char *buf, int size)
 
static int read_buffer (SOCKET sock_fd, char *buf, int size)
 
static void set_net_timeout_flag (void)
 
static void unset_net_timeout_flag (void)
 
int cas_ssl_write (int sock_fd, const char *buf, int size)
 
int cas_ssl_read (int sock_fd, char *buf, int size)
 
bool is_ssl_data_ready (int sock_fd)
 
SOCKET net_init_env (char *port_name)
 
SOCKET net_connect_proxy (void)
 
SOCKET net_connect_client (SOCKET srv_sock_fd)
 
int net_write_stream (SOCKET sock_fd, const char *buf, int size)
 
int net_read_stream (SOCKET sock_fd, char *buf, int size)
 
int net_read_header (SOCKET sock_fd, MSG_HEADER *header)
 
int net_write_header (SOCKET sock_fd, MSG_HEADER *header)
 
void init_msg_header (MSG_HEADER *header)
 
int net_write_int (SOCKET sock_fd, int value)
 
int net_read_int (SOCKET sock_fd, int *value)
 
int net_decode_str (char *msg, int msg_size, char *func_code, void ***ret_argv)
 
int net_read_to_file (SOCKET sock_fd, int file_size, char *filename)
 
int net_write_from_file (SOCKET sock_fd, int file_size, char *filename)
 
void net_timeout_set (int timeout_sec)
 
bool is_net_timed_out (void)
 
void net_write_error (SOCKET sock, int version, char *driver_info, char *cas_info, int cas_info_size, int indicator, int code, char *msg)
 

Variables

static bool net_timeout_flag = false
 
static char net_error_flag
 
static int net_timeout = NET_DEFAULT_TIMEOUT
 
bool ssl_client
 
SOCKET new_req_sock_fd
 

Macro Definition Documentation

#define READ_FROM_NET (   sd,
  buf,
  size 
)
Value:
ssl_client ? cas_ssl_read (sd, buf, size) : \
READ_FROM_SOCKET(sd, buf, size)
#define READ_FROM_SOCKET(fd, buf, size)
Definition: cas_common.h:141
int cas_ssl_read(int sock_fd, char *buf, int size)
Definition: cas_ssl.c:202
bool ssl_client
Definition: cas_ssl.c:81

Definition at line 81 of file cas_network.c.

Referenced by read_buffer().

#define SELECT_MASK   fd_set
#define WRITE_TO_NET (   sd,
  buf,
  size 
)
Value:
ssl_client ? cas_ssl_write (sd, buf, size) : \
WRITE_TO_SOCKET(sd, buf, size)
#define WRITE_TO_SOCKET(fd, buf, size)
Definition: cas_common.h:142
bool ssl_client
Definition: cas_ssl.c:81
int cas_ssl_write(int sock_fd, const char *buf, int size)
Definition: cas_ssl.c:234

Definition at line 83 of file cas_network.c.

Referenced by write_buffer().

Function Documentation

int cas_ssl_read ( int  sock_fd,
char *  buf,
int  size 
)
int cas_ssl_write ( int  sock_fd,
const char *  buf,
int  size 
)
void init_msg_header ( MSG_HEADER header)

Definition at line 358 of file cas_network.c.

Referenced by cas_register_to_proxy(), and process_request().

Here is the caller graph for this function:

bool is_net_timed_out ( void  )

Definition at line 699 of file cas_network.c.

References net_timeout_flag.

Referenced by net_read_header_keep_con_on(), net_read_int_keep_con_auto(), net_read_process(), net_read_stream(), and process_request().

Here is the caller graph for this function:

bool is_ssl_data_ready ( int  sock_fd)

Definition at line 301 of file cas_ssl.c.

References ssl.

Referenced by read_buffer().

Here is the caller graph for this function:

SOCKET net_connect_client ( SOCKET  srv_sock_fd)

Definition at line 260 of file cas_network.c.

References INVALID_SOCKET, IS_INVALID_SOCKET, and net_error_flag.

Referenced by cas_main().

Here is the caller graph for this function:

int net_decode_str ( char *  msg,
int  msg_size,
char *  func_code,
void ***  ret_argv 
)

Definition at line 393 of file cas_network.c.

Referenced by process_request(), and proxy_handler_process_client_request().

Here is the caller graph for this function:

SOCKET net_init_env ( char *  port_name)

Definition at line 90 of file cas_network.c.

References CLOSE_SOCKET, htons(), INVALID_SOCKET, IS_INVALID_SOCKET, net_connect_proxy(), ntohs(), proxy_id, sock_addr_len, sock_fd, strlen, and wsa_initialize().

Referenced by cas_main().

Here is the caller graph for this function:

int net_read_header ( SOCKET  sock_fd,
MSG_HEADER header 
)
int net_read_int ( SOCKET  sock_fd,
int *  value 
)

Definition at line 383 of file cas_network.c.

References net_read_stream(), and ntohl().

Referenced by cas_main().

Here is the caller graph for this function:

int net_read_stream ( SOCKET  sock_fd,
char *  buf,
int  size 
)

Definition at line 305 of file cas_network.c.

References is_net_timed_out(), and read_buffer().

Referenced by cas_main(), net_read_header(), net_read_int(), and process_request().

Here is the caller graph for this function:

int net_read_to_file ( SOCKET  sock_fd,
int  file_size,
char *  filename 
)
void net_timeout_set ( int  timeout_sec)

Definition at line 519 of file cas_network.c.

References net_timeout, and new_req_sock_fd.

Referenced by cas_main(), net_read_header_keep_con_on(), net_read_int_keep_con_auto(), net_read_process(), process_request(), and shard_cas_main().

Here is the caller graph for this function:

void net_write_error ( SOCKET  sock,
int  version,
char *  driver_info,
char *  cas_info,
int  cas_info_size,
int  indicator,
int  code,
char *  msg 
)
int net_write_from_file ( SOCKET  sock_fd,
int  file_size,
char *  filename 
)

Definition at line 482 of file cas_network.c.

References net_write_stream().

Referenced by process_request().

Here is the caller graph for this function:

int net_write_header ( SOCKET  sock_fd,
MSG_HEADER header 
)

Definition at line 347 of file cas_network.c.

References MSG_HEADER::buf, htonl(), MSG_HEADER::msg_body_size_ptr, MSG_HEADER_SIZE, and net_write_stream().

Referenced by cas_register_to_proxy().

Here is the caller graph for this function:

int net_write_int ( SOCKET  sock_fd,
int  value 
)

Definition at line 375 of file cas_network.c.

References htonl(), and write_buffer().

Referenced by cas_main(), cas_register_to_proxy(), and net_write_error().

Here is the caller graph for this function:

int net_write_stream ( SOCKET  sock_fd,
const char *  buf,
int  size 
)

Definition at line 283 of file cas_network.c.

References write_buffer().

Referenced by cas_main(), cas_register_to_proxy(), cas_send_connect_reply_to_driver(), net_write_error(), net_write_from_file(), net_write_header(), and process_request().

Here is the caller graph for this function:

static int read_buffer ( SOCKET  sock_fd,
char *  buf,
int  size 
)
static
static void set_net_timeout_flag ( void  )
static

Definition at line 705 of file cas_network.c.

References net_timeout_flag.

Referenced by read_buffer().

Here is the caller graph for this function:

static void unset_net_timeout_flag ( void  )
static

Definition at line 711 of file cas_network.c.

References net_timeout_flag.

Referenced by read_buffer().

Here is the caller graph for this function:

static int write_buffer ( SOCKET  sock_fd,
const char *  buf,
int  size 
)
static

Definition at line 616 of file cas_network.c.

References CUB_MAXHOSTNAMELEN, get_host_ip(), IS_INVALID_SOCKET, net_error_flag, net_timeout, NULL, sock_fd, and WRITE_TO_NET.

Referenced by dwb_initialize_block(), net_write_int(), and net_write_stream().

Here is the caller graph for this function:

Variable Documentation

char net_error_flag
static

Definition at line 73 of file cas_network.c.

Referenced by net_connect_client(), net_connect_proxy(), read_buffer(), and write_buffer().

int net_timeout = NET_DEFAULT_TIMEOUT
static

Definition at line 74 of file cas_network.c.

Referenced by net_timeout_set(), read_buffer(), and write_buffer().

bool net_timeout_flag = false
static

Definition at line 71 of file cas_network.c.

Referenced by is_net_timed_out(), set_net_timeout_flag(), and unset_net_timeout_flag().

SOCKET new_req_sock_fd

Definition at line 174 of file cas.c.

Referenced by net_read_int_keep_con_auto(), net_timeout_set(), and read_buffer().

bool ssl_client

Definition at line 81 of file cas_ssl.c.

Referenced by read_buffer().