2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
13 Test of the routines used by the FileServer to manipulate the cell/server database and
14 determine the local cell name:
15 1) Reading in the local cell name from file.
16 2) Reading in the cell/server database from disk.
17 3) Reporting the set of servers associated with a given cell name.
18 4) Printing out the contents of the cell/server database.
19 5) Reclaiming the space used by an in-memory database.
24 --------------------------------------------------------------------------------------------------------------*/
25 #include <afsconfig.h>
26 #include <afs/param.h>
31 #include <sys/types.h>
35 #include <afs/afsutil.h>
39 #include <netinet/in.h>
41 #include <afs/cellconfig.h>
44 PrintOneCell(struct afsconf_cell *ainfo, void *arock, struct afsconf_dir *adir)
49 printf("Cell %s:\n", ainfo->name);
50 for (i = 0; i < ainfo->numServers; i++) {
51 memcpy(&temp, &ainfo->hostAddr[i].sin_addr, sizeof(long));
52 printf(" host %s at %x.%x\n", ainfo->hostName[i], temp,
53 ainfo->hostAddr[i].sin_port);
58 /*Main for testcellconfig*/
63 struct afsconf_dir *theDir;
65 struct afsconf_cell theCell;
72 ("usage: testcellconfig <conf-dir-name> [<cell-to-display>]*\n");
77 theDir = afsconf_Open(dirName);
79 printf("could not open configuration files in '%s'\n", dirName);
84 code = afsconf_GetLocalCell(theDir, tbuffer, sizeof(tbuffer));
86 printf("get local cell failed, code %d\n", code);
89 printf("Local cell is '%s'\n\n", tbuffer);
92 printf("About to print cell database contents:\n");
93 afsconf_CellApply(theDir, PrintOneCell, 0);
95 /* do this junk once */
96 printf("start of special test\n");
97 code = afsconf_GetCellInfo(theDir, NULL, "afsprot", &theCell);
99 printf("failed to find afsprot service (%d)\n", code);
101 printf("AFSPROT service:\n");
102 PrintOneCell(&theCell, NULL, theDir);
104 code = afsconf_GetCellInfo(theDir, 0, "bozotheclown", &theCell);
106 printf("unexpectedly found service 'bozotheclown'\n");
107 code = afsconf_GetCellInfo(theDir, NULL, "telnet", &theCell);
108 printf("Here's the telnet service:\n");
109 PrintOneCell(&theCell, NULL, theDir);
110 printf("done with special test\n");
112 /* now print out specified cell info */
113 for (i = 2; i < argc; i++) {
114 code = afsconf_GetCellInfo(theDir, argv[i], 0, &theCell);
116 printf("Could not find info for cell '%s', code %d\n",
119 PrintOneCell(&theCell, NULL, theDir);