Exemplo n.º 1
0
func DatalinkValueToName(dlt int) string {
	name := C.pcap_datalink_val_to_name(C.int(dlt))
	if nil != name {
		return C.GoString(name)
	}
	return ""
}
Exemplo n.º 2
0
func DatalinkName(dlt int) (ret string) {
	name := C.pcap_datalink_val_to_name(C.int(dlt))
	if name != nil {
		ret = C.GoString(name)
	}
	return
}
Exemplo n.º 3
0
func DatalinkValueToName(dlt int) error {
	name := C.pcap_datalink_val_to_name(C.int(dlt))
	if nil != name {
		return errors.New(C.GoString(name))
	}
	return nil
}
Exemplo n.º 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
}