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