sd-ndisc: make callback takes arbitrary type of message

No functional change. Preparation for supporting Neighbor Advertisement
message.
This commit is contained in:
Yu Watanabe
2024-02-25 11:38:58 +00:00
committed by Luca Boccassi
parent c75d119658
commit 28eef15898
4 changed files with 10 additions and 7 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ static const char * const ndisc_event_table[_SD_NDISC_EVENT_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event_t);
static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event_t event, sd_ndisc_router *rt) {
static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event_t event, void *message) {
assert(ndisc);
assert(event >= 0 && event < _SD_NDISC_EVENT_MAX);
@@ -39,7 +39,7 @@ static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event_t event, sd_ndisc_rou
return (void) log_ndisc(ndisc, "Received '%s' event.", ndisc_event_to_string(event));
log_ndisc(ndisc, "Invoking callback for '%s' event.", ndisc_event_to_string(event));
ndisc->callback(ndisc, event, rt, ndisc->userdata);
ndisc->callback(ndisc, event, message, ndisc->userdata);
}
int sd_ndisc_is_running(sd_ndisc *nd) {
+3 -1
View File
@@ -202,7 +202,7 @@ static int send_ra(uint8_t flags) {
return 0;
}
static void test_callback(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata) {
static void test_callback(sd_ndisc *nd, sd_ndisc_event_t event, void *message, void *userdata) {
sd_event *e = userdata;
static unsigned idx = 0;
uint64_t flags_array[] = {
@@ -219,6 +219,8 @@ static void test_callback(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router
if (event != SD_NDISC_EVENT_ROUTER)
return;
sd_ndisc_router *rt = ASSERT_PTR(message);
router_dump(rt);
assert_se(sd_ndisc_router_get_flags(rt, &flags) >= 0);