blob: 0edd3c00a84f9724dd122ecf4d96c74243c110c2 [file] [log] [blame]
James Morris460c7472001-10-16 14:41:02 +00001.TH IPQ_SET_MODE 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual"
James Morris949810c2000-11-20 14:13:31 +00002.\"
James Morris460c7472001-10-16 14:41:02 +00003.\" Copyright (c) 2000-2001 Netfilter Core Team
James Morris949810c2000-11-20 14:13:31 +00004.\"
5.\" This program is free software; you can redistribute it and/or modify
6.\" it under the terms of the GNU General Public License as published by
7.\" the Free Software Foundation; either version 2 of the License, or
8.\" (at your option) any later version.
9.\"
10.\" This program is distributed in the hope that it will be useful,
11.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
12.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.\" GNU General Public License for more details.
14.\"
15.\" You should have received a copy of the GNU General Public License
16.\" along with this program; if not, write to the Free Software
17.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18.\"
19.\"
20.SH NAME
Jan Engelhardt352ccfb2009-08-20 17:15:22 +020021ipq_set_mode \(em set the ip_queue queuing mode
James Morris949810c2000-11-20 14:13:31 +000022.SH SYNOPSIS
23.B #include <linux/netfilter.h>
24.br
25.B #include <libipq.h>
26.sp
27.BI "int ipq_set_mode(const struct ipq_handle *" h ", u_int8_t " mode ", size_t " range );
28.SH DESCRIPTION
29The
30.B ipq_set_mode
31function sends a message to the kernel ip_queue module, specifying whether
32packet metadata only, or packet payloads as well as metadata should be copied to
33userspace.
34.PP
35The
36.I h
37parameter is a context handle which must previously have been returned
38successfully from a call to
39.BR ipq_create_handle .
40.PP
41The
42.I mode
43parameter must be one of:
44.TP
45.B IPQ_COPY_META
46Copy only packet metadata to userspace.
47.TP
48.B IPQ_COPY_PACKET
49Copy packet metadata and packet payloads to userspace.
50.PP
51The
52.I range
53parameter is used to specify how many bytes of the payload to copy
54to userspace. It is only valid for
55.B IPQ_COPY_PACKET
56mode and is otherwise ignored. The maximum useful value for
57.I range
58is 65535 (greater values will be clamped to this by ip_queue).
59.PP
60.B ipq_set_mode
61is usually used immediately following
62.B ipq_create_handle
63to enable the flow of packets to userspace.
64.PP
65Note that as the underlying Netlink messaging transport is connectionless,
66the ip_queue module does not know that a userspace application is ready to
67communicate until it receives a message such as this.
68.SH RETURN VALUE
Jan Engelhardt352ccfb2009-08-20 17:15:22 +020069On failure, \-1 is returned.
James Morris949810c2000-11-20 14:13:31 +000070.br
71On success, a non-zero positive value is returned.
72.SH ERRORS
73On failure, a descriptive error message will be available
74via the
75.B ipq_errstr
76function.
77.SH DIAGNOSTICS
78A relatively common failure may occur if the ip_queue module is not loaded.
79In this case, the following code excerpt:
80.PP
81.RS
82.nf
83status = ipq_set_mode(h, IPQ_COPY_META, 0);
84if (status < 0) {
85 ipq_perror("myapp");
86 ipq_destroy_handle(h);
87 exit(1);
88}
89.RE
90.fi
91.PP
92would generate the following output:
93.PP
94.I myapp: Failed to send netlink message: Connection refused
95.SH BUGS
96None known.
97.SH AUTHOR
98James Morris <jmorris@intercode.com.au>
99.SH COPYRIGHT
James Morris460c7472001-10-16 14:41:02 +0000100Copyright (c) 2000-2001 Netfilter Core Team.
James Morris949810c2000-11-20 14:13:31 +0000101.PP
102Distributed under the GNU General Public License.
103.SH SEE ALSO
104.BR libipq (3),
105.BR iptables (8).