Make ubik use unsigned addresses

The ubik code currently treats IPv4 addresses as both signed and
unsigned 32-bit ints. Make some instances use unsigned ints to make ubik
more consistent and squash a couple of warnings.

Note that this slightly alters the signatures of the public ubik
functions ubeacon_InitServerListByInfo, ubeacon_InitServerList,
ubik_ServerInitByInfo, ubik_ServerInit, ubik_ParseClientList, and
ubik_ParseServerList, to use unsigned addresses.

Change-Id: I27b6170d4de0080bf66d51a6b5332e65685ddef8
Reviewed-on: http://gerrit.openafs.org/875
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Andrew Deason 2009-11-27 17:56:19 -05:00 committed by Derrick Brashear
parent 8db0c38235
commit 95636c6fac
24 changed files with 56 additions and 62 deletions

View File

@ -58,9 +58,6 @@ libadmin/samples/rxstat_query_peer.c : all : util_RPCStatsStateGet types
libadmin/samples/rxstat_query_process.c : all : util_RPCStatsStateGet types
libadmin/test/client.c : all : util_RPCStatsStateGet types
rx/rx.c : all (pthread) : rxkad_global_stats_init not proto'd
ubik/beacon.c : all : Ubik uses signed/unsigned
interchangably for IP addresses, a
fix will require API changes.
ubik/ubikclient.c : strict-protos : ubik_Call
uss/uss_kauth.c : all : ubik_Call
viced/fsprobe.c : all : ubik_Call

View File

@ -1146,7 +1146,7 @@ ubik_Call_SingleServer(int (*aproc) (), struct ubik_client *aclient,
int
udbLocalInit(void)
{
afs_int32 serverList[MAXSERVERS];
afs_uint32 serverList[MAXSERVERS];
char hostname[256];
char *args[3];
int i;

View File

@ -33,8 +33,8 @@ struct buServerConfS {
FILE *log; /* log file for status/errors */
/* ubik and comm. related */
afs_int32 myHost;
afs_int32 serverList[MAXSERVERS]; /* list of ubik servers */
afs_uint32 myHost;
afs_uint32 serverList[MAXSERVERS]; /* list of ubik servers */
char *cellConfigdir; /* afs cell config. directory */
struct ubik_dbase *database; /* handle for the database */

View File

@ -57,7 +57,7 @@ int truncateDatabase(void);
int parseServerList(struct cmd_item *);
char lcell[MAXKTCREALMLEN];
afs_int32 myHost = 0;
afs_uint32 myHost = 0;
int helpOption;
/* server's global configuration information. This is exported to other
@ -95,8 +95,8 @@ BU_rxstat_userok(struct rx_call *call)
}
int
convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost,
afs_int32 *serverList)
convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_uint32 *myHost,
afs_uint32 *serverList)
{
int i;
char hostname[64];
@ -109,7 +109,7 @@ convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost,
printf("prserver: couldn't get address of this host.\n");
BUDB_EXIT(1);
}
memcpy(myHost, th->h_addr, sizeof(afs_int32));
memcpy(myHost, th->h_addr, sizeof(afs_uint32));
for (i = 0; i < cellinfo->numServers; i++)
/* omit my host from serverList */

View File

@ -1277,7 +1277,7 @@ int init = 0, noauth;
char name[MAXKTCNAMELEN];
char instance[MAXKTCNAMELEN];
char newCell[MAXKTCREALMLEN];
afs_int32 serverList[MAXSERVERS];
afs_uint32 serverList[MAXSERVERS];
int
NoAuth(struct cmd_syndesc *as, void *arock)

View File

@ -62,7 +62,7 @@ static int debug = 0;
"explicit". The cell can then be used to debug experimental servers. */
void
ka_ExplicitCell(char *cell, afs_int32 serverList[])
ka_ExplicitCell(char *cell, afs_uint32 serverList[])
{
int i;

View File

@ -63,7 +63,7 @@ struct ubik_dbase *KA_dbase;
int MinHours = 0;
int npwSums = KA_NPWSUMS;
afs_int32 verbose_track = 1;
afs_int32 myHost = 0;
afs_uint32 myHost = 0;
main(argc, argv)
int argc;

View File

@ -53,7 +53,7 @@
struct kadstats dynamic_statistics;
struct ubik_dbase *KA_dbase;
afs_int32 myHost = 0;
afs_uint32 myHost = 0;
afs_int32 verbose_track = 1;
afs_int32 krb4_cross = 0;
afs_int32 rxBind = 0;
@ -103,8 +103,8 @@ initialize_dstats(void)
}
static int
convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost,
afs_int32 *serverList)
convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_uint32 *myHost,
afs_uint32 *serverList)
{
int i;
char hostname[64];
@ -117,7 +117,7 @@ convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost,
ViceLog(0, ("kaserver: couldn't get address of this host.\n"));
exit(1);
}
memcpy(myHost, th->h_addr, sizeof(afs_int32));
memcpy(myHost, th->h_addr, sizeof(afs_uint32));
for (i = 0; i < cellinfo->numServers; i++)
if (cellinfo->hostAddr[i].sin_addr.s_addr != *myHost) {
@ -150,7 +150,7 @@ main(int argc, char *argv[])
{
afs_int32 code;
char *whoami = argv[0];
afs_int32 serverList[MAXSERVERS];
afs_uint32 serverList[MAXSERVERS];
struct afsconf_cell cellinfo;
char *cell;
const char *cellservdb, *dbpath, *lclpath;

View File

@ -148,7 +148,7 @@ struct kaOldKeys {
extern struct kaheader cheader;
extern struct kadstats dynamic_statistics;
extern afs_int32 myHost;
extern afs_uint32 myHost;
extern int kaux_opendb(char *path);

View File

@ -62,7 +62,7 @@ extern afs_int32 ka_GetAdminToken(char *name, char *instance, char *cell,
extern afs_int32 ka_VerifyUserToken(char *name, char *instance, char *cell,
struct ktc_encryptionKey *key);
extern void ka_ExplicitCell(char *cell, afs_int32 serverList[]
extern void ka_ExplicitCell(char *cell, afs_uint32 serverList[]
);
extern afs_int32 ka_GetServers(char *cell, struct afsconf_cell *cellinfo);

View File

@ -155,7 +155,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
char instance[MAXKTCNAMELEN];
char cell[MAXKTCREALMLEN];
char realm[MAXKTCREALMLEN];
afs_int32 serverList[MAXSERVERS];
afs_uint32 serverList[MAXSERVERS];
char *lcell; /* local cellname */
char lrealm[MAXKTCREALMLEN]; /* uppercase copy of local cellname */
int code;

View File

@ -202,7 +202,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
char instance[MAXKTCNAMELEN] = "";
char cell[MAXKTCREALMLEN] = "";
char realm[MAXKTCREALMLEN] = "";
afs_int32 serverList[MAXSERVERS];
afs_uint32 serverList[MAXSERVERS];
char *lcell; /* local cellname */
int code;
int i;

View File

@ -156,7 +156,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
char instance[MAXKTCNAMELEN];
char cell[MAXKTCREALMLEN];
char realm[MAXKTCREALMLEN];
afs_int32 serverList[MAXSERVERS];
afs_uint32 serverList[MAXSERVERS];
char *lcell; /* local cellname */
char lrealm[MAXKTCREALMLEN]; /* uppercase copy of local cellname */
int code;

View File

@ -205,7 +205,7 @@ int
main(int argc, char **argv)
{
register afs_int32 code;
afs_int32 myHost;
afs_uint32 myHost;
register struct hostent *th;
char hostname[64];
struct rx_service *tservice;
@ -444,7 +444,7 @@ main(int argc, char **argv)
fprintf(stderr, "ptserver: couldn't get address of this host.\n");
PT_EXIT(1);
}
memcpy(&myHost, th->h_addr, sizeof(afs_int32));
memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
/* get list of servers */
code =

View File

@ -26,7 +26,7 @@ extern int dbase_fd;
struct ubik_dbase *dbase;
int
ubik_ServerInit(afs_int32 myHost, short myPort, afs_int32 serverList[],
ubik_ServerInit(afs_uint32 myHost, short myPort, afs_uint32 serverList[],
const char *pathName, struct ubik_dbase **dbase)
{
return (0);

View File

@ -120,12 +120,7 @@ libubik.a: ${LIBOBJS} AFS_component_version_number.o
disk.o: disk.c ${INCLS}
uinit.o: uinit.c ${INCLS}
remote.o: remote.c ${INCLS}
# beacon.c uses signed and unsigned interchangably for IP addresses. Fixing
# will require changing the Ubik API
beacon.o: beacon.c ${INCLS}
$(CC) $(CFLAGS) @CFLAGS_NOERROR@ -c $<
lock.o: lock.c ${INCLS}
recovery.o: recovery.c ${INCLS}
ubik.o: ubik.c ${INCLS}

View File

@ -54,10 +54,10 @@ int (*ubik_CRXSecurityProc) (void *rock, struct rx_securityClass **,
void *ubik_CRXSecurityRock;
afs_int32 ubikSecIndex;
struct rx_securityClass *ubikSecClass;
static int ubeacon_InitServerListCommon(afs_int32 ame,
static int ubeacon_InitServerListCommon(afs_uint32 ame,
struct afsconf_cell *info,
char clones[],
afs_int32 aservers[]);
afs_uint32 aservers[]);
static int verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
afs_uint32 aservers[]);
static int updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR]);
@ -145,7 +145,7 @@ ubeacon_AmSyncSite(void)
* \see ubeacon_InitServerListCommon()
*/
int
ubeacon_InitServerListByInfo(afs_int32 ame, struct afsconf_cell *info,
ubeacon_InitServerListByInfo(afs_uint32 ame, struct afsconf_cell *info,
char clones[])
{
afs_int32 code;
@ -161,7 +161,7 @@ ubeacon_InitServerListByInfo(afs_int32 ame, struct afsconf_cell *info,
* \see ubeacon_InitServerListCommon()
*/
int
ubeacon_InitServerList(afs_int32 ame, register afs_int32 aservers[])
ubeacon_InitServerList(afs_uint32 ame, register afs_uint32 aservers[])
{
afs_int32 code;
@ -197,8 +197,8 @@ ubeacon_InitServerList(afs_int32 ame, register afs_int32 aservers[])
* \see ubeacon_InitServerList(), ubeacon_InitServerListByInfo()
*/
int
ubeacon_InitServerListCommon(afs_int32 ame, struct afsconf_cell *info,
char clones[], register afs_int32 aservers[])
ubeacon_InitServerListCommon(afs_uint32 ame, struct afsconf_cell *info,
char clones[], register afs_uint32 aservers[])
{
register struct ubik_server *ts;
afs_int32 me = -1;

View File

@ -384,9 +384,9 @@ ContactQuorum_DISK_SetVersion(register struct ubik_trans *atrans, int aflags,
* \see ubik_ServerInit(), ubik_ServerInitByInfo()
*/
int
ubik_ServerInitCommon(afs_int32 myHost, short myPort,
ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
struct afsconf_cell *info, char clones[],
afs_int32 serverList[], const char *pathName,
afs_uint32 serverList[], const char *pathName,
struct ubik_dbase **dbase)
{
register struct ubik_dbase *tdb;
@ -569,7 +569,7 @@ ubik_ServerInitCommon(afs_int32 myHost, short myPort,
* \see ubik_ServerInitCommon()
*/
int
ubik_ServerInitByInfo(afs_int32 myHost, short myPort,
ubik_ServerInitByInfo(afs_uint32 myHost, short myPort,
struct afsconf_cell *info, char clones[],
const char *pathName, struct ubik_dbase **dbase)
{
@ -585,7 +585,7 @@ ubik_ServerInitByInfo(afs_int32 myHost, short myPort,
* \see ubik_ServerInitCommon()
*/
int
ubik_ServerInit(afs_int32 myHost, short myPort, afs_int32 serverList[],
ubik_ServerInit(afs_uint32 myHost, short myPort, afs_uint32 serverList[],
const char *pathName, struct ubik_dbase **dbase)
{
afs_int32 code;

View File

@ -443,10 +443,10 @@ extern afs_uint32 ubikGetPrimaryInterfaceAddr(afs_uint32 addr);
struct afsconf_cell;
extern void ubeacon_Debug(struct ubik_debug *aparm);
extern int ubeacon_AmSyncSite(void);
extern int ubeacon_InitServerListByInfo(afs_int32 ame,
struct afsconf_cell *info,
extern int ubeacon_InitServerListByInfo(afs_uint32 ame,
struct afsconf_cell *info,
char clones[]);
extern int ubeacon_InitServerList(afs_int32 ame, afs_int32 aservers[]);
extern int ubeacon_InitServerList(afs_uint32 ame, afs_uint32 aservers[]);
extern void *ubeacon_Interact(void *);
/*\}*/
@ -499,12 +499,12 @@ extern afs_int32 ubik_nBuffers;
/*! \name ubik.c */
struct afsconf_cell;
extern int ubik_ServerInitByInfo(afs_int32 myHost, short myPort,
extern int ubik_ServerInitByInfo(afs_uint32 myHost, short myPort,
struct afsconf_cell *info, char clones[],
const char *pathName,
struct ubik_dbase **dbase);
extern int ubik_ServerInit(afs_int32 myHost, short myPort,
afs_int32 serverList[],
extern int ubik_ServerInit(afs_uint32 myHost, short myPort,
afs_uint32 serverList[],
const char *pathName, struct ubik_dbase **dbase);
extern int ubik_BeginTrans(register struct ubik_dbase *dbase,
afs_int32 transMode, struct ubik_trans **transPtr);
@ -541,7 +541,7 @@ extern int ubik_CheckCache(struct ubik_trans *atrans,
/*! \name ubikclient.c */
extern int ubik_ParseClientList(int argc, char **argv, afs_int32 * aothers);
extern int ubik_ParseClientList(int argc, char **argv, afs_uint32 * aothers);
extern unsigned int afs_random(void);
extern int ubik_ClientInit(register struct rx_connection **serverconns,
struct ubik_client **aclient);
@ -562,8 +562,8 @@ extern afs_int32 ubik_Call_New(int (*aproc) (), register struct ubik_client
/*\}*/
/* \name ubikcmd.c */
extern int ubik_ParseServerList(int argc, char **argv, afs_int32 *ahost,
afs_int32 *aothers);
extern int ubik_ParseServerList(int argc, char **argv, afs_uint32 *ahost,
afs_uint32 *aothers);
/*\}*/
/* \name uinit.c */

View File

@ -47,12 +47,13 @@ short ubik_initializationState; /*!< initial state is zero */
* \brief Parse list for clients.
*/
int
ubik_ParseClientList(int argc, char **argv, afs_int32 * aothers)
ubik_ParseClientList(int argc, char **argv, afs_uint32 * aothers)
{
register afs_int32 i;
register char *tp;
register struct hostent *th;
afs_int32 temp, counter;
afs_uint32 temp;
afs_int32 counter;
int inServer;
inServer = 0; /* haven't seen -servers yet */

View File

@ -36,21 +36,22 @@
* applications.
*/
int
ubik_ParseServerList(int argc, char **argv, afs_int32 *ahost,
afs_int32 *aothers)
ubik_ParseServerList(int argc, char **argv, afs_uint32 *ahost,
afs_uint32 *aothers)
{
register afs_int32 i;
register char *tp;
register struct hostent *th;
char hostname[64];
afs_int32 myHost, temp, counter;
afs_uint32 myHost, temp;
afs_int32 counter;
int inServer, sawServer;
gethostname(hostname, sizeof(hostname));
th = gethostbyname(hostname);
if (!th)
return UBADHOST;
memcpy(&myHost, th->h_addr, sizeof(afs_int32));
memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
*ahost = myHost;
inServer = 0; /* haven't seen -servers yet */
@ -68,7 +69,7 @@ ubik_ParseServerList(int argc, char **argv, afs_int32 *ahost,
th = gethostbyname(tp);
if (!th)
return UBADHOST;
memcpy(&temp, th->h_addr, sizeof(afs_int32));
memcpy(&temp, th->h_addr, sizeof(afs_uint32));
if (temp != myHost) {
if (counter++ >= MAXSERVERS)
return UNHOSTS;

View File

@ -39,7 +39,7 @@ main(int argc, char **argv)
{
register afs_int32 code;
struct ubik_client *cstruct = 0;
afs_int32 serverList[MAXSERVERS];
afs_uint32 serverList[MAXSERVERS];
struct rx_connection *serverconns[MAXSERVERS];
struct rx_securityClass *sc;
register afs_int32 i;

View File

@ -278,8 +278,8 @@ int
main(int argc, char **argv)
{
register afs_int32 code, i;
afs_int32 serverList[MAXSERVERS];
afs_int32 myHost;
afs_uint32 serverList[MAXSERVERS];
afs_uint32 myHost;
struct rx_service *tservice;
struct rx_securityClass *sc[2];
char dbfileName[128];

View File

@ -132,7 +132,7 @@ int
main(int argc, char **argv)
{
register afs_int32 code;
afs_int32 myHost;
afs_uint32 myHost;
struct rx_service *tservice;
struct rx_securityClass **securityClasses;
afs_int32 numClasses;
@ -300,7 +300,7 @@ main(int argc, char **argv)
hostname);
exit(1);
}
memcpy(&myHost, th->h_addr, sizeof(afs_int32));
memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
#if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV)
signal(SIGXCPU, CheckSignal_Signal);