X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=include%2Flibnfs-private.h;h=f153e35d9f063ac974bc2f56001e956880e79144;hb=d7c6e9aaa9df593e951e2f19106dcc71102e74f1;hp=c6a8820f6bcae2b5e10e00f4c56fc7bf3e1194e0;hpb=b077fdeb65aca9d9bc15fcd311372816d87dc213;p=deb_libnfs.git diff --git a/include/libnfs-private.h b/include/libnfs-private.h index c6a8820..f153e35 100644 --- a/include/libnfs-private.h +++ b/include/libnfs-private.h @@ -14,9 +14,48 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ -#include +#ifdef HAVE_CONFIG_H +#include "config.h" /* HAVE_SOCKADDR_STORAGE ? */ +#endif + +#include /* struct sockaddr_storage */ + +#include "libnfs-zdr.h" + +#ifndef HAVE_SOCKADDR_STORAGE +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(double)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { +#ifdef HAVE_SA_LEN + unsigned char ss_len; /* address length */ + unsigned char ss_family; /* address family */ +#else + unsigned short ss_family; +#endif + char __ss_pad1[_SS_PAD1SIZE]; + double __ss_align; /* force desired structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; +#endif + + +struct rpc_fragment { + struct rpc_fragment *next; + uint64_t size; + char *data; +}; + +#define RPC_CONTEXT_MAGIC 0xc6e46435 struct rpc_context { + uint32_t magic; int fd; int is_connected; @@ -25,7 +64,7 @@ struct rpc_context { rpc_cb connect_cb; void *connect_data; - AUTH *auth; + struct AUTH *auth; unsigned long xid; /* buffer used for encoding RPC PDU */ @@ -36,35 +75,42 @@ struct rpc_context { struct sockaddr_storage udp_src; struct rpc_pdu *waitpdu; - int inpos; - int insize; + uint32_t inpos; + uint32_t insize; char *inbuf; /* special fields for UDP, which can sometimes be BROADCASTed */ int is_udp; struct sockaddr *udp_dest; int is_broadcast; + + /* track the address we connect to so we can auto-reconnect on session failure */ + struct sockaddr_storage s; + int auto_reconnect; + + /* fragment reassembly */ + struct rpc_fragment *fragments; }; struct rpc_pdu { struct rpc_pdu *next; unsigned long xid; - XDR xdr; + ZDR zdr; - int written; + uint32_t written; struct rpc_data outdata; rpc_cb cb; void *private_data; - /* function to decode the xdr reply data and buffer to decode into */ - xdrproc_t xdr_decode_fn; - caddr_t xdr_decode_buf; - int xdr_decode_bufsize; + /* function to decode the zdr reply data and buffer to decode into */ + zdrproc_t zdr_decode_fn; + caddr_t zdr_decode_buf; + uint32_t zdr_decode_bufsize; }; -struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, xdrproc_t xdr_decode_fn, int xdr_bufsize); +struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, zdrproc_t zdr_decode_fn, int zdr_bufsize); void rpc_free_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu); int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu); int rpc_get_pdu_size(char *buf); @@ -74,7 +120,6 @@ void rpc_error_all_pdus(struct rpc_context *rpc, char *error); void rpc_set_error(struct rpc_context *rpc, char *error_string, ...); void nfs_set_error(struct nfs_context *nfs, char *error_string, ...); -struct rpc_context *nfs_get_rpc_context(struct nfs_context *nfs); const char *nfs_get_server(struct nfs_context *nfs); const char *nfs_get_export(struct nfs_context *nfs); @@ -84,3 +129,10 @@ int rpc_set_udp_destination(struct rpc_context *rpc, char *addr, int port, int i struct rpc_context *rpc_init_udp_context(void); struct sockaddr *rpc_get_recv_sockaddr(struct rpc_context *rpc); +void rpc_set_autoreconnect(struct rpc_context *rpc); +void rpc_unset_autoreconnect(struct rpc_context *rpc); + +int rpc_add_fragment(struct rpc_context *rpc, char *data, uint64_t size); +void rpc_free_all_fragments(struct rpc_context *rpc); + +const struct nfs_fh3 *nfs_get_rootfh(struct nfs_context *nfs);