Blame libipq/ipq_set_mode.3

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