2017-09-04 09:00:48 +03:00
/*
CTDB protocol marshalling
Copyright ( C ) Amitay Isaacs 2015
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef __CTDB_PROTOCOL_UTIL_H__
# define __CTDB_PROTOCOL_UTIL_H__
# include <talloc.h>
# include "protocol/protocol.h"
const char * ctdb_runstate_to_string ( enum ctdb_runstate runstate ) ;
enum ctdb_runstate ctdb_runstate_from_string ( const char * runstate_str ) ;
const char * ctdb_event_to_string ( enum ctdb_event event ) ;
enum ctdb_event ctdb_event_from_string ( const char * event_str ) ;
2017-06-30 08:11:04 +03:00
/*
2017-09-11 08:00:10 +03:00
* buflen must be long enough to hold the longest possible " address:port " .
* For example , 1122 : 3344 : 5566 : 7788 : 99 aa : bbcc : ddee : ff00 : 12345.
2017-06-30 08:11:04 +03:00
* 64 is sane value for buflen .
*/
2017-09-11 08:00:10 +03:00
int ctdb_sock_addr_to_buf ( char * buf , socklen_t buflen ,
ctdb_sock_addr * addr , bool with_port ) ;
const char * ctdb_sock_addr_to_string ( TALLOC_CTX * mem_ctx ,
ctdb_sock_addr * addr , bool with_port ) ;
2017-09-11 09:39:38 +03:00
int ctdb_sock_addr_from_string ( const char * str ,
ctdb_sock_addr * addr , bool with_port ) ;
2018-06-08 00:13:25 +03:00
int ctdb_sock_addr_mask_from_string ( const char * str ,
ctdb_sock_addr * addr ,
unsigned int * mask ) ;
2017-06-02 09:17:22 +03:00
unsigned int ctdb_sock_addr_port ( ctdb_sock_addr * addr ) ;
void ctdb_sock_addr_set_port ( ctdb_sock_addr * addr , unsigned int port ) ;
2017-09-04 09:00:48 +03:00
int ctdb_sock_addr_cmp_ip ( const ctdb_sock_addr * addr1 ,
const ctdb_sock_addr * addr2 ) ;
int ctdb_sock_addr_cmp ( const ctdb_sock_addr * addr1 ,
const ctdb_sock_addr * addr2 ) ;
bool ctdb_sock_addr_same_ip ( const ctdb_sock_addr * addr1 ,
const ctdb_sock_addr * addr2 ) ;
bool ctdb_sock_addr_same ( const ctdb_sock_addr * addr1 ,
const ctdb_sock_addr * addr2 ) ;
2017-09-04 09:41:30 +03:00
int ctdb_connection_to_buf ( char * buf , size_t buflen ,
struct ctdb_connection * conn , bool client_first ) ;
const char * ctdb_connection_to_string ( TALLOC_CTX * mem_ctx ,
struct ctdb_connection * conn ,
bool client_first ) ;
int ctdb_connection_from_string ( const char * str , bool client_first ,
struct ctdb_connection * conn ) ;
2017-09-04 10:01:05 +03:00
int ctdb_connection_list_add ( struct ctdb_connection_list * conn_list ,
struct ctdb_connection * conn ) ;
int ctdb_connection_list_sort ( struct ctdb_connection_list * conn_list ) ;
const char * ctdb_connection_list_to_string (
TALLOC_CTX * mem_ctx ,
struct ctdb_connection_list * conn_list , bool client_first ) ;
2018-07-18 12:00:42 +03:00
int ctdb_connection_list_read ( TALLOC_CTX * mem_ctx ,
int fd ,
bool client_first ,
2017-09-04 10:01:05 +03:00
struct ctdb_connection_list * * conn_list ) ;
2017-09-04 09:00:48 +03:00
# endif /* __CTDB_PROTOCOL_UTIL_H__ */