]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/nsm.h
Merge branch 'upstream'
[nfs-utils.git] / support / include / nsm.h
1 /*
2  * Copyright 2009 Oracle.  All rights reserved.
3  *
4  * This file is part of nfs-utils.
5  *
6  * nfs-utils is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * nfs-utils is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 /*
21  * NSM for Linux.
22  */
23
24 #ifndef NFS_UTILS_SUPPORT_NSM_H
25 #define NFS_UTILS_SUPPORT_NSM_H
26
27 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <stdbool.h>
30
31 #include <netdb.h>
32 #include <time.h>
33
34 #include "sm_inter.h"
35
36 typedef unsigned int
37                 (*nsm_populate_t)(const char *hostname,
38                                 const struct sockaddr *sap,
39                                 const struct mon *mon,
40                                 const time_t timestamp);
41
42 /* file.c */
43
44 extern _Bool    nsm_setup_pathnames(const char *progname,
45                                 const char *parentdir);
46 extern _Bool    nsm_is_default_parentdir(void);
47 extern _Bool    nsm_drop_privileges(const int pidfd);
48
49 extern int      nsm_get_state(_Bool update);
50 extern void     nsm_update_kernel_state(const int state);
51
52 extern unsigned int
53                 nsm_retire_monitored_hosts(void);
54 extern unsigned int
55                 nsm_load_monitor_list(nsm_populate_t func);
56 extern unsigned int
57                 nsm_load_notify_list(nsm_populate_t func);
58
59 extern _Bool    nsm_insert_monitored_host(const char *hostname,
60                         const struct sockaddr *sap, const struct mon *m);
61 extern void     nsm_delete_monitored_host(const char *hostname,
62                         const char *mon_name, const char *my_name);
63 extern void     nsm_delete_notified_host(const char *hostname,
64                         const char *mon_name, const char *my_name);
65 extern size_t   nsm_priv_to_hex(const char *priv, char *buf,
66                                 const size_t buflen);
67
68 /* rpc.c */
69
70 #define NSM_MAXMSGSIZE  (2048u)
71
72 extern uint32_t nsm_xmit_getport(const int sock,
73                         const struct sockaddr_in *sin,
74                         const unsigned long program,
75                         const unsigned long version);
76 extern uint32_t nsm_xmit_getaddr(const int sock,
77                         const struct sockaddr_in6 *sin6,
78                         const rpcprog_t program, const rpcvers_t version);
79 extern uint32_t nsm_xmit_rpcbind(const int sock, const struct sockaddr *sap,
80                         const rpcprog_t program, const rpcvers_t version);
81 extern uint32_t nsm_xmit_notify(const int sock, const struct sockaddr *sap,
82                         const socklen_t salen, const rpcprog_t program,
83                         const char *mon_name, const int state);
84 extern uint32_t nsm_xmit_nlmcall(const int sock, const struct sockaddr *sap,
85                         const socklen_t salen, const struct mon *m,
86                         const int state);
87 extern uint32_t nsm_parse_reply(XDR *xdrs);
88 extern unsigned long
89                 nsm_recv_getport(XDR *xdrs);
90 extern uint16_t nsm_recv_getaddr(XDR *xdrs);
91 extern uint16_t nsm_recv_rpcbind(const sa_family_t family, XDR *xdrs);
92
93 #endif  /* !NFS_UTILS_SUPPORT_NSM_H */