]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/exportfs.h
mountd/exportfs: Make m_addrlist field a nfs_sockaddr
[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(nfs_client *, struct hostent *);
120 int                             client_gettype(char *hname);
121 int                             client_check(nfs_client *, struct hostent *);
122 void                            client_release(nfs_client *);
123 void                            client_freeall(void);
124 char *                          client_compose(struct hostent *he);
125 struct hostent *                client_resolve(struct in_addr addr);
126 int                             client_member(const char *client,
127                                                 const char *name);
128
129 int                             export_read(char *fname);
130 void                    export_add(nfs_export *);
131 void                            export_reset(nfs_export *);
132 nfs_export *                    export_lookup(char *hname, char *path, int caconical);
133 nfs_export *                    export_find(struct hostent *, char *path);
134 nfs_export *                    export_allowed(struct hostent *, char *path);
135 nfs_export *                    export_create(struct exportent *, int canonical);
136 nfs_export *                    export_dup(nfs_export *, struct hostent *);
137 void                            export_freeall(void);
138 int                             export_export(nfs_export *);
139 int                             export_unexport(nfs_export *);
140
141 int                             xtab_mount_read(void);
142 int                             xtab_export_read(void);
143 int                             xtab_mount_write(void);
144 int                             xtab_export_write(void);
145 void                            xtab_append(nfs_export *);
146
147 int                             secinfo_addflavor(struct flav_info *, struct exportent *);
148
149 int                             rmtab_read(void);
150
151 struct nfskey *                 key_lookup(char *hname);
152
153 struct export_features {
154         unsigned int flags;
155         unsigned int secinfo_flags;
156 };
157
158 struct export_features *get_export_features(void);
159
160 /* Record export error.  */
161 extern int export_errno;
162
163 #endif /* EXPORTFS_H */