00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _CHIMERA_H_
00009 #define _CHIMERA_H_
00010
00011 #include "host.h"
00012 #include "key.h"
00013 #include "log.h"
00014 #include <pthread.h>
00015 #include "message.h"
00016 #include "semaphore.h"
00017
00018
00019 typedef void (*chimera_forward_upcall_t)(Key **, Message **, ChimeraHost **);
00020 typedef void (*chimera_deliver_upcall_t)(Key *, Message *);
00021 typedef void (*chimera_update_upcall_t)(Key *, ChimeraHost *, int);
00022
00023 typedef struct {
00024 ChimeraHost *me;
00025 ChimeraHost *bootstrap;
00026 void *join;
00027 pthread_mutex_t lock;
00028 chimera_forward_upcall_t forward;
00029 chimera_deliver_upcall_t deliver;
00030 chimera_update_upcall_t update;
00031 Sema globalSeqNum;
00032 } ChimeraGlobal;
00033
00039 ChimeraState *chimera_init(int port);
00040
00045 void chimera_join(ChimeraState *state,ChimeraHost *bootstrap);
00046
00052 void chimera_route(ChimeraState *state, Key *key, Message *msg, ChimeraHost *hint);
00053
00060 void chimera_forward(ChimeraState *state, chimera_forward_upcall_t func);
00061
00067 void chimera_deliver(ChimeraState *state,chimera_deliver_upcall_t func);
00068
00074 void chimera_update(ChimeraState *state,chimera_update_upcall_t func);
00075
00079 void chimera_setkey(ChimeraState *state,Key key);
00080
00087 void chimera_register(ChimeraState *state, int type, int ack);
00088
00094 void chimera_send(ChimeraState *state, Key key, int type, int len, char *data);
00095
00100 int chimera_ping(ChimeraState *state,ChimeraHost *host);
00101
00102 #endif
00103