From bbe3648e2108393f3132ede777c19e00a9d5a547 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 16 Jun 2020 10:00:42 +0200 Subject: Add an address to task --- announce.c | 13 +++++-------- main.h | 1 + utils.h | 2 ++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/announce.c b/announce.c index 6d17faf..7f69e51 100644 --- a/announce.c +++ b/announce.c @@ -14,9 +14,7 @@ struct announce { uint64_t value; struct uring_task task; - struct uring_task mcast_task; - struct sockaddr_in mcast_addr; }; static void @@ -50,8 +48,8 @@ mcast_send(struct cfg *cfg, struct announce *aev, struct server *server) return; } - server->mcast_msg.msg_name = &aev->mcast_addr; - server->mcast_msg.msg_namelen = sizeof(aev->mcast_addr); + server->mcast_msg.msg_name = &aev->mcast_task.addr; + server->mcast_msg.msg_namelen = sizeof(aev->mcast_task.addr); server->mcast_iov.iov_len = len; uring_sendmsg(cfg, &aev->mcast_task, &server->mcast_msg, mcast_sent); @@ -181,10 +179,9 @@ announce_init(struct cfg *cfg) uring_task_init(&aev->mcast_task, "aev_mcast", &aev->task, mcast_free); uring_task_set_fd(&aev->mcast_task, sfd); - memset(&aev->mcast_addr, 0, sizeof(aev->mcast_addr)); - aev->mcast_addr.sin_family = AF_INET; - aev->mcast_addr.sin_addr.s_addr = inet_addr("224.0.2.60"); - aev->mcast_addr.sin_port = htons(4445); + aev->mcast_task.addr.in4.sin_family = AF_INET; + aev->mcast_task.addr.in4.sin_addr.s_addr = inet_addr("224.0.2.60"); + aev->mcast_task.addr.in4.sin_port = htons(4445); cfg->aev = aev; uring_read(cfg, &aev->task, &aev->value, sizeof(aev->value), announce_cb); diff --git a/main.h b/main.h index dbca512..d2efe9f 100644 --- a/main.h +++ b/main.h @@ -44,6 +44,7 @@ struct uring_task { callback_t callback; rcallback_t complete_callback; /* to check if tbuf processing is done */ callback_t final_callback; /* once tbuf processing is done */ + struct sockaddr_in46 addr; /* used for recvmsg/sendmsg */ void *priv; }; diff --git a/utils.h b/utils.h index 48faef4..6d09522 100644 --- a/utils.h +++ b/utils.h @@ -4,6 +4,7 @@ #include #include #include +#include struct list_head { struct list_head *next; @@ -30,6 +31,7 @@ struct sockaddr_in46 { struct sockaddr_storage storage; struct sockaddr_in in4; struct sockaddr_in6 in6; + struct sockaddr_ll ll; }; socklen_t addrlen; struct list_head list; -- cgit v1.2.3