view src/director/director-host.h @ 11321:5f350b5ff6d9 HEAD

Added initial implementation of a director process (for NFS users). There are still some unimplemented features and bugs. Also changing mail server list doesn't yet make sure that other directors won't assign the same user to a different server at the same time.
author Timo Sirainen <tss@iki.fi>
date Wed, 19 May 2010 09:56:49 +0200
parents
children 9d886ae434c3
line wrap: on
line source

#ifndef DIRECTOR_HOST_H
#define DIRECTOR_HOST_H

#include "network.h"

struct director;

struct director_host {
	struct ip_addr ip;
	unsigned int port;

	/* name contains "ip:port" */
	char *name;

	/* each command between directors contains an increasing sequence.
	   if director A gets conflicting information about director B, it can
	   trust the one that has the highest sequence. */
	unsigned int last_seq;

	/* we are this director */
	unsigned int self:1;
};

struct director_host *
director_host_add(struct director *dir, const struct ip_addr *ip,
		  unsigned int port);
void director_host_free(struct director_host *host);

struct director_host *
director_host_get(struct director *dir, const struct ip_addr *ip,
		  unsigned int port);
struct director_host *
director_host_lookup(struct director *dir, const struct ip_addr *ip,
		     unsigned int port);
struct director_host *
director_host_lookup_ip(struct director *dir, const struct ip_addr *ip);

/* Returns -1 if b1 is more on our left side than b2, 1 if b2 is,
   0 if they equal. */
int director_host_cmp_to_self(const struct director_host *b1,
			      const struct director_host *b2,
			      const struct director_host *self);

/* Parse hosts list (e.g. "host1:port host2 host3:port") and them as
   directors */
void director_host_add_from_string(struct director *dir, const char *hosts);

#endif