]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/exportfs.h
3cf1ee82b9461bd20d5b3c16b7dc7cd929b34f36
[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
104 typedef struct _exp_hash_entry {
105         nfs_export * p_first;
106         nfs_export * p_last;
107 } exp_hash_entry;
108
109 typedef struct _exp_hash_table {
110         nfs_export * p_head;
111         exp_hash_entry entries[HASH_TABLE_SIZE];
112 } exp_hash_table;
113
114 extern exp_hash_table exportlist[MCL_MAXTYPES];
115
116 extern nfs_client *             clientlist[MCL_MAXTYPES];
117
118 nfs_client *                    client_lookup(char *hname, int canonical);
119 nfs_client *                    client_dup(const nfs_client *clp,
120                                                 const struct addrinfo *ai);
121 int                             client_gettype(char *hname);
122 int                             client_check(const nfs_client *clp,
123                                                 const struct addrinfo *ai);
124 void                            client_release(nfs_client *);
125 void                            client_freeall(void);
126 char *                          client_compose(const struct addrinfo *ai);
127 struct addrinfo *               client_resolve(const struct sockaddr *sap);
128 int                             client_member(const char *client,
129                                                 const char *name);
130
131 void                            export_read(char *fname);
132 void                            export_reset(nfs_export *);
133 nfs_export *                    export_lookup(char *hname, char *path, int caconical);
134 nfs_export *                    export_find(const struct addrinfo *ai,
135                                                 const char *path);
136 nfs_export *                    export_allowed(const struct addrinfo *ai,
137                                                 const char *path);
138 nfs_export *                    export_create(struct exportent *, int canonical);
139 void                            export_freeall(void);
140 int                             export_export(nfs_export *);
141 int                             export_unexport(nfs_export *);
142
143 int                             xtab_mount_read(void);
144 int                             xtab_export_read(void);
145 int                             xtab_mount_write(void);
146 int                             xtab_export_write(void);
147 void                            xtab_append(nfs_export *);
148
149 int                             secinfo_addflavor(struct flav_info *, struct exportent *);
150
151 char *                          host_ntop(const struct sockaddr *sap,
152                                                 char *buf, const size_t buflen);
153 __attribute_malloc__
154 struct addrinfo *               host_pton(const char *paddr);
155 __attribute_malloc__
156 struct addrinfo *               host_addrinfo(const char *hostname);
157 __attribute_malloc__
158 char *                          host_canonname(const struct sockaddr *sap);
159 __attribute_malloc__
160 struct addrinfo *               host_reliable_addrinfo(const struct sockaddr *sap);
161 __attribute_malloc__
162 struct addrinfo *               host_numeric_addrinfo(const struct sockaddr *sap);
163
164 int                             rmtab_read(void);
165
166 struct nfskey *                 key_lookup(char *hname);
167
168 struct export_features {
169         unsigned int flags;
170         unsigned int secinfo_flags;
171 };
172
173 struct export_features *get_export_features(void);
174
175 /* Record export error.  */
176 extern int export_errno;
177
178 #endif /* EXPORTFS_H */