2023-02-18 23:37:11 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-12-16 09:02:59 -06:00
|
|
|
"log"
|
2023-02-18 23:37:11 -06:00
|
|
|
"github.com/jsimonetti/rtnetlink"
|
|
|
|
)
|
|
|
|
|
|
|
|
// List all interfaces
|
|
|
|
func Example_listLink() {
|
|
|
|
// Dial a connection to the rtnetlink socket
|
|
|
|
conn, err := rtnetlink.Dial(nil)
|
|
|
|
if err != nil {
|
2023-12-20 03:13:43 -06:00
|
|
|
debug(LogError, "Example_listLink() failed", err)
|
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
|
|
|
}
|