|
Packit Service |
e080da |
/*
|
|
Packit Service |
e080da |
Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
|
|
Packit Service |
e080da |
This file is part of GlusterFS.
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
This file is licensed to you under your choice of the GNU Lesser
|
|
Packit Service |
e080da |
General Public License, version 3 or any later version (LGPLv3 or
|
|
Packit Service |
e080da |
later), or the GNU General Public License, version 2 (GPLv2), in all
|
|
Packit Service |
e080da |
cases as published by the Free Software Foundation.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#ifndef __RPC_TRANSPORT_H__
|
|
Packit Service |
e080da |
#define __RPC_TRANSPORT_H__
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#include <inttypes.h>
|
|
Packit Service |
e080da |
#ifdef GF_SOLARIS_HOST_OS
|
|
Packit Service |
e080da |
#include <rpc/auth.h>
|
|
Packit Service |
e080da |
#else
|
|
Packit Service |
e080da |
#include <rpc/rpc.h>
|
|
Packit Service |
e080da |
#endif
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#include <rpc/rpc_msg.h>
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#ifndef MAX_IOVEC
|
|
Packit Service |
e080da |
#define MAX_IOVEC 16
|
|
Packit Service |
e080da |
#endif
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#ifndef AI_ADDRCONFIG
|
|
Packit Service |
e080da |
#define AI_ADDRCONFIG 0
|
|
Packit Service |
e080da |
#endif /* AI_ADDRCONFIG */
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
/* Given the 4-byte fragment header, returns non-zero if this fragment
|
|
Packit Service |
e080da |
* is the last fragment for the RPC record being assembled.
|
|
Packit Service |
e080da |
* RPC Record marking standard defines a 32 bit value as the fragment
|
|
Packit Service |
e080da |
* header with the MSB signifying whether the fragment is the last
|
|
Packit Service |
e080da |
* fragment for the record being assembled.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
#define RPC_LASTFRAG(fraghdr) ((uint32_t)(fraghdr & 0x80000000U))
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
/* Given the 4-byte fragment header, extracts the bits that contain
|
|
Packit Service |
e080da |
* the fragment size.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
#define RPC_FRAGSIZE(fraghdr) ((uint32_t)(fraghdr & 0x7fffffffU))
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#define RPC_FRAGHDR_SIZE 4
|
|
Packit Service |
e080da |
#define RPC_MSGTYPE_SIZE 8
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
/* size of the msg from the start of call-body till and including credlen */
|
|
Packit Service |
e080da |
#define RPC_CALL_BODY_SIZE 24
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#define RPC_REPLY_STATUS_SIZE 4
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#define RPC_AUTH_FLAVOUR_N_LENGTH_SIZE 8
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#define RPC_ACCEPT_STATUS_LEN 4
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_ops;
|
|
Packit Service |
e080da |
typedef struct rpc_transport rpc_transport_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#include <glusterfs/dict.h>
|
|
Packit Service |
e080da |
#include <glusterfs/compat.h>
|
|
Packit Service |
e080da |
#include "rpcsvc-common.h"
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct peer_info {
|
|
Packit Service |
e080da |
// OP-VERSION of clients
|
|
Packit Service |
e080da |
uint32_t max_op_version;
|
|
Packit Service |
e080da |
uint32_t min_op_version;
|
|
Packit Service |
e080da |
struct sockaddr_storage sockaddr;
|
|
Packit Service |
e080da |
socklen_t sockaddr_len;
|
|
Packit Service |
e080da |
char identifier[UNIX_PATH_MAX];
|
|
Packit Service |
e080da |
// Volume mounted by client
|
|
Packit Service |
e080da |
char volname[NAME_MAX];
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct peer_info peer_info_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
typedef enum msg_type msg_type_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
typedef enum {
|
|
Packit Service |
e080da |
RPC_TRANSPORT_ACCEPT, /* New client has been accepted */
|
|
Packit Service |
e080da |
RPC_TRANSPORT_DISCONNECT, /* Connection is disconnected */
|
|
Packit Service |
e080da |
RPC_TRANSPORT_CLEANUP, /* connection is about to be freed */
|
|
Packit Service |
e080da |
/*RPC_TRANSPORT_READ,*/ /* An event used to enable rpcsvc to instruct
|
|
Packit Service |
e080da |
* transport the number of bytes to read.
|
|
Packit Service |
e080da |
* This helps in reading large msgs, wherein
|
|
Packit Service |
e080da |
* the rpc actors might decide to place the
|
|
Packit Service |
e080da |
* actor's payload in new iobufs separate
|
|
Packit Service |
e080da |
* from the rpc header, proghdr and
|
|
Packit Service |
e080da |
* authentication information. glusterfs/nfs
|
|
Packit Service |
e080da |
* read and write actors are few examples
|
|
Packit Service |
e080da |
* that might beniefit from this. While
|
|
Packit Service |
e080da |
* reading a single msg, this event may be
|
|
Packit Service |
e080da |
* delivered more than once.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
RPC_TRANSPORT_MAP_XID_REQUEST, /* receiver of this event should send
|
|
Packit Service |
e080da |
* the prognum and procnum corresponding
|
|
Packit Service |
e080da |
* to xid.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
RPC_TRANSPORT_MSG_RECEIVED, /* Complete rpc msg has been read */
|
|
Packit Service |
e080da |
RPC_TRANSPORT_CONNECT, /* client is connected to server */
|
|
Packit Service |
e080da |
RPC_TRANSPORT_MSG_SENT,
|
|
Packit Service |
e080da |
RPC_TRANSPORT_EVENT_THREAD_DIED /* event-thread has died */
|
|
Packit Service |
e080da |
} rpc_transport_event_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_msg {
|
|
Packit Service |
e080da |
struct iovec *rpchdr;
|
|
Packit Service |
e080da |
int rpchdrcount;
|
|
Packit Service |
e080da |
struct iovec *proghdr;
|
|
Packit Service |
e080da |
int proghdrcount;
|
|
Packit Service |
e080da |
struct iovec *progpayload;
|
|
Packit Service |
e080da |
int progpayloadcount;
|
|
Packit Service |
e080da |
struct iobref *iobref;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct rpc_transport_msg rpc_transport_msg_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_rsp {
|
|
Packit Service |
e080da |
struct iovec *rsphdr;
|
|
Packit Service |
e080da |
int rsphdr_count;
|
|
Packit Service |
e080da |
struct iovec *rsp_payload;
|
|
Packit Service |
e080da |
int rsp_payload_count;
|
|
Packit Service |
e080da |
struct iobref *rsp_iobref;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct rpc_transport_rsp rpc_transport_rsp_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_req {
|
|
Packit Service |
e080da |
struct rpc_req *rpc_req;
|
|
Packit Service |
e080da |
rpc_transport_msg_t msg;
|
|
Packit Service |
e080da |
rpc_transport_rsp_t rsp;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct rpc_transport_req rpc_transport_req_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_reply {
|
|
Packit Service |
e080da |
void *private;
|
|
Packit Service |
e080da |
rpc_transport_msg_t msg;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct rpc_transport_reply rpc_transport_reply_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_data {
|
|
Packit Service |
e080da |
union {
|
|
Packit Service |
e080da |
rpc_transport_req_t req;
|
|
Packit Service |
e080da |
rpc_transport_reply_t reply;
|
|
Packit Service |
e080da |
} data;
|
|
Packit Service |
e080da |
char is_request;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct rpc_transport_data rpc_transport_data_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
/* FIXME: prognum, procnum and progver are already present in
|
|
Packit Service |
e080da |
* rpc_request, hence these should be removed from request_info
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
struct rpc_request_info {
|
|
Packit Service |
e080da |
int prognum;
|
|
Packit Service |
e080da |
int progver;
|
|
Packit Service |
e080da |
int procnum;
|
|
Packit Service |
e080da |
void *rpc_req; /* struct rpc_req */
|
|
Packit Service |
e080da |
rpc_transport_rsp_t rsp;
|
|
Packit Service |
e080da |
uint32_t xid;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct rpc_request_info rpc_request_info_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_pollin {
|
|
Packit Service |
e080da |
int count;
|
|
Packit Service |
e080da |
void *private;
|
|
Packit Service |
e080da |
struct iobref *iobref;
|
|
Packit Service |
e080da |
struct iovec vector[MAX_IOVEC];
|
|
Packit Service |
e080da |
char is_reply;
|
|
Packit Service |
e080da |
char vectored;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
typedef struct rpc_transport_pollin rpc_transport_pollin_t;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
typedef int (*rpc_transport_notify_t)(rpc_transport_t *, void *mydata,
|
|
Packit Service |
e080da |
rpc_transport_event_t, void *data, ...);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport {
|
|
Packit Service |
e080da |
struct rpc_transport_ops *ops;
|
|
Packit Service |
e080da |
rpc_transport_t *listener; /* listener transport to which
|
|
Packit Service |
e080da |
* request for creation of this
|
|
Packit Service |
e080da |
* transport came from. valid only
|
|
Packit Service |
e080da |
* on server process.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
void *private;
|
|
Packit Service |
e080da |
struct _client *xl_private;
|
|
Packit Service |
e080da |
void *xl; /* Used for THIS */
|
|
Packit Service |
e080da |
void *mydata;
|
|
Packit Service |
e080da |
pthread_mutex_t lock;
|
|
Packit Service |
e080da |
gf_atomic_t refcount;
|
|
Packit Service |
e080da |
glusterfs_ctx_t *ctx;
|
|
Packit Service |
e080da |
dict_t *options;
|
|
Packit Service |
e080da |
char *name;
|
|
Packit Service |
e080da |
void *dnscache;
|
|
Packit Service |
e080da |
void *drc_client;
|
|
Packit Service |
e080da |
data_t *buf;
|
|
Packit Service |
e080da |
int32_t (*init)(rpc_transport_t *this);
|
|
Packit Service |
e080da |
void (*fini)(rpc_transport_t *this);
|
|
Packit Service |
e080da |
int (*reconfigure)(rpc_transport_t *this, dict_t *options);
|
|
Packit Service |
e080da |
rpc_transport_notify_t notify;
|
|
Packit Service |
e080da |
void *notify_data;
|
|
Packit Service |
e080da |
peer_info_t peerinfo;
|
|
Packit Service |
e080da |
peer_info_t myinfo;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
uint64_t total_bytes_read;
|
|
Packit Service |
e080da |
uint64_t total_bytes_write;
|
|
Packit Service |
e080da |
uint32_t xid; /* RPC/XID used for callbacks */
|
|
Packit Service |
e080da |
int32_t outstanding_rpc_count;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct list_head list;
|
|
Packit Service |
e080da |
int bind_insecure;
|
|
Packit Service |
e080da |
void *dl_handle; /* handle of dlopen() */
|
|
Packit Service |
e080da |
char *ssl_name;
|
|
Packit Service |
e080da |
dict_t *clnt_options; /* store options received from
|
|
Packit Service |
e080da |
* client */
|
|
Packit Service |
e080da |
/* connect_failed: saves the connect() syscall status as socket_t
|
|
Packit Service |
e080da |
* member holding connect() status can't be accessed by higher gfapi
|
|
Packit Service |
e080da |
* layer or in client management notification handler functions
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
gf_boolean_t connect_failed;
|
|
Packit Service |
e080da |
char notify_poller_death;
|
|
Packit Service |
e080da |
char poller_death_accept;
|
|
Packit Service |
e080da |
gf_atomic_t disconnect_progress;
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
struct rpc_transport_ops {
|
|
Packit Service |
e080da |
/* no need of receive op, msg will be delivered through an event
|
|
Packit Service |
e080da |
* notification
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
int32_t (*submit_request)(rpc_transport_t *this, rpc_transport_req_t *req);
|
|
Packit Service |
e080da |
int32_t (*submit_reply)(rpc_transport_t *this,
|
|
Packit Service |
e080da |
rpc_transport_reply_t *reply);
|
|
Packit Service |
e080da |
int32_t (*connect)(rpc_transport_t *this, int port);
|
|
Packit Service |
e080da |
int32_t (*listen)(rpc_transport_t *this);
|
|
Packit Service |
e080da |
int32_t (*disconnect)(rpc_transport_t *this, gf_boolean_t wait);
|
|
Packit Service |
e080da |
int32_t (*get_peername)(rpc_transport_t *this, char *hostname, int hostlen);
|
|
Packit Service |
e080da |
int32_t (*get_peeraddr)(rpc_transport_t *this, char *peeraddr, int addrlen,
|
|
Packit Service |
e080da |
struct sockaddr_storage *sa, socklen_t sasize);
|
|
Packit Service |
e080da |
int32_t (*get_myname)(rpc_transport_t *this, char *hostname, int hostlen);
|
|
Packit Service |
e080da |
int32_t (*get_myaddr)(rpc_transport_t *this, char *peeraddr, int addrlen,
|
|
Packit Service |
e080da |
struct sockaddr_storage *sa, socklen_t sasize);
|
|
Packit Service |
e080da |
int32_t (*throttle)(rpc_transport_t *this, gf_boolean_t onoff);
|
|
Packit Service |
e080da |
};
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_count(const char *transport_type);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_listen(rpc_transport_t *this);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_connect(rpc_transport_t *this, int port);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_disconnect(rpc_transport_t *this, gf_boolean_t wait);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_destroy(rpc_transport_t *this);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_notify(rpc_transport_t *this, rpc_transport_event_t event,
|
|
Packit Service |
e080da |
void *data, ...);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_submit_request(rpc_transport_t *this, rpc_transport_req_t *req);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_submit_reply(rpc_transport_t *this, rpc_transport_reply_t *reply);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
rpc_transport_t *
|
|
Packit Service |
e080da |
rpc_transport_load(glusterfs_ctx_t *ctx, dict_t *options, char *name);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
rpc_transport_t *
|
|
Packit Service |
e080da |
rpc_transport_ref(rpc_transport_t *trans);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_unref(rpc_transport_t *trans);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int
|
|
Packit Service |
e080da |
rpc_transport_register_notify(rpc_transport_t *trans, rpc_transport_notify_t,
|
|
Packit Service |
e080da |
void *mydata);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_get_peername(rpc_transport_t *this, char *hostname, int hostlen);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_get_peeraddr(rpc_transport_t *this, char *peeraddr, int addrlen,
|
|
Packit Service |
e080da |
struct sockaddr_storage *sa, size_t salen);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_get_myname(rpc_transport_t *this, char *hostname, int hostlen);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int32_t
|
|
Packit Service |
e080da |
rpc_transport_get_myaddr(rpc_transport_t *this, char *peeraddr, int addrlen,
|
|
Packit Service |
e080da |
struct sockaddr_storage *sa, size_t salen);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int
|
|
Packit Service |
e080da |
rpc_transport_throttle(rpc_transport_t *this, gf_boolean_t onoff);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
rpc_transport_pollin_t *
|
|
Packit Service |
e080da |
rpc_transport_pollin_alloc(rpc_transport_t *this, struct iovec *vector,
|
|
Packit Service |
e080da |
int count, struct iobuf *hdr_iobuf,
|
|
Packit Service |
e080da |
struct iobref *iobref, void *private);
|
|
Packit Service |
e080da |
void
|
|
Packit Service |
e080da |
rpc_transport_pollin_destroy(rpc_transport_pollin_t *pollin);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int
|
|
Packit Service |
e080da |
rpc_transport_keepalive_options_set(dict_t *options, int32_t interval,
|
|
Packit Service |
e080da |
int32_t time, int32_t timeout);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int
|
|
Packit Service |
173fb3 |
rpc_transport_unix_options_build(dict_t *options, char *filepath,
|
|
Packit Service |
e080da |
int frame_timeout);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
int
|
|
Packit Service |
173fb3 |
rpc_transport_inet_options_build(dict_t *options, const char *hostname,
|
|
Packit Service |
e080da |
int port, char *af);
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
void
|
|
Packit Service |
e080da |
rpc_transport_cleanup(rpc_transport_t *);
|
|
Packit Service |
e080da |
#endif /* __RPC_TRANSPORT_H__ */
|