示例#1
0
文件: pcap.go 项目: dlintw/gopcap
func DatalinkValueToDescription(dlt int) string {
	desc := C.pcap_datalink_val_to_description(C.int(dlt))
	if nil != desc {
		return C.GoString(desc)
	}
	return ""
}
示例#2
0
文件: pcap.go 项目: alvinlee/gopcap
func DatalinkDesc(dlt int) (ret string) {
	desc := C.pcap_datalink_val_to_description(C.int(dlt))
	if desc != nil {
		ret = C.GoString(desc)
	}
	return
}
示例#3
0
文件: pcap.go 项目: hongruiqi/gopcap
func DatalinkValueToDescription(dlt int) error {
	desc := C.pcap_datalink_val_to_description(C.int(dlt))
	if nil != desc {
		return errors.New(C.GoString(desc))
	}
	return nil
}
示例#4
0
文件: pcap.go 项目: donckers/gopacket
// Obtains a list of all possible data link types supported for an interface.
func (p *Handle) ListDataLinks() (datalinks []Datalink, err error) {
	var dlt_buf *C.int

	n := int(C.pcap_list_datalinks(p.cptr, &dlt_buf))
	if -1 == n {
		return nil, p.Error()
	}

	defer C.pcap_free_datalinks(dlt_buf)

	datalinks = make([]Datalink, n)

	dltArray := (*[100]C.int)(unsafe.Pointer(dlt_buf))

	for i := 0; i < n; i++ {
		expr := C.pcap_datalink_val_to_name((*dltArray)[i])
		datalinks[i].Name = C.GoString(expr)

		expr = C.pcap_datalink_val_to_description((*dltArray)[i])
		datalinks[i].Description = C.GoString(expr)
	}

	return datalinks, nil
}
示例#5
0
func DatalinkValueToDescription(dlt int) string {
	if desc := C.pcap_datalink_val_to_description(C.int(dlt)); desc != nil {
		return C.GoString(desc)
	}
	return ""
}