Exemple #1
0
func DatalinkValueToDescription(dlt int) string {
	desc := C.pcap_datalink_val_to_description(C.int(dlt))
	if nil != desc {
		return C.GoString(desc)
	}
	return ""
}
Exemple #2
0
func DatalinkDesc(dlt int) (ret string) {
	desc := C.pcap_datalink_val_to_description(C.int(dlt))
	if desc != nil {
		ret = C.GoString(desc)
	}
	return
}
Exemple #3
0
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
}
Exemple #4
0
// 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
}
Exemple #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 ""
}