Skip to content

Commit

Permalink
routing seems done.
Browse files Browse the repository at this point in the history
git-svn-id: https://subversion.cs.uiuc.edu/svn/bang/eoh2009@128 69d76c3e-0761-0410-948c-9895a8bb34fc
  • Loading branch information
nbysani2 committed Mar 7, 2009
1 parent b15d168 commit 421d303
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/base/bang-routing.c
Expand Up @@ -30,13 +30,36 @@ typedef struct {

static int uuid_hashcode(const void *uuid);
static int uuid_ptr_compare(const void *uuid1, const void *uuid2);
static peer_or_module *new_pom_module_route(BANG_module *module);
static peer_or_module *new_pom_peer_route(int peer_id, char *module_name, unsigned char *module_version);
static BANG_request* create_request(enum BANG_request_types request, uuid_t authority, uuid_t peer);
static BANG_request* create_request_with_message(enum BANG_request_types request, char *message);
static BANG_request* create_request_with_job(enum BANG_request_types request, uuid_t authority, uuid_t peer, BANG_job *job);

static BANG_hashmap *routes = NULL;

static int uuid_hashcode(const void *uuid) {
assert(uuid != NULL);

int hc = (*((uuid_t*)uuid)[0] << 2) & (*((uuid_t*)uuid)[15]);

return hc;
}

static int uuid_ptr_compare(const void *uuid1, const void *uuid2) {
return uuid_compare(*((uuid_t*)uuid1),*((uuid_t*)uuid2));
}

static peer_or_module *new_pom_module_route(BANG_module *module) {
peer_or_module *new = malloc(sizeof(peer_or_module));

new->remote = LOCAL;

new->mr = module;

return new;
}

static peer_or_module *new_pom_peer_route(int peer_id, char *module_name, unsigned char *module_version) {
peer_or_module *new = malloc(sizeof(peer_or_module));

Expand Down Expand Up @@ -223,7 +246,7 @@ void BANG_register_module_route(BANG_module *module) {

void BANG_register_peer_route(uuid_t uuid, int peer_id, char *module_name, unsigned char* module_version) {
assert(routes != NULL);
assert(!uuid_is_null(&uuid));
assert(!uuid_is_null(uuid));
assert(peer_id != -1);

peer_or_module *pom = new_pom_peer_route(peer_id,module_name,module_version);
Expand All @@ -238,7 +261,7 @@ void BANG_deregister_route(uuid_t route) {
}

void BANG_route_init() {
routes = new_BANG_hashmap(NULL,NULL);
routes = new_BANG_hashmap(&uuid_hashcode,&uuid_ptr_compare);
}

void BANG_route_close() {
Expand Down

0 comments on commit 421d303

Please sign in to comment.