2020-07-06 10:34:52 -07:00
|
|
|
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package interfaces
|
|
|
|
|
|
|
|
import (
|
2021-03-02 21:13:29 -08:00
|
|
|
"syscall"
|
2020-07-06 10:34:52 -07:00
|
|
|
|
2021-03-02 21:13:29 -08:00
|
|
|
"golang.org/x/net/route"
|
2020-07-06 10:34:52 -07:00
|
|
|
)
|
|
|
|
|
2021-05-10 08:23:41 -07:00
|
|
|
// fetchRoutingTable calls route.FetchRIB, fetching NET_RT_DUMP2.
|
2021-04-23 13:23:19 -07:00
|
|
|
func fetchRoutingTable() (rib []byte, err error) {
|
2021-05-10 08:23:41 -07:00
|
|
|
return route.FetchRIB(syscall.AF_UNSPEC, syscall.NET_RT_DUMP2, 0)
|
2021-04-23 13:23:19 -07:00
|
|
|
}
|
|
|
|
|
2022-10-14 09:29:34 +01:00
|
|
|
func parseRoutingTable(rib []byte) ([]route.Message, error) {
|
|
|
|
return route.ParseRIB(syscall.NET_RT_IFLIST2, rib)
|
2021-03-15 13:00:20 -07:00
|
|
|
}
|