static int events_cb(const struct nlmsghdr *nlh, void *data) { int ret = MNL_CB_OK; int event = NFNL_MSG_TYPE(nlh->nlmsg_type); int type = *((int *)data); switch(event) { case NFT_MSG_NEWTABLE: case NFT_MSG_DELTABLE: ret = table_cb(nlh, event, type); break; case NFT_MSG_NEWCHAIN: case NFT_MSG_DELCHAIN: ret = chain_cb(nlh, event, type); break; case NFT_MSG_NEWRULE: case NFT_MSG_DELRULE: ret = rule_cb(nlh, event, type); break; case NFT_MSG_NEWSET: case NFT_MSG_DELSET: ret = set_cb(nlh, event, type); break; case NFT_MSG_NEWSETELEM: case NFT_MSG_DELSETELEM: ret = setelem_cb(nlh, event, type); break; case NFT_MSG_NEWGEN: ret = gen_cb(nlh, event, type); break; } return ret; }
static int events_cb(const struct nlmsghdr *nlh, void *data) { int event = NFNL_MSG_TYPE(nlh->nlmsg_type); struct callback_data *cb = data; int err = MNL_CB_OK; if (!cb || cb->type == CALLBACK_RETURN_NONE) return err; DBG("handle event %s", event_to_str(event)); switch(event) { case NFT_MSG_NEWCHAIN: err = chain_cb(nlh, event, cb); break; case NFT_MSG_NEWRULE: err = rule_cb(nlh, event, cb); break; default: DBG("unhandled event type %s", event_to_str(event)); break; } return err; }