Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * linux/include/linux/sunrpc/svcsock.h
0004  *
0005  * RPC server socket I/O.
0006  *
0007  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
0008  */
0009 
0010 #ifndef SUNRPC_SVCSOCK_H
0011 #define SUNRPC_SVCSOCK_H
0012 
0013 #include <linux/sunrpc/svc.h>
0014 #include <linux/sunrpc/svc_xprt.h>
0015 
0016 /*
0017  * RPC server socket.
0018  */
0019 struct svc_sock {
0020     struct svc_xprt     sk_xprt;
0021     struct socket *     sk_sock;    /* berkeley socket layer */
0022     struct sock *       sk_sk;      /* INET layer */
0023 
0024     /* We keep the old state_change and data_ready CB's here */
0025     void            (*sk_ostate)(struct sock *);
0026     void            (*sk_odata)(struct sock *);
0027     void            (*sk_owspace)(struct sock *);
0028 
0029     /* private TCP part */
0030     /* On-the-wire fragment header: */
0031     __be32          sk_marker;
0032     /* As we receive a record, this includes the length received so
0033      * far (including the fragment header): */
0034     u32         sk_tcplen;
0035     /* Total length of the data (not including fragment headers)
0036      * received so far in the fragments making up this rpc: */
0037     u32         sk_datalen;
0038     /* Number of queued send requests */
0039     atomic_t        sk_sendqlen;
0040 
0041     struct page *       sk_pages[RPCSVC_MAXPAGES];  /* received data */
0042 };
0043 
0044 static inline u32 svc_sock_reclen(struct svc_sock *svsk)
0045 {
0046     return be32_to_cpu(svsk->sk_marker) & RPC_FRAGMENT_SIZE_MASK;
0047 }
0048 
0049 static inline u32 svc_sock_final_rec(struct svc_sock *svsk)
0050 {
0051     return be32_to_cpu(svsk->sk_marker) & RPC_LAST_STREAM_FRAGMENT;
0052 }
0053 
0054 /*
0055  * Function prototypes.
0056  */
0057 void        svc_close_net(struct svc_serv *, struct net *);
0058 int     svc_recv(struct svc_rqst *, long);
0059 int     svc_send(struct svc_rqst *);
0060 void        svc_drop(struct svc_rqst *);
0061 void        svc_sock_update_bufs(struct svc_serv *serv);
0062 bool        svc_alien_sock(struct net *net, int fd);
0063 int     svc_addsock(struct svc_serv *serv, const int fd,
0064                     char *name_return, const size_t len,
0065                     const struct cred *cred);
0066 void        svc_init_xprt_sock(void);
0067 void        svc_cleanup_xprt_sock(void);
0068 struct svc_xprt *svc_sock_create(struct svc_serv *serv, int prot);
0069 void        svc_sock_destroy(struct svc_xprt *);
0070 
0071 /*
0072  * svc_makesock socket characteristics
0073  */
0074 #define SVC_SOCK_DEFAULTS   (0U)
0075 #define SVC_SOCK_ANONYMOUS  (1U << 0)   /* don't register with pmap */
0076 #define SVC_SOCK_TEMPORARY  (1U << 1)   /* flag socket as temporary */
0077 
0078 #endif /* SUNRPC_SVCSOCK_H */