From 9dab3985812e75071271ce69000561156d0d9374 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Thu, 27 Dec 2018 15:42:00 +0100 Subject: include: Add a flow_join operation for broadcast This adds a new flow_join operaiton for broadcast, which is a much safer solution than overloading destination name semantics. The internal API now also has a different IPCP_FLOW_JOIN operation. The IRMd doesn't need to query broadcasts IPCPs for the name, it can just check if an IPCP with the layer name exists. The broadcast IPCP doesn't need to implement the query proxy call anymore. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/broadcast/main.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'src/ipcpd/broadcast') diff --git a/src/ipcpd/broadcast/main.c b/src/ipcpd/broadcast/main.c index 8c6bfa71..af39dd34 100644 --- a/src/ipcpd/broadcast/main.c +++ b/src/ipcpd/broadcast/main.c @@ -198,31 +198,18 @@ static int broadcast_ipcp_bootstrap(const struct ipcp_config * conf) return -1; } -static int broadcast_ipcp_query(const uint8_t * dst) +static int name_check(const uint8_t * dst) { uint8_t * buf; size_t len; int ret; - char * multicast_name; - char * suffix = ".mc"; len = hash_len(ipcpi.dir_hash_algo); buf = malloc(len); if (buf == NULL) return -ENOMEM; - multicast_name = malloc(strlen(ipcpi.layer_name) + strlen(suffix) + 1); - if (multicast_name == NULL) { - free(buf); - return -ENOMEM; - } - - strcpy(multicast_name, ipcpi.layer_name); - strcat(multicast_name, suffix); - - str_hash(ipcpi.dir_hash_algo, buf, multicast_name); - - free(multicast_name); + str_hash(ipcpi.dir_hash_algo, buf, ipcpi.layer_name); ret = memcmp(buf, dst, len); @@ -231,9 +218,9 @@ static int broadcast_ipcp_query(const uint8_t * dst) return ret; } -static int broadcast_ipcp_alloc(int fd, - const uint8_t * dst, - qosspec_t qs) +static int broadcast_ipcp_join(int fd, + const uint8_t * dst, + qosspec_t qs) { struct conn conn; @@ -243,7 +230,7 @@ static int broadcast_ipcp_alloc(int fd, conn.flow_info.fd = fd; - if (broadcast_ipcp_query(dst) != 0) + if (name_check(dst) != 0) return -1; notifier_event(NOTIFY_DT_CONN_ADD, &conn); @@ -276,8 +263,9 @@ static struct ipcp_ops broadcast_ops = { .ipcp_disconnect = connmgr_ipcp_disconnect, .ipcp_reg = NULL, .ipcp_unreg = NULL, - .ipcp_query = broadcast_ipcp_query, - .ipcp_flow_alloc = broadcast_ipcp_alloc, + .ipcp_query = NULL, + .ipcp_flow_alloc = NULL, + .ipcp_flow_join = broadcast_ipcp_join, .ipcp_flow_alloc_resp = NULL, .ipcp_flow_dealloc = broadcast_ipcp_dealloc }; -- cgit v1.2.3