diff --git a/event/lib/event.c b/event/lib/event.c index 59929f5a76ddabfee6054960331df7ae8e714f15..1de7067d5001ce8c6cc4d7a68bfca8cd20889035 100644 --- a/event/lib/event.c +++ b/event/lib/event.c @@ -12,6 +12,9 @@ #include <errno.h> #include <string.h> #include <unistd.h> +#include <netdb.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include "event.h" #include "log.h" @@ -23,6 +26,7 @@ #endif static char hostname[MAXHOSTNAMELEN]; +static char ipaddr[32]; /* * Register with the testbed event system. NAME specifies the name of @@ -53,15 +57,27 @@ static char hostname[MAXHOSTNAMELEN]; event_handle_t event_register(char *name, int threaded) { - event_handle_t handle; - elvin_handle_t server; - elvin_error_t status; + event_handle_t handle; + elvin_handle_t server; + elvin_error_t status; + struct hostent *he; + struct in_addr myip; if (gethostname(hostname, MAXHOSTNAMELEN) == -1) { ERROR("could not get hostname: %s\n", strerror(errno)); return 0; } + /* + * Get our IP address. Thats how we name ourselves to the + * Testbed Event System. + */ + if (! (he = gethostbyname(hostname))) { + ERROR("could not get IP address from hostname: %s", hostname); + } + memcpy((char *)&myip, he->h_addr, he->h_length); + strcpy(ipaddr, inet_ntoa(myip)); + TRACE("registering with event system (hostname=\"%s\")\n", hostname); /* Allocate a handle to be returned to the caller: */ @@ -387,6 +403,9 @@ event_notification_alloc(event_handle_t handle, address_tuple_t tuple) return NULL; } + /* Add our address */ + event_notification_set_sender(handle, notification, ipaddr); + return notification; } @@ -845,8 +864,11 @@ addclause(char *tag, char *clause, char *exp, int size, int *index) char *bp; char clausecopy[BUFSIZ], *strp = clausecopy; char buf[BUFSIZ]; + int needglob = 1; /* Must copy clause since we use strsep! */ + if (strlen(clause) >= sizeof(clausecopy)-1) + goto bad; strcpy(clausecopy, clause); /* @@ -858,6 +880,9 @@ addclause(char *tag, char *clause, char *exp, int size, int *index) /* Empty token (two delimiters next to each other) */ if (! *bp) continue; + + if (! strcmp("*", bp)) + needglob = 0; count += snprintf(&buf[count], sizeof(buf) - count, "%s %s == \"%s\" ", @@ -865,7 +890,16 @@ addclause(char *tag, char *clause, char *exp, int size, int *index) } if (strp || count >= sizeof(buf)) goto bad; - +#if 0 + if (needglob) { + count += snprintf(&buf[count], sizeof(buf) - count, + "%s %s == \"*\" ", + (count ? "||" : ""), tag); + + if (count >= size) + goto bad; + } +#endif /* * And wrap in parens (add an "and" if not the first clause). */ diff --git a/event/tbgen/tevd.c b/event/tbgen/tevd.c index 3d96bd86e53bad3272bbf075fe1ece9d55c1b3e5..2afbb15499188d8570849a0278a36df4422d26ae 100644 --- a/event/tbgen/tevd.c +++ b/event/tbgen/tevd.c @@ -135,8 +135,8 @@ callback(event_handle_t handle, event_notification_t notification, void *data) char eventtype[TBDB_FLEN_EVEVENTTYPE]; char ipaddr[32]; - event_notification_get_host(handle, notification, - ipaddr, sizeof(ipaddr)); + event_notification_get_sender(handle, notification, + ipaddr, sizeof(ipaddr)); event_notification_get_eventtype(handle, notification, eventtype, sizeof(eventtype));