2023-02-18 23:37:11 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jsimonetti/rtnetlink"
|
2024-01-03 19:33:13 -06:00
|
|
|
"go.wit.com/log"
|
2023-02-18 23:37:11 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// List all interfaces
|
|
|
|
func Example_listLink() {
|
|
|
|
// Dial a connection to the rtnetlink socket
|
|
|
|
conn, err := rtnetlink.Dial(nil)
|
|
|
|
if err != nil {
|
2024-01-03 19:33:13 -06:00
|
|
|
log.Error(err, "Example_listLink() failed")
|
2023-03-28 08:53:51 -05:00
|
|
|
return
|
2023-02-18 23:37:11 -06:00
|
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
|
|
|
|
// Request a list of interfaces
|
|
|
|
msg, err := conn.Link.List()
|
|
|
|
if err != nil {
|
2023-12-16 09:02:59 -06:00
|
|
|
log.Println(err)
|
2023-02-18 23:37:11 -06:00
|
|
|
}
|
|
|
|
|
2023-12-16 09:02:59 -06:00
|
|
|
log.Println("%#v", msg)
|
|
|
|
log.Println(SPEW, msg)
|
2023-02-18 23:37:11 -06:00
|
|
|
}
|