1
#ifndef __CL_COMMUNICATION_H
2
#define __CL_COMMUNICATION_H
4
/*___INFO__MARK_BEGIN__*/
5
/*************************************************************************
7
* The Contents of this file are made available subject to the terms of
8
* the Sun Industry Standards Source License Version 1.2
10
* Sun Microsystems Inc., March, 2001
13
* Sun Industry Standards Source License Version 1.2
14
* =================================================
15
* The contents of this file are subject to the Sun Industry Standards
16
* Source License Version 1.2 (the "License"); You may not use this file
17
* except in compliance with the License. You may obtain a copy of the
18
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
20
* Software provided under this License is provided on an "AS IS" basis,
21
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
22
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
23
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
24
* See the License for the specific provisions governing your rights and
25
* obligations concerning the Software.
27
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
29
* Copyright: 2001 by Sun Microsystems, Inc.
31
* All Rights Reserved.
33
************************************************************************/
34
/*___INFO__MARK_END__*/
36
#include "cl_data_types.h"
37
#include "cl_list_types.h"
38
#include "cl_xml_parsing.h"
39
#include "cl_connection_list.h"
41
#define CL_DEFINE_READ_TIMEOUT 30
42
#define CL_DEFINE_WRITE_TIMEOUT 30
43
#define CL_DEFINE_ACK_TIMEOUT 60
44
#define CL_DEFINE_MESSAGE_TIMEOUT 3600 /* default timeout for trashing received but not application fetched messages */
45
#define CL_DEFINE_GET_CLIENT_CONNECTION_DATA_TIMEOUT 60 /* default timeout for accepting a connection */
46
#define CL_DEFINE_DELETE_MESSAGES_TIMEOUT_AFTER_CCRM 60 /* default timeout for unread message deletion after connection shutdown */
47
#define CL_DEFINE_SYNCHRON_RECEIVE_TIMEOUT 60 /* default timeout for synchron send messages */
48
#define CL_DEFINE_CLIENT_CONNECTION_LIFETIME 600 /* Cut off connection when client is not active for this time */
49
#define CL_DEFINE_MESSAGE_DUP_LOG_TIMEOUT 30 /* timeout for marking duplicate application error messages */
52
#define CL_DEFINE_DATA_BUFFER_SIZE 1024 * 4 /* 4 KB buffer for reading/writing messages */
54
/* TODO: enable this when application code is not using u_short with client ids !!! */
55
#define CL_DEFINE_MAX_MESSAGE_ID 4294967295UL /* max unsigned long value for a 32 bit system */
57
#define CL_DEFINE_MAX_MESSAGE_ID 65535 /* max unsigned short value */
61
#define CL_MAXHOSTNAMELEN_LENGTH MAXHOSTNAMELEN
63
#define CL_MAXHOSTNAMELEN_LENGTH 256
67
int cl_com_compare_endpoints(cl_com_endpoint_t* endpoint1, cl_com_endpoint_t* endpoint2);
68
void cl_com_dump_endpoint(cl_com_endpoint_t* endpoint, const char* text);
70
int cl_com_endpoint_list_refresh(cl_raw_list_t* endpoint_list);
72
/* debug client functions */
73
int cl_com_add_debug_message(cl_com_connection_t* connection, const char* message, cl_com_message_t* ms);
75
int cl_com_gethostname(char **unique_hostname,struct in_addr *copy_addr,struct hostent **he_copy, int* system_error_value);
76
int cl_com_host_list_refresh(cl_raw_list_t* host_list);
77
int cl_com_cached_gethostbyname(const char *hostname, char **unique_hostname, struct in_addr *copy_addr,struct hostent **he_copy, int* system_error_value);
78
int cl_com_cached_gethostbyaddr( struct in_addr *addr, char **unique_hostname,struct hostent **he_copy,int* system_error_val );
79
char* cl_com_get_h_error_string(int h_error);
80
int cl_com_compare_hosts(const char* host1, const char* host2);
81
int cl_com_set_resolve_method(cl_host_resolve_method_t method, char* local_domain_name);
83
int cl_com_free_handle_statistic(cl_com_handle_statistic_t** statistic);
84
int cl_com_free_hostent(cl_com_hostent_t **hostent_p); /* CR check */
85
int cl_com_free_hostspec(cl_com_host_spec_t **hostspec);
86
int cl_com_print_host_info(cl_com_hostent_t *hostent_p ); /* CR check */
89
int cl_com_create_debug_client_setup(cl_debug_client_setup_t** new_setup,
90
cl_debug_client_t dc_mode,
91
cl_bool_t dc_dump_flag,
92
int dc_app_log_level);
94
int cl_com_free_debug_client_setup(cl_debug_client_setup_t** new_setup);
96
int cl_com_create_ssl_setup(cl_ssl_setup_t** new_setup,
97
cl_ssl_cert_mode_t ssl_cert_mode,
98
cl_ssl_method_t ssl_method,
99
char* ssl_CA_cert_pem_file,
100
char* ssl_CA_key_pem_file,
101
char* ssl_cert_pem_file,
102
char* ssl_key_pem_file,
104
char* ssl_reconnect_file,
106
unsigned long ssl_refresh_time,
108
cl_ssl_verify_func_t ssl_verify_func);
110
int cl_com_dup_ssl_setup(cl_ssl_setup_t** new_setup, cl_ssl_setup_t* source);
111
int cl_com_free_ssl_setup(cl_ssl_setup_t** del_setup);
113
const char* cl_com_get_framework_type(cl_com_connection_t* connection); /* CR check */
114
const char* cl_com_get_connection_type(cl_com_connection_t* connection); /* CR check */
115
const char* cl_com_get_service_handler_flag(cl_com_connection_t* connection); /* CR check */
116
const char* cl_com_get_data_write_flag(cl_com_connection_t* connection); /* CR check */
117
const char* cl_com_get_data_read_flag(cl_com_connection_t* connection); /* CR check */
118
const char* cl_com_get_connection_state(cl_com_connection_t* connection); /* CR check */
119
const char* cl_com_get_connection_sub_state(cl_com_connection_t* connection);
120
const char* cl_com_get_data_flow_type(cl_com_connection_t* connection); /* CR check */
122
/* This can be called by an signal handler to trigger abort of communications */
123
void cl_com_ignore_timeouts(cl_bool_t flag);
124
cl_bool_t cl_com_get_ignore_timeouts_flag(void);
127
/* message functions */
128
int cl_com_setup_message(cl_com_message_t** message, cl_com_connection_t* connection, cl_byte_t* data,unsigned long size, cl_xml_ack_type_t ack_type, unsigned long response_id, unsigned long tag); /* *message must be zero */
129
int cl_com_create_message(cl_com_message_t** message);
130
int cl_com_free_message(cl_com_message_t** message);
132
int cl_com_create_connection(cl_com_connection_t** connection);
134
int cl_com_free_connection(cl_com_connection_t** connection);
135
use cl_com_close_connection();
138
/* after this line are the main functions used by lib user */
139
/* ======================================================= */
142
int cl_com_connection_complete_accept(cl_com_connection_t* connection,
145
int cl_com_connection_complete_shutdown(cl_com_connection_t* connection);
148
int cl_com_open_connection(cl_com_connection_t* connection,
150
cl_com_endpoint_t* remote_endpoint,
151
cl_com_endpoint_t* local_endpoint); /* CR check */
153
int cl_com_close_connection(cl_com_connection_t** connection); /* CR check */
155
int cl_com_read_GMSH(cl_com_connection_t* connection, unsigned long *only_one_read);
156
int cl_com_read(cl_com_connection_t* connection, cl_byte_t* message, unsigned long size, unsigned long* only_one_read);
157
int cl_com_write(cl_com_connection_t* connection, cl_byte_t* message, unsigned long size, unsigned long *only_one_write);
161
/* This functions need service connection pointer = cl_com_connection_request_handler_setup */
162
/* ======================================================================================== */
164
int cl_com_connection_get_connect_port(cl_com_connection_t* connection, int* port);
165
int cl_com_connection_set_connect_port(cl_com_connection_t* connection, int port);
167
int cl_com_connection_get_service_port(cl_com_connection_t* connection, int* port);
168
int cl_com_connection_get_fd(cl_com_connection_t* connection, int* fd);
169
int cl_com_connection_get_client_socket_in_port(cl_com_connection_t* connection, int* port);
173
int cl_com_connection_request_handler_setup(cl_com_connection_t* connection,
174
cl_com_endpoint_t* local_endpoint );
176
/* check for new service connection clients */
177
int cl_com_connection_request_handler(cl_com_connection_t* connection,
178
cl_com_connection_t** new_connection);
179
/* cleanup service */
180
int cl_com_connection_request_handler_cleanup(cl_com_connection_t* connection);
182
/* check open connection list for new messages */
183
int cl_com_open_connection_request_handler(cl_com_handle_t* handle,
185
int timeout_val_usec,
186
cl_select_method_t select_mode );
188
int cl_com_connection_complete_request(cl_raw_list_t* connection_list, cl_connection_list_elem_t* elem, long timeout, cl_select_method_t select_mode );
191
#endif /* __CL_COMMUNICATION_H */