2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-07-06 17:34:52 +00:00
|
|
|
|
|
|
|
package interfaces
|
|
|
|
|
|
|
|
import (
|
2021-03-03 05:13:29 +00:00
|
|
|
"syscall"
|
2020-07-06 17:34:52 +00:00
|
|
|
|
2021-03-03 05:13:29 +00:00
|
|
|
"golang.org/x/net/route"
|
2020-07-06 17:34:52 +00:00
|
|
|
)
|
|
|
|
|
2021-05-10 15:23:41 +00:00
|
|
|
// fetchRoutingTable calls route.FetchRIB, fetching NET_RT_DUMP2.
|
2021-04-23 20:23:19 +00:00
|
|
|
func fetchRoutingTable() (rib []byte, err error) {
|
2021-05-10 15:23:41 +00:00
|
|
|
return route.FetchRIB(syscall.AF_UNSPEC, syscall.NET_RT_DUMP2, 0)
|
2021-04-23 20:23:19 +00:00
|
|
|
}
|
|
|
|
|
2022-10-14 08:29:34 +00:00
|
|
|
func parseRoutingTable(rib []byte) ([]route.Message, error) {
|
|
|
|
return route.ParseRIB(syscall.NET_RT_IFLIST2, rib)
|
2021-03-15 20:00:20 +00:00
|
|
|
}
|