]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/exportfs.h
Merge branch 'upstream'
[nfs-utils.git] / support / include / exportfs.h
1 /*
2  * support/include/exportfs.h
3  *
4  * Declarations for exportfs and mountd
5  *
6  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7  */
8
9 #ifndef EXPORTFS_H
10 #define EXPORTFS_H
11
12 #include <netdb.h>
13
14 #include "sockaddr.h"
15 #include "nfslib.h"
16
17 enum {
18         MCL_FQDN = 0,
19         MCL_SUBNETWORK,
20         MCL_IPADDR = MCL_SUBNETWORK,
21         MCL_WILDCARD,
22         MCL_NETGROUP,
23         MCL_ANONYMOUS,
24         MCL_GSS,
25         MCL_MAXTYPES
26 };
27
28 enum {
29         FSLOC_NONE = 0,
30         FSLOC_REFER,
31         FSLOC_REPLICA,
32         FSLOC_STUB
33 };
34
35 typedef struct mclient {
36         struct mclient *        m_next;
37         char *                  m_hostname;
38         int                     m_type;
39         int                     m_naddr;
40         union nfs_sockaddr      m_addrlist[NFSCLNT_ADDRMAX];
41         int                     m_exported;     /* exported to nfsd */
42         int                     m_count;
43 } nfs_client;
44
45 static inline const struct sockaddr *
46 get_addrlist(const nfs_client *clp, const int i)
47 {
48         return &clp->m_addrlist[i].sa;
49 }
50
51 static inline const struct sockaddr_in *
52 get_addrlist_in(const nfs_client *clp, const int i)
53 {
54         return &clp->m_addrlist[i].s4;
55 }
56
57 static inline const struct sockaddr_in6 *
58 get_addrlist_in6(const nfs_client *clp, const int i)
59 {
60         return &clp->m_addrlist[i].s6;
61 }
62
63 static inline void
64 set_addrlist_in(nfs_client *clp, const int i, const struct sockaddr_in *sin)
65 {
66         memcpy(&clp->m_addrlist[i].s4, sin, sizeof(*sin));
67 }
68
69 static inline void
70 set_addrlist_in6(nfs_client *clp, const int i, const struct sockaddr_in6 *sin6)
71 {
72         memcpy(&clp->m_addrlist[i].s6, sin6, sizeof(*sin6));
73 }
74
75 static inline void
76 set_addrlist(nfs_client *clp, const int i, const struct sockaddr *sap)
77 {
78         switch (sap->sa_family) {
79         case AF_INET:
80                 memcpy(&clp->m_addrlist[i].s4, sap, sizeof(struct sockaddr_in));
81                 break;
82 #ifdef IPV6_SUPPORTED
83         case AF_INET6:
84                 memcpy(&clp->m_addrlist[i].s6, sap, sizeof(struct sockaddr_in6));
85                 break;
86 #endif
87         }
88 }
89
90 typedef struct mexport {
91         struct mexport *        m_next;
92         struct mclient *        m_client;
93         struct exportent        m_export;
94         int                     m_exported;     /* known to knfsd. -1 means not sure */
95         int                     m_xtabent  : 1, /* xtab entry exists */
96                                 m_mayexport: 1, /* derived from xtabbed */
97                                 m_changed  : 1, /* options (may) have changed */
98                                 m_warned   : 1; /* warned about multiple exports
99                                                  * matching one client */
100 } nfs_export;
101
102 #define HASH_TABLE_SIZE 1021
103 #define DEFAULT_TTL     (30 * 60)
104
105 typedef struct _exp_hash_entry {
106         nfs_export * p_first;
107         nfs_export * p_last;
108 } exp_hash_entry;
109
110 typedef struct _exp_hash_table {
111         nfs_export * p_head;
112         exp_hash_entry entries[HASH_TABLE_SIZE];
113 } exp_hash_table;
114
115 extern exp_hash_table exportlist[MCL_MAXTYPES];
116
117 extern nfs_client *             clientlist[MCL_MAXTYPES];
118
119 nfs_client *                    client_lookup(char *hname, int canonical);
120 nfs_client *                    client_dup(const nfs_client *clp,
121                                                 const struct addrinfo *ai);
122 int                             client_gettype(char *hname);
123 int                             client_check(const nfs_client *clp,
124                                                 const struct addrinfo *ai);
125 void                            client_release(nfs_client *);
126 void                            client_freeall(void);
127 char *                          client_compose(const struct addrinfo *ai);
128 struct addrinfo *               client_resolve(const struct sockaddr *sap);
129 int                             client_member(const char *client,
130                                                 const char *name);
131
132 void                            export_read(char *fname);
133 void                            export_reset(nfs_export *);
134 nfs_export *                    export_lookup(char *hname, char *path, int caconical);
135 nfs_export *                    export_find(const struct addrinfo *ai,
136                                                 const char *path);
137 nfs_export *                    export_allowed(const struct addrinfo *ai,
138                                                 const char *path);
139 nfs_export *                    export_create(struct exportent *, int canonical);
140 void                            export_freeall(void);
141 int                             export_export(nfs_export *);
142 int                             export_unexport(nfs_export *);
143
144 int                             xtab_mount_read(void);
145 int                             xtab_export_read(void);
146 int                             xtab_mount_write(void);
147 int                             xtab_export_write(void);
148 void                            xtab_append(nfs_export *);
149
150 int                             secinfo_addflavor(struct flav_info *, struct exportent *);
151
152 char *                          host_ntop(const struct sockaddr *sap,
153                                                 char *buf, const size_t buflen);
154 __attribute_malloc__
155 struct addrinfo *               host_pton(const char *paddr);
156 __attribute_malloc__
157 struct addrinfo *               host_addrinfo(const char *hostname);
158 __attribute_malloc__
159 char *                          host_canonname(const struct sockaddr *sap);
160 __attribute_malloc__
161 struct addrinfo *               host_reliable_addrinfo(const struct sockaddr *sap);
162 __attribute_malloc__
163 struct addrinfo *               host_numeric_addrinfo(const struct sockaddr *sap);
164
165 int                             rmtab_read(void);
166
167 struct nfskey *                 key_lookup(char *hname);
168
169 struct export_features {
170         unsigned int flags;
171         unsigned int secinfo_flags;
172 };
173
174 struct export_features *get_export_features(void);
175
176 /* Record export error.  */
177 extern int export_errno;
178
179 #endif /* EXPORTFS_H */