18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/* AFS Volume Location Service client interface
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
58c2ecf20Sopenharmony_ci * Written by David Howells (dhowells@redhat.com)
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef AFS_VL_H
98c2ecf20Sopenharmony_ci#define AFS_VL_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "afs.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define AFS_VL_PORT		7003	/* volume location service port */
148c2ecf20Sopenharmony_ci#define VL_SERVICE		52	/* RxRPC service ID for the Volume Location service */
158c2ecf20Sopenharmony_ci#define YFS_VL_SERVICE		2503	/* Service ID for AuriStor upgraded VL service */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cienum AFSVL_Operations {
188c2ecf20Sopenharmony_ci	VLGETENTRYBYID		= 503,	/* AFS Get VLDB entry by ID */
198c2ecf20Sopenharmony_ci	VLGETENTRYBYNAME	= 504,	/* AFS Get VLDB entry by name */
208c2ecf20Sopenharmony_ci	VLPROBE			= 514,	/* AFS probe VL service */
218c2ecf20Sopenharmony_ci	VLGETENTRYBYIDU		= 526,	/* AFS Get VLDB entry by ID (UUID-variant) */
228c2ecf20Sopenharmony_ci	VLGETENTRYBYNAMEU	= 527,	/* AFS Get VLDB entry by name (UUID-variant) */
238c2ecf20Sopenharmony_ci	VLGETADDRSU		= 533,	/* AFS Get addrs for fileserver */
248c2ecf20Sopenharmony_ci	YVLGETENDPOINTS		= 64002, /* YFS Get endpoints for file/volume server */
258c2ecf20Sopenharmony_ci	YVLGETCELLNAME		= 64014, /* YFS Get actual cell name */
268c2ecf20Sopenharmony_ci	VLGETCAPABILITIES	= 65537, /* AFS Get server capabilities */
278c2ecf20Sopenharmony_ci};
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum AFSVL_Errors {
308c2ecf20Sopenharmony_ci	AFSVL_IDEXIST 		= 363520,	/* Volume Id entry exists in vl database */
318c2ecf20Sopenharmony_ci	AFSVL_IO 		= 363521,	/* I/O related error */
328c2ecf20Sopenharmony_ci	AFSVL_NAMEEXIST 	= 363522,	/* Volume name entry exists in vl database */
338c2ecf20Sopenharmony_ci	AFSVL_CREATEFAIL 	= 363523,	/* Internal creation failure */
348c2ecf20Sopenharmony_ci	AFSVL_NOENT 		= 363524,	/* No such entry */
358c2ecf20Sopenharmony_ci	AFSVL_EMPTY 		= 363525,	/* Vl database is empty */
368c2ecf20Sopenharmony_ci	AFSVL_ENTDELETED 	= 363526,	/* Entry is deleted (soft delete) */
378c2ecf20Sopenharmony_ci	AFSVL_BADNAME 		= 363527,	/* Volume name is illegal */
388c2ecf20Sopenharmony_ci	AFSVL_BADINDEX 		= 363528,	/* Index is out of range */
398c2ecf20Sopenharmony_ci	AFSVL_BADVOLTYPE 	= 363529,	/* Bad volume type */
408c2ecf20Sopenharmony_ci	AFSVL_BADSERVER 	= 363530,	/* Illegal server number (out of range) */
418c2ecf20Sopenharmony_ci	AFSVL_BADPARTITION 	= 363531,	/* Bad partition number */
428c2ecf20Sopenharmony_ci	AFSVL_REPSFULL 		= 363532,	/* Run out of space for Replication sites */
438c2ecf20Sopenharmony_ci	AFSVL_NOREPSERVER 	= 363533,	/* No such Replication server site exists */
448c2ecf20Sopenharmony_ci	AFSVL_DUPREPSERVER 	= 363534,	/* Replication site already exists */
458c2ecf20Sopenharmony_ci	AFSVL_RWNOTFOUND 	= 363535,	/* Parent R/W entry not found */
468c2ecf20Sopenharmony_ci	AFSVL_BADREFCOUNT 	= 363536,	/* Illegal Reference Count number */
478c2ecf20Sopenharmony_ci	AFSVL_SIZEEXCEEDED 	= 363537,	/* Vl size for attributes exceeded */
488c2ecf20Sopenharmony_ci	AFSVL_BADENTRY 		= 363538,	/* Bad incoming vl entry */
498c2ecf20Sopenharmony_ci	AFSVL_BADVOLIDBUMP 	= 363539,	/* Illegal max volid increment */
508c2ecf20Sopenharmony_ci	AFSVL_IDALREADYHASHED 	= 363540,	/* RO/BACK id already hashed */
518c2ecf20Sopenharmony_ci	AFSVL_ENTRYLOCKED 	= 363541,	/* Vl entry is already locked */
528c2ecf20Sopenharmony_ci	AFSVL_BADVOLOPER 	= 363542,	/* Bad volume operation code */
538c2ecf20Sopenharmony_ci	AFSVL_BADRELLOCKTYPE 	= 363543,	/* Bad release lock type */
548c2ecf20Sopenharmony_ci	AFSVL_RERELEASE 	= 363544,	/* Status report: last release was aborted */
558c2ecf20Sopenharmony_ci	AFSVL_BADSERVERFLAG 	= 363545,	/* Invalid replication site server flag */
568c2ecf20Sopenharmony_ci	AFSVL_PERM 		= 363546,	/* No permission access */
578c2ecf20Sopenharmony_ci	AFSVL_NOMEM 		= 363547,	/* malloc/realloc failed to alloc enough memory */
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cienum {
618c2ecf20Sopenharmony_ci	YFS_SERVER_INDEX	= 0,
628c2ecf20Sopenharmony_ci	YFS_SERVER_UUID		= 1,
638c2ecf20Sopenharmony_ci	YFS_SERVER_ENDPOINT	= 2,
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cienum {
678c2ecf20Sopenharmony_ci	YFS_ENDPOINT_IPV4	= 0,
688c2ecf20Sopenharmony_ci	YFS_ENDPOINT_IPV6	= 1,
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define YFS_MAXENDPOINTS	16
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/*
748c2ecf20Sopenharmony_ci * maps to "struct vldbentry" in vvl-spec.pdf
758c2ecf20Sopenharmony_ci */
768c2ecf20Sopenharmony_cistruct afs_vldbentry {
778c2ecf20Sopenharmony_ci	char		name[65];		/* name of volume (with NUL char) */
788c2ecf20Sopenharmony_ci	afs_voltype_t	type;			/* volume type */
798c2ecf20Sopenharmony_ci	unsigned	num_servers;		/* num servers that hold instances of this vol */
808c2ecf20Sopenharmony_ci	unsigned	clone_id;		/* cloning ID */
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	unsigned	flags;
838c2ecf20Sopenharmony_ci#define AFS_VLF_RWEXISTS	0x1000		/* R/W volume exists */
848c2ecf20Sopenharmony_ci#define AFS_VLF_ROEXISTS	0x2000		/* R/O volume exists */
858c2ecf20Sopenharmony_ci#define AFS_VLF_BACKEXISTS	0x4000		/* backup volume exists */
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	afs_volid_t	volume_ids[3];		/* volume IDs */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	struct {
908c2ecf20Sopenharmony_ci		struct in_addr	addr;		/* server address */
918c2ecf20Sopenharmony_ci		unsigned	partition;	/* partition ID on this server */
928c2ecf20Sopenharmony_ci		unsigned	flags;		/* server specific flags */
938c2ecf20Sopenharmony_ci#define AFS_VLSF_NEWREPSITE	0x0001	/* Ignore all 'non-new' servers */
948c2ecf20Sopenharmony_ci#define AFS_VLSF_ROVOL		0x0002	/* this server holds a R/O instance of the volume */
958c2ecf20Sopenharmony_ci#define AFS_VLSF_RWVOL		0x0004	/* this server holds a R/W instance of the volume */
968c2ecf20Sopenharmony_ci#define AFS_VLSF_BACKVOL	0x0008	/* this server holds a backup instance of the volume */
978c2ecf20Sopenharmony_ci#define AFS_VLSF_UUID		0x0010	/* This server is referred to by its UUID */
988c2ecf20Sopenharmony_ci#define AFS_VLSF_DONTUSE	0x0020	/* This server ref should be ignored */
998c2ecf20Sopenharmony_ci	} servers[8];
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define AFS_VLDB_MAXNAMELEN 65
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cistruct afs_ListAddrByAttributes__xdr {
1068c2ecf20Sopenharmony_ci	__be32			Mask;
1078c2ecf20Sopenharmony_ci#define AFS_VLADDR_IPADDR	0x1	/* Match by ->ipaddr */
1088c2ecf20Sopenharmony_ci#define AFS_VLADDR_INDEX	0x2	/* Match by ->index */
1098c2ecf20Sopenharmony_ci#define AFS_VLADDR_UUID		0x4	/* Match by ->uuid */
1108c2ecf20Sopenharmony_ci	__be32			ipaddr;
1118c2ecf20Sopenharmony_ci	__be32			index;
1128c2ecf20Sopenharmony_ci	__be32			spare;
1138c2ecf20Sopenharmony_ci	struct afs_uuid__xdr	uuid;
1148c2ecf20Sopenharmony_ci};
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistruct afs_uvldbentry__xdr {
1178c2ecf20Sopenharmony_ci	__be32			name[AFS_VLDB_MAXNAMELEN];
1188c2ecf20Sopenharmony_ci	__be32			nServers;
1198c2ecf20Sopenharmony_ci	struct afs_uuid__xdr	serverNumber[AFS_NMAXNSERVERS];
1208c2ecf20Sopenharmony_ci	__be32			serverUnique[AFS_NMAXNSERVERS];
1218c2ecf20Sopenharmony_ci	__be32			serverPartition[AFS_NMAXNSERVERS];
1228c2ecf20Sopenharmony_ci	__be32			serverFlags[AFS_NMAXNSERVERS];
1238c2ecf20Sopenharmony_ci	__be32			volumeId[AFS_MAXTYPES];
1248c2ecf20Sopenharmony_ci	__be32			cloneId;
1258c2ecf20Sopenharmony_ci	__be32			flags;
1268c2ecf20Sopenharmony_ci	__be32			spares1;
1278c2ecf20Sopenharmony_ci	__be32			spares2;
1288c2ecf20Sopenharmony_ci	__be32			spares3;
1298c2ecf20Sopenharmony_ci	__be32			spares4;
1308c2ecf20Sopenharmony_ci	__be32			spares5;
1318c2ecf20Sopenharmony_ci	__be32			spares6;
1328c2ecf20Sopenharmony_ci	__be32			spares7;
1338c2ecf20Sopenharmony_ci	__be32			spares8;
1348c2ecf20Sopenharmony_ci	__be32			spares9;
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistruct afs_address_list {
1388c2ecf20Sopenharmony_ci	refcount_t		usage;
1398c2ecf20Sopenharmony_ci	unsigned int		version;
1408c2ecf20Sopenharmony_ci	unsigned int		nr_addrs;
1418c2ecf20Sopenharmony_ci	struct sockaddr_rxrpc	addrs[];
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ciextern void afs_put_address_list(struct afs_address_list *alist);
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#endif /* AFS_VL_H */
147