Blame libipq/ipq_set_mode.3

Packit Service d1fe03
.TH IPQ_SET_MODE 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual" 
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     Copyright (c) 2000-2001 Netfilter Core Team
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     This program is free software; you can redistribute it and/or modify
Packit Service d1fe03
.\"     it under the terms of the GNU General Public License as published by
Packit Service d1fe03
.\"     the Free Software Foundation; either version 2 of the License, or
Packit Service d1fe03
.\"     (at your option) any later version.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     This program is distributed in the hope that it will be useful,
Packit Service d1fe03
.\"     but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service d1fe03
.\"     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service d1fe03
.\"     GNU General Public License for more details.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     You should have received a copy of the GNU General Public License
Packit Service d1fe03
.\"     along with this program; if not, write to the Free Software
Packit Service d1fe03
.\"     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"
Packit Service d1fe03
.SH NAME
Packit Service d1fe03
ipq_set_mode \(em set the ip_queue queuing mode
Packit Service d1fe03
.SH SYNOPSIS
Packit Service d1fe03
.B #include <linux/netfilter.h>
Packit Service d1fe03
.br
Packit Service d1fe03
.B #include <libipq.h>
Packit Service d1fe03
.sp
Packit Service d1fe03
.BI "int ipq_set_mode(const struct ipq_handle *" h ", u_int8_t " mode ", size_t " range );
Packit Service d1fe03
.SH DESCRIPTION
Packit Service d1fe03
The
Packit Service d1fe03
.B ipq_set_mode
Packit Service d1fe03
function sends a message to the kernel ip_queue module, specifying whether
Packit Service d1fe03
packet metadata only, or packet payloads as well as metadata should be copied to
Packit Service d1fe03
userspace.
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.I h
Packit Service d1fe03
parameter is a context handle which must previously have been returned 
Packit Service d1fe03
successfully from a call to
Packit Service d1fe03
.BR ipq_create_handle .
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.I mode
Packit Service d1fe03
parameter must be one of:
Packit Service d1fe03
.TP
Packit Service d1fe03
.B IPQ_COPY_META
Packit Service d1fe03
Copy only packet metadata to userspace.
Packit Service d1fe03
.TP
Packit Service d1fe03
.B IPQ_COPY_PACKET
Packit Service d1fe03
Copy packet metadata and packet payloads to userspace.
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.I range
Packit Service d1fe03
parameter is used to specify how many bytes of the payload to copy
Packit Service d1fe03
to userspace.  It is only valid for
Packit Service d1fe03
.B IPQ_COPY_PACKET
Packit Service d1fe03
mode and is otherwise ignored.  The maximum useful value for
Packit Service d1fe03
.I range
Packit Service d1fe03
is 65535 (greater values will be clamped to this by ip_queue).
Packit Service d1fe03
.PP
Packit Service d1fe03
.B ipq_set_mode
Packit Service d1fe03
is usually used immediately following
Packit Service d1fe03
.B ipq_create_handle
Packit Service d1fe03
to enable the flow of packets to userspace.
Packit Service d1fe03
.PP
Packit Service d1fe03
Note that as the underlying Netlink messaging transport is connectionless,
Packit Service d1fe03
the ip_queue module does not know that a userspace application is ready to
Packit Service d1fe03
communicate until it receives a message such as this.
Packit Service d1fe03
.SH RETURN VALUE
Packit Service d1fe03
On failure, \-1 is returned.
Packit Service d1fe03
.br
Packit Service d1fe03
On success, a non-zero positive value is returned.
Packit Service d1fe03
.SH ERRORS
Packit Service d1fe03
On failure, a descriptive error message will be available
Packit Service d1fe03
via the
Packit Service d1fe03
.B ipq_errstr
Packit Service d1fe03
function.
Packit Service d1fe03
.SH DIAGNOSTICS
Packit Service d1fe03
A relatively common failure may occur if the ip_queue module is not loaded.
Packit Service d1fe03
In this case, the following code excerpt:
Packit Service d1fe03
.PP
Packit Service d1fe03
.RS
Packit Service d1fe03
.nf
Packit Service d1fe03
status = ipq_set_mode(h, IPQ_COPY_META, 0);
Packit Service d1fe03
if (status < 0) {
Packit Service d1fe03
	ipq_perror("myapp");
Packit Service d1fe03
	ipq_destroy_handle(h);
Packit Service d1fe03
	exit(1);
Packit Service d1fe03
}
Packit Service d1fe03
.RE
Packit Service d1fe03
.fi
Packit Service d1fe03
.PP
Packit Service d1fe03
would generate the following output:
Packit Service d1fe03
.PP
Packit Service d1fe03
.I myapp: Failed to send netlink message: Connection refused
Packit Service d1fe03
.SH BUGS
Packit Service d1fe03
None known.
Packit Service d1fe03
.SH AUTHOR
Packit Service d1fe03
James Morris <jmorris@intercode.com.au>
Packit Service d1fe03
.SH COPYRIGHT
Packit Service d1fe03
Copyright (c) 2000-2001 Netfilter Core Team.
Packit Service d1fe03
.PP
Packit Service d1fe03
Distributed under the GNU General Public License.
Packit Service d1fe03
.SH SEE ALSO
Packit Service d1fe03
.BR libipq (3),
Packit Service d1fe03
.BR iptables (8).