| 1 |
/* ----------------------------------------------------------------------- * |
| 2 |
* |
| 3 |
* repl_list.h - header file for replicated mount server selection |
| 4 |
* |
| 5 |
* Copyright 2004 Jeff Moyer <[email protected]> - All Rights Reserved |
| 6 |
* Copyright 2004-2006 Ian Kent <[email protected]> - All Rights Reserved |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, |
| 11 |
* USA; either version 2 of the License, or (at your option) any later |
| 12 |
* version; incorporated herein by reference. |
| 13 |
* |
| 14 |
* ----------------------------------------------------------------------- */ |
| 15 |
|
| 16 |
#ifndef _REPLICATED_H |
| 17 |
#define _REPLICATED_H |
| 18 |
|
| 19 |
#define PROXIMITY_ERROR 0x0000 |
| 20 |
#define PROXIMITY_LOCAL 0x0001 |
| 21 |
#define PROXIMITY_SUBNET 0x0002 |
| 22 |
#define PROXIMITY_NET 0x0004 |
| 23 |
#define PROXIMITY_OTHER 0x0008 |
| 24 |
#define PROXIMITY_UNSUPPORTED 0x0010 |
| 25 |
|
| 26 |
#define NFS2_SUPPORTED 0x0010 |
| 27 |
#define NFS3_SUPPORTED 0x0020 |
| 28 |
#define NFS4_SUPPORTED 0x0040 |
| 29 |
#define NFS_VERS_DEFAULT (NFS3_SUPPORTED) |
| 30 |
#define NFS_VERS_MASK (NFS2_SUPPORTED|NFS3_SUPPORTED) |
| 31 |
#define NFS4_VERS_DEFAULT (NFS4_SUPPORTED) |
| 32 |
#define NFS4_VERS_MASK (NFS4_SUPPORTED) |
| 33 |
|
| 34 |
#define NFS2_REQUESTED NFS2_SUPPORTED |
| 35 |
#define NFS3_REQUESTED NFS3_SUPPORTED |
| 36 |
#define NFS4_REQUESTED NFS4_SUPPORTED |
| 37 |
|
| 38 |
#define NFS4_ONLY_REQUESTED 0x0800 |
| 39 |
|
| 40 |
#define TCP_SUPPORTED 0x0001 |
| 41 |
#define UDP_SUPPORTED 0x0002 |
| 42 |
#define TCP_REQUESTED TCP_SUPPORTED |
| 43 |
#define UDP_REQUESTED UDP_SUPPORTED |
| 44 |
#define TCP6_REQUESTED 0x0100 |
| 45 |
#define UDP6_REQUESTED 0x0200 |
| 46 |
#define NFS_PROTO_DEFAULT (TCP_SUPPORTED|UDP_SUPPORTED) |
| 47 |
#define NFS_PROTO_MASK (TCP_SUPPORTED|UDP_SUPPORTED) |
| 48 |
|
| 49 |
#define NFS2_TCP_SUPPORTED NFS2_SUPPORTED |
| 50 |
#define NFS3_TCP_SUPPORTED NFS3_SUPPORTED |
| 51 |
#define NFS4_TCP_SUPPORTED NFS4_SUPPORTED |
| 52 |
#define NFS2_UDP_SUPPORTED (NFS2_SUPPORTED << 8) |
| 53 |
#define NFS3_UDP_SUPPORTED (NFS3_SUPPORTED << 8) |
| 54 |
#define NFS4_UDP_SUPPORTED (NFS4_SUPPORTED << 8) |
| 55 |
#define TCP_SELECTED_MASK 0x00FF |
| 56 |
#define UDP_SELECTED_MASK 0xFF00 |
| 57 |
|
| 58 |
#define IS_ERR(supported) (0x8000 & supported) |
| 59 |
#define ERR(supported) (IS_ERR(supported) ? (~supported + 1) : supported) |
| 60 |
|
| 61 |
#define RPC_TIMEOUT 5 |
| 62 |
|
| 63 |
struct host { |
| 64 |
char *name; |
| 65 |
int ent_num; |
| 66 |
struct sockaddr *addr; |
| 67 |
size_t addr_len; |
| 68 |
unsigned int rr; |
| 69 |
char *path; |
| 70 |
unsigned int version; |
| 71 |
unsigned int options; |
| 72 |
unsigned int proximity; |
| 73 |
unsigned int weight; |
| 74 |
unsigned long cost; |
| 75 |
struct host *next; |
| 76 |
}; |
| 77 |
|
| 78 |
void seed_random(void); |
| 79 |
struct host *new_host(const char *, int, struct sockaddr *, size_t, |
| 80 |
unsigned int, unsigned int, unsigned int); |
| 81 |
void free_host_list(struct host **); |
| 82 |
int parse_location(unsigned, struct host **, const char *, unsigned int); |
| 83 |
int prune_host_list(unsigned, struct host **, unsigned int, int); |
| 84 |
void dump_host_list(struct host *); |
| 85 |
|
| 86 |
#endif |
| 87 |
|