sigar/go_bindings/gotoc/netroute.go

58 lines
671 B
Go
Raw Normal View History

2016-01-04 18:23:11 +08:00
package gotoc
import (
"unsafe"
)
/*
#include "../../../../../Include/sigar.h"
*/
import "C"
func NetRoute() (C.sigar_net_route_list_t ,
[]C.sigar_net_route_t){
sigar:=GetSigarHandle()
var netlist C.sigar_net_route_list_t
C.sigar_net_route_list_get(sigar, &netlist)
var length int=int(netlist.number)
var goNetRoute =make([]C.sigar_net_route_t, length)
croute:=GetGoSlice(length, unsafe.Pointer(netlist.data))
goNetRoute = *(*[]C.sigar_net_route_t)(unsafe.Pointer(&croute))
C.sigar_net_route_list_destroy(sigar, &netlist)
return netlist, goNetRoute
}