summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-01-10 13:47:28 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-01-10 13:47:28 (GMT)
commit2532c73e35f699b366ca682bc058dc86c4660b5b (patch)
treec6a330b2846c75edf65db7b52b789ba398dc1be9
parent7043a6dfce69dd09722d8200ef518218f92b0e78 (diff)
sending messages to listener
-rw-r--r--openwrt/rhctl/Makefile2
-rw-r--r--switchctl.c34
2 files changed, 24 insertions, 12 deletions
diff --git a/openwrt/rhctl/Makefile b/openwrt/rhctl/Makefile
index 0fe6fb9..58a7e56 100644
--- a/openwrt/rhctl/Makefile
+++ b/openwrt/rhctl/Makefile
@@ -18,7 +18,7 @@ PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://localhost/
-PKG_MD5SUM:=885cb8a68c2e2a61909ae6a9f976af50
+PKG_MD5SUM:=b78c565d316a4d18c5b0959db3895576
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
diff --git a/switchctl.c b/switchctl.c
index ba81c46..b003909 100644
--- a/switchctl.c
+++ b/switchctl.c
@@ -432,6 +432,10 @@ void process_cmd_listen(const char* param, int fd, client_t* client_lst)
else if(!strncmp(param, "none", 4)) {
listener->request_listener = 0;
listener->status_listener = 0;
+ listener->gpi_listener = 0;
+ listener->oc_listener = 0;
+ listener->relay_listener = 0;
+ listener->silence_listener = 0;
}
else {
log_printf(DEBUG, "unkown listener type '%s'", param);
@@ -532,6 +536,19 @@ int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst, op
return 0;
}
+
+#define SEND_TO_LISTENER(STRING, LEN, FLAG) \
+ if(!strncmp(buffer->buf, STRING, LEN)) { \
+ client_t* client; \
+ int listener_cnt = 0; \
+ for(client = client_lst; client; client = client->next) \
+ if(client->FLAG && client->fd != cmd_fd) { \
+ send_response(client->fd, buffer->buf); \
+ listener_cnt++; \
+ } \
+ log_printf(DEBUG, "sent message to %d additional listeners", listener_cnt); \
+ } \
+
int process_switch(read_buffer_t* buffer, int switch_fd, cmd_t **cmd_q, client_t* client_lst)
{
int ret = 0;
@@ -572,17 +589,12 @@ int process_switch(read_buffer_t* buffer, int switch_fd, cmd_t **cmd_q, client_t
send_response(cmd_fd, buffer->buf);
}
- if(!strncmp(buffer->buf, "S0L", 3)) {
- client_t* client;
- int listener_cnt = 0;
- for(client = client_lst; client; client = client->next)
- if(client->status_listener && client->fd != cmd_fd) {
- send_response(client->fd, buffer->buf);
- listener_cnt++;
- }
- log_printf(DEBUG, "sent status to %d additional listeners", listener_cnt);
- }
-
+ SEND_TO_LISTENER("S0L", 3, status_listener);
+ SEND_TO_LISTENER("S0P", 3, gpi_listener);
+ SEND_TO_LISTENER("S0O", 3, oc_listener);
+ SEND_TO_LISTENER("S0R", 3, relay_listener);
+ SEND_TO_LISTENER("S0S", 3, silence_listener);
+
if((!strncmp(buffer->buf, "RRR", 3)) ||
(!strncmp(buffer->buf, "EEE", 3)))
cmd_pop(cmd_q);