003 File Manager
Current Path:
/usr/include
usr
/
include
/
📁
..
📄
Block.h
(1.96 KB)
📄
Block_private.h
(5.94 KB)
📄
FlexLexer.h
(6.73 KB)
📄
_ctype.h
(5.98 KB)
📄
_semaphore.h
(2.05 KB)
📄
a.out.h
(1.88 KB)
📄
aio.h
(7.69 KB)
📄
alias.h
(8.51 KB)
📄
ar.h
(2.69 KB)
📄
archive.h
(51.93 KB)
📄
archive_entry.h
(32.79 KB)
📁
arpa
📄
asn1-common.h
(2.06 KB)
📄
asn1_err.h
(1.07 KB)
📄
assert.h
(2.93 KB)
📁
atf-c
📁
atf-c++
📄
atf-c++.hpp
(1.49 KB)
📄
atf-c.h
(1.5 KB)
📄
base64.h
(1.99 KB)
📄
be.h
(5.32 KB)
📄
bitstring.h
(1.53 KB)
📄
blacklist.h
(2.2 KB)
📄
bluetooth.h
(6.65 KB)
📄
bsdxml.h
(40.5 KB)
📄
bsdxml_external.h
(5.4 KB)
📁
bsm
📁
bsnmp
📄
bzlib.h
(6.09 KB)
📁
c++
📄
calendar.h
(1.83 KB)
📁
cam
📄
camlib.h
(7.39 KB)
📄
capsicum_helpers.h
(4.33 KB)
📁
casper
📄
cms_asn1.h
(27.2 KB)
📄
com_err.h
(2.62 KB)
📄
com_right.h
(2.8 KB)
📄
complex.h
(4.68 KB)
📄
cpio.h
(2.4 KB)
📄
crmf_asn1.h
(13.31 KB)
📁
crypto
📄
ctype.h
(4.59 KB)
📄
curses.h
(97.92 KB)
📄
cuse.h
(3.26 KB)
📄
db.h
(7.49 KB)
📄
der-private.h
(1.29 KB)
📄
der-protos.h
(10.5 KB)
📄
der.h
(3.08 KB)
📁
dev
📄
devctl.h
(2.02 KB)
📁
devdctl
📄
devinfo.h
(4.52 KB)
📄
devstat.h
(5.2 KB)
📄
dialog.h
(37.7 KB)
📄
digest_asn1.h
(17.01 KB)
📄
dirent.h
(4.13 KB)
📄
dlfcn.h
(5.04 KB)
📄
dlg_colors.h
(6.87 KB)
📄
dlg_config.h
(2.64 KB)
📄
dlg_keys.h
(5.23 KB)
📄
dpv.h
(5.76 KB)
📄
dtrace.h
(23.64 KB)
📄
dwarf.h
(20.09 KB)
📁
edit
📄
efivar-dp.h
(2.58 KB)
📄
efivar.h
(3.75 KB)
📄
elf-hints.h
(1.96 KB)
📄
elf.h
(1.59 KB)
📄
err.h
(2.98 KB)
📄
errno.h
(8.29 KB)
📄
eti.h
(2.9 KB)
📄
execinfo.h
(1.92 KB)
📄
fcntl.h
(12.02 KB)
📄
fenv.h
(8.19 KB)
📄
fetch.h
(4.87 KB)
📄
figpar.h
(3.84 KB)
📄
float.h
(86 B)
📄
floatingpoint.h
(2.01 KB)
📄
fmtmsg.h
(2.76 KB)
📄
fmtutils.h
(2.19 KB)
📄
fnmatch.h
(2.32 KB)
📄
form.h
(18.37 KB)
📁
fs
📄
fstab.h
(3.03 KB)
📄
fts.h
(5.47 KB)
📄
ftw.h
(2.26 KB)
📁
gcc
📄
gelf.h
(5 KB)
📁
geom
📄
getarg.h
(3.15 KB)
📄
getopt.h
(2.73 KB)
📄
glob.h
(4.21 KB)
📄
grp.h
(3.21 KB)
📁
gssapi
📄
gssapi.h
(158 B)
📄
hdb-protos.h
(7.24 KB)
📄
hdb.h
(9.85 KB)
📄
hdb_asn1.h
(16.72 KB)
📄
hdb_err.h
(944 B)
📄
heim_asn1.h
(2.33 KB)
📄
heim_err.h
(1.46 KB)
📄
heim_threads.h
(6.91 KB)
📄
heimbase.h
(5.1 KB)
📄
heimntlm-protos.h
(3.78 KB)
📄
heimntlm.h
(4.85 KB)
📄
hex.h
(2.08 KB)
📄
histedit.h
(9.16 KB)
📄
hx509-private.h
(9.39 KB)
📄
hx509-protos.h
(22.53 KB)
📄
hx509.h
(5.88 KB)
📄
hx509_err.h
(3.04 KB)
📄
iconv.h
(4.23 KB)
📄
ieeefp.h
(261 B)
📄
ifaddrs.h
(2.09 KB)
📁
infiniband
📄
inttypes.h
(2.2 KB)
📄
iso646.h
(1.67 KB)
📁
isofs
📄
jail.h
(2.46 KB)
📄
k524_err.h
(724 B)
📁
kadm5
📄
kafs.h
(7.09 KB)
📄
kdc-protos.h
(2.25 KB)
📄
kdc.h
(3.5 KB)
📄
kenv.h
(1.58 KB)
📁
krb5
📄
krb5-private.h
(12.91 KB)
📄
krb5-protos.h
(113.43 KB)
📄
krb5-types.h
(1.48 KB)
📄
krb5.h
(29.75 KB)
📄
krb5_asn1.h
(70.51 KB)
📄
krb5_ccapi.h
(7.52 KB)
📄
krb5_err.h
(7.37 KB)
📄
kvm.h
(4.11 KB)
📄
kx509_asn1.h
(4.61 KB)
📄
langinfo.h
(3.95 KB)
📁
lib80211
📁
lib9p
📄
libcasper.h
(6.53 KB)
📄
libcasper_service.h
(2.5 KB)
📄
libdwarf.h
(32.98 KB)
📄
libelf.h
(7.72 KB)
📄
libgen.h
(2.65 KB)
📄
libgeom.h
(4.47 KB)
📄
libgpio.h
(3.48 KB)
📁
libipt
📁
libmilter
📄
libnetmap.h
(24.54 KB)
📄
libproc.h
(5.51 KB)
📄
libprocstat.h
(7.57 KB)
📄
librss.h
(2.96 KB)
📄
libufs.h
(5.08 KB)
📄
libusb.h
(22.05 KB)
📄
libusb20.h
(12.45 KB)
📄
libusb20_desc.h
(17.6 KB)
📄
libutil.h
(8.04 KB)
📁
libxo
📄
libzfs.h
(32.8 KB)
📄
libzfs_core.h
(5.1 KB)
📄
libzfsbootenv.h
(1.22 KB)
📄
limits.h
(4.7 KB)
📄
link.h
(1.71 KB)
📄
linker_set.h
(3.85 KB)
📄
locale.h
(2.64 KB)
📄
login_cap.h
(6.25 KB)
📁
lzma
📄
lzma.h
(9.63 KB)
📁
machine
📄
magic.h
(5.64 KB)
📄
malloc.h
(102 B)
📄
malloc_np.h
(5.04 KB)
📄
math.h
(13.92 KB)
📄
md4.h
(2.31 KB)
📄
md5.h
(810 B)
📄
memory.h
(1.68 KB)
📄
memstat.h
(7.26 KB)
📄
menu.h
(11.99 KB)
📄
monetary.h
(1.88 KB)
📄
mp.h
(857 B)
📄
mpool.h
(4.16 KB)
📄
mqueue.h
(2.22 KB)
📄
mtlib.h
(4.22 KB)
📄
ncurses.h
(97.92 KB)
📄
ncurses_dll.h
(4.42 KB)
📄
ndbm.h
(2.67 KB)
📁
net
📁
net80211
📄
netconfig.h
(3.71 KB)
📄
netdb.h
(10.78 KB)
📁
netgraph
📄
netgraph.h
(3.02 KB)
📁
netinet
📁
netinet6
📁
netipsec
📁
netnatm
📁
netpfil
📁
netsmb
📁
nfs
📁
nfsclient
📁
nfsserver
📄
nl_types.h
(2.94 KB)
📄
nlist.h
(2.13 KB)
📄
nss.h
(2.32 KB)
📄
nsswitch.h
(7.16 KB)
📄
ntlm_err.h
(970 B)
📄
ocsp_asn1.h
(14.58 KB)
📄
omp.h
(15.76 KB)
📁
opencsd
📁
openssl
📄
opie.h
(5.57 KB)
📄
osreldate.h
(1.51 KB)
📄
panel.h
(4.1 KB)
📄
parse_bytes.h
(2.13 KB)
📄
parse_time.h
(2.19 KB)
📄
parse_units.h
(2.73 KB)
📄
pathconv.h
(1.64 KB)
📄
paths.h
(5.16 KB)
📁
pcap
📄
pcap-bpf.h
(2.24 KB)
📄
pcap-namedb.h
(1.98 KB)
📄
pcap-netmap.h
(126 B)
📄
pcap.h
(2.17 KB)
📄
pkcs10_asn1.h
(4.13 KB)
📄
pkcs12_asn1.h
(13.04 KB)
📄
pkcs8_asn1.h
(6.51 KB)
📄
pkcs9_asn1.h
(5.95 KB)
📄
pkinit_asn1.h
(26.54 KB)
📄
pmc.h
(4.51 KB)
📄
pmcformat.h
(1.47 KB)
📄
pmclog.h
(5.74 KB)
📄
poll.h
(4.03 KB)
📄
printf.h
(5.15 KB)
📁
private
📄
proc_service.h
(2.96 KB)
📁
protocols
📄
pthread.h
(12.7 KB)
📄
pthread_np.h
(3.28 KB)
📄
pwd.h
(6.05 KB)
📄
radlib.h
(8.86 KB)
📄
radlib_vs.h
(3.6 KB)
📄
ranlib.h
(1.99 KB)
📁
rdma
📄
readpassphrase.h
(1.82 KB)
📄
regex.h
(3.87 KB)
📄
res_update.h
(2.45 KB)
📄
resolv.h
(18.69 KB)
📄
resolve.h
(7.26 KB)
📄
rfc2459_asn1.h
(73.99 KB)
📄
ripemd.h
(5.09 KB)
📄
roken-common.h
(11.68 KB)
📄
roken.h
(6.86 KB)
📁
rpc
📁
rpcsvc
📄
rpoll.h
(2.13 KB)
📄
rtbl.h
(3.61 KB)
📄
rtld_db.h
(3.82 KB)
📄
runetype.h
(3.76 KB)
📄
sched.h
(9.06 KB)
📄
sdp.h
(21.58 KB)
📄
search.h
(1.71 KB)
📁
security
📄
semaphore.h
(2.35 KB)
📄
setjmp.h
(2.5 KB)
📄
sha.h
(5.91 KB)
📄
sha224.h
(2.93 KB)
📄
sha256.h
(3.01 KB)
📄
sha384.h
(2.94 KB)
📄
sha512.h
(3.02 KB)
📄
sha512t.h
(4.6 KB)
📄
signal.h
(4.42 KB)
📄
skein.h
(15.95 KB)
📄
skein_freebsd.h
(3.85 KB)
📄
skein_iv.h
(5.54 KB)
📄
skein_port.h
(5.17 KB)
📄
spawn.h
(4.26 KB)
📄
stab.h
(3.07 KB)
📄
stdalign.h
(1.81 KB)
📄
stdarg.h
(87 B)
📄
stdatomic.h
(13.94 KB)
📄
stdbool.h
(1.64 KB)
📄
stddef.h
(2.59 KB)
📄
stdint.h
(2.63 KB)
📄
stdio.h
(16.92 KB)
📄
stdlib.h
(11.23 KB)
📄
stdnoreturn.h
(1.59 KB)
📄
string.h
(5.32 KB)
📄
string_m.h
(1.72 KB)
📄
stringlist.h
(1.83 KB)
📄
strings.h
(2.47 KB)
📁
sys
📄
sysdecode.h
(6.59 KB)
📄
sysexits.h
(5.17 KB)
📄
syslog.h
(7.25 KB)
📄
taclib.h
(5.28 KB)
📄
tar.h
(2.9 KB)
📄
tcpd.h
(8.18 KB)
📁
teken
📄
term.h
(40.4 KB)
📄
termcap.h
(3.39 KB)
📄
termios.h
(3.28 KB)
📄
tgmath.h
(8.85 KB)
📄
thread_db.h
(6.36 KB)
📄
thread_pool_impl.h
(2.76 KB)
📄
threads.h
(3.56 KB)
📄
time.h
(7.07 KB)
📄
timeconv.h
(2.42 KB)
📄
timers.h
(1.97 KB)
📄
ttyent.h
(2.95 KB)
📄
uchar.h
(2.3 KB)
📄
ucontext.h
(2.91 KB)
📁
ufs
📄
ugidfw.h
(2.68 KB)
📄
ulimit.h
(1.58 KB)
📄
ulog.h
(1.67 KB)
📄
unctrl.h
(3.1 KB)
📄
unistd.h
(18.71 KB)
📄
usb.h
(9.48 KB)
📄
usbhid.h
(3.75 KB)
📄
utempter.h
(1.76 KB)
📄
utime.h
(2.01 KB)
📄
utmpx.h
(3.03 KB)
📄
uuid.h
(2.43 KB)
📄
varargs.h
(1.54 KB)
📄
vgl.h
(5.59 KB)
📄
vis.h
(4.48 KB)
📁
vm
📄
vmmapi.h
(10.49 KB)
📄
wchar.h
(8.81 KB)
📄
wctype.h
(3.89 KB)
📄
wind.h
(3.09 KB)
📄
wind_err.h
(860 B)
📄
wordexp.h
(2.75 KB)
📁
x86
📄
xdbm.h
(1.91 KB)
📁
xlocale
📄
xlocale.h
(2.23 KB)
📄
ypclnt.h
(2.33 KB)
📄
zconf.h
(16.24 KB)
📄
zdb.h
(1.02 KB)
📄
zinject.h
(2.14 KB)
📄
zlib.h
(94.08 KB)
📄
zstream.h
(820 B)
📄
zutil_import.h
(2.51 KB)
Editing: libnetmap.h
/*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (C) 2018 Universita` di Pisa * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * $FreeBSD$ */ #ifndef LIBNETMAP_H_ #define LIBNETMAP_H_ /* if thread-safety is not needed, define LIBNETMAP_NOTHREADSAFE before including * this file. */ /* NOTE: we include net/netmap_user.h without defining NETMAP_WITH_LIBS, which * is deprecated. If you still need it, please define NETMAP_WITH_LIBS and * include net/netmap_user.h before including this file. */ #include <net/netmap_user.h> struct nmctx; struct nmport_d; struct nmem_d; /* * A port open specification (portspec for brevity) has the following syntax * (square brackets delimit optional parts): * * subsystem:vpname[mode][options] * * The "subsystem" is denoted by a prefix, possibly followed by an identifier. * There can be several kinds of subsystems, each one selected by a unique * prefix. Currently defined subsystems are: * * netmap (no id allowed) * the standard subsystem * * vale (followed by a possibly empty id) * the vpname is connected to a VALE switch identified by * the id (an empty id selects the default switch) * * The "vpname" has the following syntax: * * identifier or * identifier1{identifier2 or * identifier1}identifier2 * * Identifiers are sequences of alphanumeric characters. The part that begins * with either '{' or '}', when present, denotes a netmap pipe opened in the * same memory region as the subsystem:indentifier1 port. * * The "mode" can be one of the following: * * ^ bind all host (sw) ring pairs * ^NN bind individual host ring pair * * bind host and NIC ring pairs * -NN bind individual NIC ring pair * @NN open the port in the NN memory region * a suffix starting with / and the following flags, * in any order: * x exclusive access * z zero copy monitor (both tx and rx) * t monitor tx side (copy monitor) * r monitor rx side (copy monitor) * R bind only RX ring(s) * T bind only TX ring(s) * * The "options" start at the first '@' character not followed by a number. * Each option starts with '@' and has the following syntax: * * option (flag option) * option=value (single key option) * option:key1=value1,key2=value2,... (multi-key option) * * For multi-key options, the keys can be assigned in any order, but they * cannot be assigned more than once. It is not necessary to assign all the * option keys: unmentioned keys will receive default values. Some multi-key * options define a default key and also accept the single-key syntax, by * assigning the value to this key. * * NOTE: Options may be silently ignored if the port is already open by some * other process. * * The currently available options are (default keys, when defined, are marked * with '*'): * * share (single-key) * open the port in the same memory region used by the * given port name (the port name must be given in * subsystem:vpname form) * * conf (multi-key) * specify the rings/slots numbers (effective only on * ports that are created by the open operation itself, * and ignored otherwise). * * The keys are: * * *rings number of tx and rx rings * tx-rings number of tx rings * rx-rings number of rx rings * host-rings number of tx and rx host rings * host-tx-rings number of host tx rings * host-rx-rings number of host rx rings * slots number of slots in each tx and rx * ring * tx-slots number of slots in each tx ring * rx-slots number of slots in each rx ring * * (more specific keys override the less specific ones) * All keys default to zero if not assigned, and the * corresponding value will be chosen by netmap. * * extmem (multi-key) * open the port in the memory region obtained by * mmap()ing the given file. * * The keys are: * * *file the file to mmap * if-num number of pre-allocated netmap_if's * if-size size of each netmap_if * ring-num number of pre-allocated netmap_ring's * ring-size size of each netmap_ring * buf-num number of pre-allocated buffers * buf-size size of each buffer * * file must be assigned. The other keys default to zero, * causing netmap to take the corresponding values from * the priv_{if,ring,buf}_{num,size} sysctls. * */ /* nmport manipulation */ /* struct nmport_d - describes a netmap port */ struct nmport_d { /* see net/netmap.h for the definition of these fields */ struct nmreq_header hdr; struct nmreq_register reg; /* all the fields below should be considered read-only */ /* if the same context is used throughout the program, d1->mem == * d2->mem iff d1 and d2 are using the memory region (i.e., zero * copy is possible between the two ports) */ struct nmem_d *mem; /* the nmctx used when this nmport_d was created */ struct nmctx *ctx; int register_done; /* nmport_register() has been called */ int mmap_done; /* nmport_mmap() has been called */ /* pointer to the extmem option contained in the hdr options, if any */ struct nmreq_opt_extmem *extmem; /* the fields below are compatible with nm_open() */ int fd; /* "/dev/netmap", -1 if not open */ struct netmap_if *nifp; /* pointer to the netmap_if */ uint16_t first_tx_ring; uint16_t last_tx_ring; uint16_t first_rx_ring; uint16_t last_rx_ring; uint16_t cur_tx_ring; /* used by nmport_inject */ uint16_t cur_rx_ring; /* LIFO list of cleanup functions (used internally) */ struct nmport_cleanup_d *clist; }; /* nmport_open - opens a port from a portspec * @portspec the port opening specification * * If successful, the function returns a new nmport_d describing a netmap * port, opened according to the port specification, ready to be used for rx * and/or tx. * * The rings available for tx are in the [first_tx_ring, last_tx_ring] * interval, and similarly for rx. One or both intervals may be empty. * * When done using it, the nmport_d descriptor must be closed using * nmport_close(). * * In case of error, NULL is returned, errno is set to some error, and an * error message is sent through the error() method of the current context. */ struct nmport_d * nmport_open(const char *portspec); /* nport_close - close a netmap port * @d the port we want to close * * Undoes the actions performed by the nmport_open that created d, then * frees the descriptor. */ void nmport_close(struct nmport_d *d); /* nmport_inject - sends a packet * @d the port through which we want to send * @buf base address of the packet * @size its size in bytes * * Sends a packet using the cur_tx_ring and updates the index * to use all available tx rings in turn. Note: the packet is copied. * * Returns 0 on success an -1 on error. */ int nmport_inject(struct nmport_d *d, const void *buf, size_t size); /* * the functions below can be used to split the functionality of * nmport_open when special features (e.g., extra buffers) are needed * * The relation among the functions is as follows: * * |nmport_new * |nmport_prepare = | * | |nmport_parse * nmport_open =| * | |nmport_register * |nmport_open_desc =| * |nmport_mmap * */ /* nmport_new - create a new nmport_d * * Creates a new nmport_d using the malloc() method of the current default * context. Returns NULL on error, setting errno to an error value. */ struct nmport_d *nmport_new(void); /* nmport_parse - fills the nmport_d netmap-register request * @d the nmport to be filled * @portspec the port opening specification * * This function parses the portspec and initizalizes the @d->hdr and @d->reg * fields. It may need to allocate a list of options. If an extmem option is * found, it may also mmap() the corresponding file. * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_parse(struct nmport_d *d, const char *portspec); /* nmport_register - registers the port with netmap * @d the nmport to be registered * * This function obtains a netmap file descriptor and registers the port with * netmap. The @d->hdr and @d->reg data structures must have been previously * initialized (via nmport_parse() or otherwise). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_register(struct nmport_d *); /* nmport_mmap - maps the port resources into the process memory * @d the nmport to be mapped * * The port must have been previously been registered using nmport_register. * * Note that if extmem is used (either via an option or by calling an * nmport_extmem_* function before nmport_register()), no new mmap() is issued. * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_mmap(struct nmport_d *); /* the following functions undo the actions of nmport_new(), nmport_parse(), * nmport_register() and nmport_mmap(), respectively. */ void nmport_delete(struct nmport_d *); void nmport_undo_parse(struct nmport_d *); void nmport_undo_register(struct nmport_d *); void nmport_undo_mmap(struct nmport_d *); /* nmport_prepare - create a port descriptor, but do not open it * @portspec the port opening specification * * This functions creates a new nmport_d and initializes it according to * @portspec. It is equivalent to nmport_new() followed by nmport_parse(). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ struct nmport_d *nmport_prepare(const char *portspec); /* nmport_open_desc - open an initialized port descriptor * @d the descriptor we want to open * * Registers the port with netmap and maps the rings and buffers into the * process memory. It is equivalent to nmport_register() followed by * nmport_mmap(). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_open_desc(struct nmport_d *d); /* the following functions undo the actions of nmport_prepare() * and nmport_open_desc(), respectively. */ void nmport_undo_prepare(struct nmport_d *); void nmport_undo_open_desc(struct nmport_d *); /* nmport_clone - copy an nmport_d * @d the nmport_d we want to copy * * Copying an nmport_d by hand should be avoided, since adjustments are needed * and some part of the state cannot be easily duplicated. This function * creates a copy of @d in a safe way. The returned nmport_d contains * nmreq_header and nmreq_register structures equivalent to those contained in * @d, except for the option list, which is ignored. The returned nmport_d is * already nmport_prepare()d, but it must still be nmport_open_desc()ed. The * new nmport_d uses the same nmctx as @d. * * If extmem was used for @d, then @d cannot be nmport_clone()d until it has * been nmport_register()ed. * * In case of error, the function returns NULL, sets errno to an error value * and sends an error message to the nmctx error() method. */ struct nmport_d *nmport_clone(struct nmport_d *); /* nmport_extmem - use extmem for this port * @d the port we want to use the extmem for * @base the base address of the extmem region * @size the size in bytes of the extmem region * * the memory that contains the netmap ifs, rings and buffers is usually * allocated by netmap and later mmap()ed by the applications. It is sometimes * useful to reverse this process, by having the applications allocate some * memory (through mmap() or otherwise) and then let netmap use it. The extmem * option can be used to implement this latter strategy. The option can be * passed through the portspec using the '@extmem:...' syntax, or * programmatically by calling nmport_extmem() or nmport_extmem_from_file() * between nmport_parse() and nmport_register() (or between nmport_prepare() * and nmport_open_desc()). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_extmem(struct nmport_d *d, void *base, size_t size); /* nmport_extmem_from_file - use the extmem obtained by mapping a file * @d the port we want to use the extmem for * @fname path of the file we want to map * * This works like nmport_extmem, but the extmem memory is obtained by * mmap()ping @fname. nmport_close() will also automatically munmap() the file. * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_extmem_from_file(struct nmport_d *d, const char *fname); /* nmport_extmem_getinfo - opbtai a pointer to the extmem configuration * @d the port we want to obtain the pointer from * * Returns a pointer to the nmreq_pools_info structure containing the * configuration of the extmem attached to port @d, or NULL if no extmem * is attached. This can be used to set the desired configuration before * registering the port, or to read the actual configuration after * registration. */ struct nmreq_pools_info* nmport_extmem_getinfo(struct nmport_d *d); /* enable/disable options * * These functions can be used to disable options that the application cannot * or doesn't want to handle, or to enable options that require special support * from the application and are, therefore, disabled by default. Disabled * options will cause an error if encountered during option parsing. * * If the option is unknown, nmport_disable_option is a NOP, while * nmport_enable_option returns -1 and sets errno to EOPNOTSUPP. * * These functions are not threadsafe and are meant to be used at the beginning * of the program. */ void nmport_disable_option(const char *opt); int nmport_enable_option(const char *opt); /* nmreq manipulation * * nmreq_header_init - initialize an nmreq_header * @hdr the nmreq_header to initialize * @reqtype the kind of netmap request * @body the body of the request * * Initialize the nr_version, nr_reqtype and nr_body fields of *@hdr. * The other fields are set to zero. */ void nmreq_header_init(struct nmreq_header *hdr, uint16_t reqtype, void *body); /* * These functions allow for finer grained parsing of portspecs. They are used * internally by nmport_parse(). */ /* nmreq_header_decode - initialize an nmreq_header * @ppspec: (in/out) pointer to a pointer to the portspec * @hdr: pointer to the nmreq_header to be initialized * @ctx: pointer to the nmctx to use (for errors) * * This function fills the @hdr the nr_name field with the port name extracted * from *@pifname. The other fields of *@hdr are unchanged. The @pifname is * updated to point at the first char past the port name. * * Returns 0 on success. In case of error, -1 is returned with errno set to * EINVAL, @pifname is unchanged, *@hdr is also unchanged, and an error message * is sent through @ctx->error(). */ int nmreq_header_decode(const char **ppspec, struct nmreq_header *hdr, struct nmctx *ctx); /* nmreq_regiter_decode - initialize an nmreq_register * @pmode: (in/out) pointer to a pointer to an opening mode * @reg: pointer to the nmreq_register to be initialized * @ctx: pointer to the nmctx to use (for errors) * * This function fills the nr_mode, nr_ringid, nr_flags and nr_mem_id fields of * the structure pointed by @reg, according to the opening mode specified by * *@pmode. The other fields of *@reg are unchanged. The @pmode is updated to * point at the first char past the opening mode. * * If a '@' is encountered followed by something which is not a number, parsing * stops (without error) and @pmode is left pointing at the '@' char. The * nr_mode, nr_ringid and nr_flags fields are still updated, but nr_mem_id is * not touched and the interpretation of the '@' field is left to the caller. * * Returns 0 on success. In case of error, -1 is returned with errno set to * EINVAL, @pmode is unchanged, *@reg is also unchanged, and an error message * is sent through @ctx->error(). */ int nmreq_register_decode(const char **pmode, struct nmreq_register *reg, struct nmctx *ctx); /* nmreq_options_decode - parse the "options" part of the portspec * @opt: pointer to the option list * @parsers: list of option parsers * @token: token to pass to each parser * @ctx: pointer to the nmctx to use (for errors and malloc/free) * * This function parses each option in @opt. Each option is matched (based on * the "option" prefix) to a corresponding parser in @parsers. The function * checks that the syntax is appropriate for the parser and it assigns all the * keys mentioned in the option. It then passes control to the parser, to * interpret the keys values. * * Returns 0 on success. In case of error, -1 is returned, errno is set to an * error value and a message is sent to @ctx->error(). The effects of partially * interpreted options may not be undone. */ struct nmreq_opt_parser; int nmreq_options_decode(const char *opt, struct nmreq_opt_parser *parsers, void *token, struct nmctx *ctx); struct nmreq_parse_ctx; /* type of the option-parsers callbacks */ typedef int (*nmreq_opt_parser_cb)(struct nmreq_parse_ctx *); #define NMREQ_OPT_MAXKEYS 16 /* max nr of recognized keys per option */ /* struct nmreq_opt_key - describes an option key */ struct nmreq_opt_key { const char *key; /* the key name */ int id; /* its position in the parse context */ unsigned int flags; #define NMREQ_OPTK_ALLOWEMPTY (1U << 0) /* =value may be omitted */ #define NMREQ_OPTK_MUSTSET (1U << 1) /* the key is mandatory */ #define NMREQ_OPTK_DEFAULT (1U << 2) /* this is the default key */ }; /* struct nmreq_opt_parser - describes an option parser */ struct nmreq_opt_parser { const char *prefix; /* matches one option prefix */ nmreq_opt_parser_cb parse; /* the parse callback */ int default_key; /* which option is the default if the parser is multi-key (-1 if none) */ int nr_keys; unsigned int flags; #define NMREQ_OPTF_DISABLED (1U << 0) #define NMREQ_OPTF_ALLOWEMPTY (1U << 1) /* =value can be omitted */ struct nmreq_opt_parser *next; /* list of options */ /* recognized keys */ struct nmreq_opt_key keys[NMREQ_OPT_MAXKEYS]; } __attribute__((aligned(16))); /* struct nmreq_parse_ctx - the parse context received by the parse callback */ struct nmreq_parse_ctx { struct nmctx *ctx; /* the nmctx for errors and malloc/free */ void *token; /* the token passed to nmreq_options_parse */ /* the value (i.e., the part after the = sign) of each recognized key * is assigned to the corresponding entry in this array, based on the * key id. Unassigned keys are left at NULL. */ const char *keys[NMREQ_OPT_MAXKEYS]; }; /* nmreq_get_mem_id - get the mem_id of the given port * @portname pointer to a pointer to the portname * @ctx pointer to the nmctx to use (for errors) * * *@portname must point to a substem:vpname porname, possibly followed by * something else. * * If successful, returns the mem_id of *@portname and moves @portname past the * subsystem:vpname part of the input. In case of error it returns -1, sets * errno to an error value and sends an error message to ctx->error(). */ int32_t nmreq_get_mem_id(const char **portname, struct nmctx *ctx); /* option list manipulation */ void nmreq_push_option(struct nmreq_header *, struct nmreq_option *); void nmreq_remove_option(struct nmreq_header *, struct nmreq_option *); struct nmreq_option *nmreq_find_option(struct nmreq_header *, uint32_t); void nmreq_free_options(struct nmreq_header *); const char* nmreq_option_name(uint32_t); #define nmreq_foreach_option(h_, o_) \ for ((o_) = (struct nmreq_option *)((uintptr_t)((h_)->nr_options));\ (o_) != NULL;\ (o_) = (struct nmreq_option *)((uintptr_t)((o_)->nro_next))) /* nmctx manipulation */ /* the nmctx serves a few purposes: * * - maintain a list of all memory regions open by the program, so that two * ports that are using the same region (as identified by the mem_id) will * point to the same nmem_d instance. * * - allow the user to specify how to lock accesses to the above list, if * needed (lock() callback) * * - allow the user to specify how error messages should be delivered (error() * callback) * * - select the verbosity of the library (verbose field); if verbose==0, no * errors are sent to the error() callback * * - allow the user to override the malloc/free functions used by the library * (malloc() and free() callbacks) * */ typedef void (*nmctx_error_cb)(struct nmctx *, const char *); typedef void *(*nmctx_malloc_cb)(struct nmctx *,size_t); typedef void (*nmctx_free_cb)(struct nmctx *,void *); typedef void (*nmctx_lock_cb)(struct nmctx *, int); struct nmctx { int verbose; nmctx_error_cb error; nmctx_malloc_cb malloc; nmctx_free_cb free; nmctx_lock_cb lock; struct nmem_d *mem_descs; }; /* nmctx_get - obtain a pointer to the current default context */ struct nmctx *nmctx_get(void); /* nmctx_set_default - change the default context * @ctx pointer to the new context * * Returns a pointer to the previous default context. */ struct nmctx *nmctx_set_default(struct nmctx *ctx); /* internal functions and data structures */ /* struct nmem_d - describes a memory region currently used */ struct nmem_d { uint16_t mem_id; /* the region netmap identifier */ int refcount; /* how many nmport_d's point here */ void *mem; /* memory region base address */ size_t size; /* memory region size */ int is_extmem; /* was it obtained via extmem? */ /* pointers for the circular list implementation. * The list head is the mem_descs filed in the nmctx */ struct nmem_d *next; struct nmem_d *prev; }; /* a trick to force the inclusion of libpthread only if requested. If * LIBNETMAP_NOTHREADSAFE is defined, no pthread symbol is imported. * * There is no need to actually call this function: the ((used)) attribute is * sufficient to include it in the image. */ static __attribute__((used)) void libnetmap_init(void) { #ifndef LIBNETMAP_NOTHREADSAFE extern int nmctx_threadsafe; /* dummy assignment to link-in the nmctx-pthread.o object. The proper * inizialization is performed only once in the library constructor * defined there. */ nmctx_threadsafe = 1; #endif /* LIBNETMAP_NOTHREADSAFE */ } /* nmctx_set_threadsafe - install a threadsafe default context * * called by the constructor in nmctx-pthread.o to initialize a lock and install * the lock() callback in the default context. */ void nmctx_set_threadsafe(void); /* nmctx_ferror - format and send an error message */ void nmctx_ferror(struct nmctx *, const char *, ...); /* nmctx_malloc - allocate memory */ void *nmctx_malloc(struct nmctx *, size_t); /* nmctx_free - free memory allocated via nmctx_malloc */ void nmctx_free(struct nmctx *, void *); /* nmctx_lock - lock the list of nmem_d */ void nmctx_lock(struct nmctx *); /* nmctx_unlock - unlock the list of nmem_d */ void nmctx_unlock(struct nmctx *); #endif /* LIBNETMAP_H_ */
Upload File
Create Folder