Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/linux/netlinkutil/Address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ bool Address::IsIpv4() const noexcept
return m_family == AF_INET;
}

bool Address::IsLinkLocal() const
{
if (m_family == AF_INET)
{
return (ntohl(AsBytes<in_addr>().s_addr) & 0xFFFF0000) == 0xA9FE0000;
}

const auto bytes = AsBytes<in6_addr>();
return bytes.s6_addr[0] == 0xFE && (bytes.s6_addr[1] & 0xC0) == 0x80;
}
Comment on lines +144 to +153

bool Address::IsPrefixRouteAutogenerationDisabled() const noexcept
{
return m_disableAutogeneratedPrefixRoute;
Expand Down
4 changes: 4 additions & 0 deletions src/linux/netlinkutil/RoutingTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ void RoutingTable::SendMessage(const Route& route, int operation, int flags, con
message.route.rtm_type = route.IsMulticast() ? RTN_MULTICAST : RTN_UNICAST;
message.route.rtm_scope = route.IsOnlink() ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE;
message.route.rtm_flags = RTM_F_NOTIFY;
if (route.via.has_value() && route.via.value().IsLinkLocal())
{
message.route.rtm_flags |= RTNH_F_ONLINK;
}
Comment on lines 139 to +145
message.route.rtm_dst_len = route.to.has_value() ? route.to.value().PrefixLength() : 0;

utils::InitializeIntegerAttribute(message.tableId, m_table, RTA_TABLE);
Expand Down
1 change: 1 addition & 0 deletions src/linux/netlinkutil/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Address
int Scope() const noexcept;
int PreferredLifetime() const noexcept;
bool IsIpv4() const noexcept;
bool IsLinkLocal() const;
bool IsPrefixRouteAutogenerationDisabled() const noexcept;

private:
Expand Down
Loading