| 352 | } |
| 353 | |
| 354 | void netlink_connector::send_rt_request(std::uint32_t _retry) { |
| 355 | typedef struct { |
| 356 | struct nlmsghdr nlhdr; |
| 357 | struct rtgenmsg routemsg; |
| 358 | } netlink_route_msg; |
| 359 | |
| 360 | auto get_route_msg = std::make_shared<netlink_route_msg>(); |
| 361 | memset(get_route_msg.get(), 0, sizeof(*get_route_msg)); |
| 362 | get_route_msg->nlhdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)); |
| 363 | get_route_msg->nlhdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; |
| 364 | get_route_msg->nlhdr.nlmsg_type = RTM_GETROUTE; |
| 365 | // the sequence number has stored the request sequence and the retry count. |
| 366 | // request sequece is stored in the LSB (least significant byte) and |
| 367 | // retry is stored in the 2nd LSB. |
| 368 | get_route_msg->nlhdr.nlmsg_seq = rt_request_sequence_ | (_retry << retry_bit_shift_); |
| 369 | if (multicast_address_.is_v6()) { |
| 370 | get_route_msg->routemsg.rtgen_family = AF_INET6; |
| 371 | } else { |
| 372 | get_route_msg->routemsg.rtgen_family = AF_INET; |
| 373 | } |
| 374 | |
| 375 | { |
| 376 | std::scoped_lock its_lock(socket_mutex_); |
| 377 | socket_.async_send(boost::asio::buffer(get_route_msg.get(), sizeof(*get_route_msg)), |
| 378 | [self = shared_from_this(), data = get_route_msg](auto... args) mutable { |
| 379 | self->send_cbk(args...); |
| 380 | data.reset(); |
| 381 | }); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | bool netlink_connector::has_address(const struct ifaddrmsg* ifa_struct, size_t length) const { |
| 386 | auto retrta = static_cast<const struct rtattr*>(IFA_RTA(ifa_struct)); |