func (it *TableIterator) Key() []byte {
	return it.key
}
Key returns the current key value of the iterator, if the most recent call to Next returned true.
The slice is valid only until the next call to Next.
package bcc
import (
	"bytes"
	"errors"
	"fmt"
	"os"
	"unsafe"
)
import "C"
var errIterationFailed = errors.New("table.Iter: leaf for next key not found")
type Table struct {
	id     C.size_t
	module *Module
}
func NewTable(id C.size_t, module *Module) *Table {
	return &Table{
		id:     id,
		module: module,
	}
}
func (table *Table) ID() string {
	return C.GoString(C.bpf_table_name(table.module.p, table.id))
}
func (table *Table) Name() string {
	return C.GoString(C.bpf_table_name(table.module.p, table.id))
}
func (table *Table) Config() map[string]interface{} {
	mod := table.module.p
	return map[string]interface{}{
		"name":      C.GoString(C.bpf_table_name(mod, table.id)),
		"fd":        int(C.bpf_table_fd_id(mod, table.id)),
		"key_size":  uint64(C.bpf_table_key_size_id(mod, table.id)),
		"leaf_size": uint64(C.bpf_table_leaf_size_id(mod, table.id)),
		"key_desc":  C.GoString(C.bpf_table_key_desc_id(mod, table.id)),
		"leaf_desc": C.GoString(C.bpf_table_leaf_desc_id(mod, table.id)),
	}
}
func (table *Table) LeafStrToBytes(leafStr string) ([]byte, error) {
	mod := table.module.p
	leafSize := C.bpf_table_leaf_size_id(mod, table.id)
	leaf := make([]byte, leafSize)
	leafP := unsafe.Pointer(&leaf[0])
	leafCS := C.CString(leafStr)
	defer C.free(unsafe.Pointer(leafCS))
	r := C.bpf_table_leaf_sscanf(mod, table.id, leafCS, leafP)
	if r != 0 {
		return nil, fmt.Errorf("error scanning leaf (%v) from string", leafStr)
	}
	return leaf, nil
}
func (table *Table) KeyStrToBytes(keyStr string) ([]byte, error) {
	mod := table.module.p
	keySize := C.bpf_table_key_size_id(mod, table.id)
	key := make([]byte, keySize)
	keyP := unsafe.Pointer(&key[0])
	keyCS := C.CString(keyStr)
	defer C.free(unsafe.Pointer(keyCS))
	r := C.bpf_table_key_sscanf(mod, table.id, keyCS, keyP)
	if r != 0 {
		return nil, fmt.Errorf("error scanning key (%v) from string", keyStr)
	}
	return key, nil
}
func (table *Table) KeyBytesToStr(key []byte) (string, error) {
	keySize := len(key)
	keyP := unsafe.Pointer(&key[0])
	keyStr := make([]byte, keySize*8)
	keyStrP := (*C.char)(unsafe.Pointer(&keyStr[0]))
	if res := C.bpf_table_key_snprintf(table.module.p, table.id, keyStrP, C.size_t(len(keyStr)), keyP); res != 0 {
		return "", fmt.Errorf("formatting table-key: %d", res)
	}
	return string(keyStr[:bytes.IndexByte(keyStr, 0)]), nil
}
func (table *Table) LeafBytesToStr(leaf []byte) (string, error) {
	leafSize := len(leaf)
	leafP := unsafe.Pointer(&leaf[0])
	leafStr := make([]byte, leafSize*8)
	leafStrP := (*C.char)(unsafe.Pointer(&leafStr[0]))
	if res := C.bpf_table_leaf_snprintf(table.module.p, table.id, leafStrP, C.size_t(len(leafStr)), leafP); res != 0 {
		return "", fmt.Errorf("formatting table-leaf: %d", res)
	}
	return string(leafStr[:bytes.IndexByte(leafStr, 0)]), nil
}
func (table *Table) Get(key []byte) ([]byte, error) {
	mod := table.module.p
	fd := C.bpf_table_fd_id(mod, table.id)
	keyP := unsafe.Pointer(&key[0])
	leafSize := C.bpf_table_leaf_size_id(mod, table.id)
	leaf := make([]byte, leafSize)
	leafP := unsafe.Pointer(&leaf[0])
	r, err := C.bpf_lookup_elem(fd, keyP, leafP)
	if r != 0 {
		keyStr, errK := table.KeyBytesToStr(key)
		if errK != nil {
			keyStr = fmt.Sprintf("%v", key)
		}
		return nil, fmt.Errorf("Table.Get: key %v: %v", keyStr, err)
	}
	return leaf, nil
}
func (table *Table) GetP(key unsafe.Pointer) (unsafe.Pointer, error) {
	fd := C.bpf_table_fd_id(table.module.p, table.id)
	leafSize := C.bpf_table_leaf_size_id(table.module.p, table.id)
	leaf := make([]byte, leafSize)
	leafP := unsafe.Pointer(&leaf[0])
	_, err := C.bpf_lookup_elem(fd, key, leafP)
	if err != nil {
		return nil, err
	}
	return leafP, nil
}
func (table *Table) Set(key, leaf []byte) error {
	fd := C.bpf_table_fd_id(table.module.p, table.id)
	keyP := unsafe.Pointer(&key[0])
	leafP := unsafe.Pointer(&leaf[0])
	r, err := C.bpf_update_elem(fd, keyP, leafP, 0)
	if r != 0 {
		keyStr, errK := table.KeyBytesToStr(key)
		if errK != nil {
			keyStr = fmt.Sprintf("%v", key)
		}
		leafStr, errL := table.LeafBytesToStr(leaf)
		if errL != nil {
			leafStr = fmt.Sprintf("%v", leaf)
		}
		return fmt.Errorf("Table.Set: update %v to %v: %v", keyStr, leafStr, err)
	}
	return nil
}
func (table *Table) SetP(key, leaf unsafe.Pointer) error {
	fd := C.bpf_table_fd_id(table.module.p, table.id)
	_, err := C.bpf_update_elem(fd, key, leaf, 0)
	if err != nil {
		return err
	}
	return nil
}
func (table *Table) Delete(key []byte) error {
	fd := C.bpf_table_fd_id(table.module.p, table.id)
	keyP := unsafe.Pointer(&key[0])
	r, err := C.bpf_delete_elem(fd, keyP)
	if r != 0 {
		keyStr, errK := table.KeyBytesToStr(key)
		if errK != nil {
			keyStr = fmt.Sprintf("%v", key)
		}
		return fmt.Errorf("Table.Delete: key %v: %v", keyStr, err)
	}
	return nil
}
func (table *Table) DeleteP(key unsafe.Pointer) error {
	fd := C.bpf_table_fd_id(table.module.p, table.id)
	_, err := C.bpf_delete_elem(fd, key)
	if err != nil {
		return err
	}
	return nil
}
func (table *Table) DeleteAll() error {
	mod := table.module.p
	fd := C.bpf_table_fd_id(mod, table.id)
	keySize := C.bpf_table_key_size_id(mod, table.id)
	key := make([]byte, keySize)
	keyP := unsafe.Pointer(&key[0])
	for res := C.bpf_get_first_key(fd, keyP, keySize); res == 0; res = C.bpf_get_next_key(fd, keyP, keyP) {
		r, err := C.bpf_delete_elem(fd, keyP)
		if r != 0 {
			return fmt.Errorf("Table.DeleteAll: unable to delete element: %v", err)
		}
	}
	return nil
}
type TableIterator struct {
	table *Table
	fd    C.int
	err error
	key  []byte
	leaf []byte
}
func (table *Table) Iter() *TableIterator {
	fd := C.bpf_table_fd_id(table.module.p, table.id)
	return &TableIterator{
		table: table,
		fd:    fd,
	}
}
func (it *TableIterator) Next() bool {
	if it.err != nil {
		return false
	}
	if it.key == nil {
		keySize := C.bpf_table_key_size_id(it.table.module.p, it.table.id)
		key := make([]byte, keySize)
		keyP := unsafe.Pointer(&key[0])
		if res, err := C.bpf_get_first_key(it.fd, keyP, keySize); res != 0 {
			if !os.IsNotExist(err) {
				it.err = err
			}
			return false
		}
		leafSize := C.bpf_table_leaf_size_id(it.table.module.p, it.table.id)
		leaf := make([]byte, leafSize)
		it.key = key
		it.leaf = leaf
	} else {
		keyP := unsafe.Pointer(&it.key[0])
		if res, err := C.bpf_get_next_key(it.fd, keyP, keyP); res != 0 {
			if !os.IsNotExist(err) {
				it.err = err
			}
			return false
		}
	}
	keyP := unsafe.Pointer(&it.key[0])
	leafP := unsafe.Pointer(&it.leaf[0])
	if res, err := C.bpf_lookup_elem(it.fd, keyP, leafP); res != 0 {
		it.err = errIterationFailed
		if !os.IsNotExist(err) {
			it.err = err
		}
		return false
	}
	return true
}