blob: 26ab9f9e61e03bee618502aeab33a584ca3d766d [file] [log] [blame]
James Morris460c7472001-10-16 14:41:02 +00001.TH IPQ_READ 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_read \(em read queue messages from ip_queue and read into supplied buffer
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 "ssize_t ipq_read(const struct ipq_handle *" h ", unsigned char *" buf ", size_t " len ", int " timeout ");"
28.SH DESCRIPTION
29The
30.B ipq_read
James Morris460c7472001-10-16 14:41:02 +000031function reads a queue message from the kernel and copies it to
James Morris949810c2000-11-20 14:13:31 +000032the memory pointed to by
33.I buf
34to a maximum length of
James Morris460c7472001-10-16 14:41:02 +000035. IR len .
James Morris949810c2000-11-20 14:13:31 +000036.PP
37The
38.I h
39parameter is a context handle which must previously have been returned
40successfully from a call to
James Morris460c7472001-10-16 14:41:02 +000041.BR ipq_create_handle .
James Morris949810c2000-11-20 14:13:31 +000042.PP
43The caller is responsible for ensuring that the memory pointed to by
44.I buf
45is large enough to contain
46.I len
47bytes.
48.PP
49The
50.I timeout
James Morris460c7472001-10-16 14:41:02 +000051parameter may be used to set a timeout for the operation, specified in microseconds.
52This is implemented internally by the library via the
53.BR select
54system call. A value of zero provides normal, backwards-compatible blocking behaviour
55with no timeout. A negative value causes the function to return immediately.
James Morris949810c2000-11-20 14:13:31 +000056.PP
57Data returned via
58.I buf
59should not be accessed directly. Use the
60.BR ipq_message_type ,
61.BR ipq_get_packet ", and"
62.BR ipq_get_msgerr
63functions to access the queue message in the buffer.
64.SH RETURN VALUE
Jan Engelhardt352ccfb2009-08-20 17:15:22 +020065On failure, \-1 is returned.
James Morris949810c2000-11-20 14:13:31 +000066.br
James Morris460c7472001-10-16 14:41:02 +000067On success, a non-zero positive value is returned when no timeout
68value is specified.
69.br
70On success with a timeout value specified, zero is returned if no data
71was available to read, or if a non-blocked signal was caught. In the
72latter case, the global
73.B errno
74value will be set to
75.BR EINTR .
James Morris949810c2000-11-20 14:13:31 +000076.SH ERRORS
77On error, a descriptive error message will be available
78via the
79.B ipq_errstr
80function.
81.SH DIAGNOSTICS
82While the
83.B ipq_read
84function may return successfully, the queue message copied to the buffer
85may itself be an error message from a higher level kernel component. Use
86.B ipq_message_type
87to determine if it is an error message, and
88.B ipq_get_msgerr
89to access the value of the message.
James Morris949810c2000-11-20 14:13:31 +000090.SH BUGS
91None known.
92.SH AUTHOR
93James Morris <jmorris@intercode.com.au>
94.SH COPYRIGHT
James Morris460c7472001-10-16 14:41:02 +000095Copyright (c) 2000-2001 Netfilter Core Team.
James Morris949810c2000-11-20 14:13:31 +000096.PP
97Distributed under the GNU General Public License.
James Morris460c7472001-10-16 14:41:02 +000098.SH CREDITS
James Morris67b63ae2001-10-16 16:58:25 +000099Joost Remijn implemented the timeout feature, which appeared in the 1.2.4 release of iptables.
James Morris949810c2000-11-20 14:13:31 +0000100.SH SEE ALSO
101.BR iptables (8),
James Morris460c7472001-10-16 14:41:02 +0000102.BR libipq (3),
103.BR select (2).
James Morris949810c2000-11-20 14:13:31 +0000104