blob: 5d967376bf1979ba27fd020cfef680adf5aba11a [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 Morris67b63ae2001-10-16 16:58:25 +00003.\" $Id: ipq_read.3,v 1.2 2001/10/16 14:41:02 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
James Morris460c7472001-10-16 14:41:02 +000023ipq_read - read queue messages from ip_queue and read into supplied buffer
James Morris949810c2000-11-20 14:13:31 +000024.SH SYNOPSIS
25.B #include <linux/netfilter.h>
26.br
27.B #include <libipq.h>
28.sp
29.BI "ssize_t ipq_read(const struct ipq_handle *" h ", unsigned char *" buf ", size_t " len ", int " timeout ");"
30.SH DESCRIPTION
31The
32.B ipq_read
James Morris460c7472001-10-16 14:41:02 +000033function reads a queue message from the kernel and copies it to
James Morris949810c2000-11-20 14:13:31 +000034the memory pointed to by
35.I buf
36to a maximum length of
James Morris460c7472001-10-16 14:41:02 +000037. IR len .
James Morris949810c2000-11-20 14:13:31 +000038.PP
39The
40.I h
41parameter is a context handle which must previously have been returned
42successfully from a call to
James Morris460c7472001-10-16 14:41:02 +000043.BR ipq_create_handle .
James Morris949810c2000-11-20 14:13:31 +000044.PP
45The caller is responsible for ensuring that the memory pointed to by
46.I buf
47is large enough to contain
48.I len
49bytes.
50.PP
51The
52.I timeout
James Morris460c7472001-10-16 14:41:02 +000053parameter may be used to set a timeout for the operation, specified in microseconds.
54This is implemented internally by the library via the
55.BR select
56system call. A value of zero provides normal, backwards-compatible blocking behaviour
57with no timeout. A negative value causes the function to return immediately.
James Morris949810c2000-11-20 14:13:31 +000058.PP
59Data returned via
60.I buf
61should not be accessed directly. Use the
62.BR ipq_message_type ,
63.BR ipq_get_packet ", and"
64.BR ipq_get_msgerr
65functions to access the queue message in the buffer.
66.SH RETURN VALUE
67On failure, -1 is returned.
68.br
James Morris460c7472001-10-16 14:41:02 +000069On success, a non-zero positive value is returned when no timeout
70value is specified.
71.br
72On success with a timeout value specified, zero is returned if no data
73was available to read, or if a non-blocked signal was caught. In the
74latter case, the global
75.B errno
76value will be set to
77.BR EINTR .
James Morris949810c2000-11-20 14:13:31 +000078.SH ERRORS
79On error, a descriptive error message will be available
80via the
81.B ipq_errstr
82function.
83.SH DIAGNOSTICS
84While the
85.B ipq_read
86function may return successfully, the queue message copied to the buffer
87may itself be an error message from a higher level kernel component. Use
88.B ipq_message_type
89to determine if it is an error message, and
90.B ipq_get_msgerr
91to access the value of the message.
James Morris949810c2000-11-20 14:13:31 +000092.SH BUGS
93None known.
94.SH AUTHOR
95James Morris <jmorris@intercode.com.au>
96.SH COPYRIGHT
James Morris460c7472001-10-16 14:41:02 +000097Copyright (c) 2000-2001 Netfilter Core Team.
James Morris949810c2000-11-20 14:13:31 +000098.PP
99Distributed under the GNU General Public License.
James Morris460c7472001-10-16 14:41:02 +0000100.SH CREDITS
James Morris67b63ae2001-10-16 16:58:25 +0000101Joost Remijn implemented the timeout feature, which appeared in the 1.2.4 release of iptables.
James Morris949810c2000-11-20 14:13:31 +0000102.SH SEE ALSO
103.BR iptables (8),
James Morris460c7472001-10-16 14:41:02 +0000104.BR libipq (3),
105.BR select (2).
James Morris949810c2000-11-20 14:13:31 +0000106