blob: 89d8817b093fa1e98cbe7fe3fd79484d64ed9247 [file] [log] [blame]
James Morris460c7472001-10-16 14:41:02 +00001.TH IPQ_MESSAGE_TYPE 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_message_type, ipq_get_packet, ipq_getmsgerr \(em query queue messages
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_message_type(const unsigned char *" buf ");"
28.br
29.BI "ipq_packet_msg_t *ipq_get_packet(const unsigned char *" buf ");"
30.br
31.BI "int ipq_get_msgerr(const unsigned char *" buf ");"
32.SH DESCRIPTION
33The
34.B ipq_message_type
35function returns the type of queue message returned to userspace
36via
37.BR ipq_read .
38.PP
39.B ipq_message_type
40should always be called following a successful call to
41.B ipq_read
42to determine whether the message is a packet message or an
43error message. The
44.I buf
45parameter should be the same data obtained from
46the previous call to
47.BR ipq_read .
48.PP
49.B ipq_message_type
50will return one of the following values:
51.TP
52.B NLMSG_ERROR
53An error message generated by the Netlink transport.
54.PP
55.TP
56.B IPQM_PACKET
57A packet message containing packet metadata and optional packet payload data.
58.PP
59The
60.B ipq_get_packet
61function should be called if
62.B ipq_message_type
63returns
64.BR IPQM_PACKET .
65The
66.I buf
67parameter should point to the same data used for the call to
68.BR ipq_message_type .
69The pointer returned by
70.B ipq_get_packet
71points to a packet message, which is declared as follows:
72.PP
73.RS
74.nf
75typedef struct ipq_packet_msg {
76 unsigned long packet_id; /* ID of queued packet */
77 unsigned long mark; /* Netfilter mark value */
78 long timestamp_sec; /* Packet arrival time (seconds) */
79 long timestamp_usec; /* Packet arrvial time (+useconds) */
80 unsigned int hook; /* Netfilter hook we rode in on */
81 char indev_name[IFNAMSIZ]; /* Name of incoming interface */
82 char outdev_name[IFNAMSIZ]; /* Name of outgoing interface */
83 unsigned short hw_protocol; /* Hardware protocol (network order) */
84 unsigned short hw_type; /* Hardware type */
85 unsigned char hw_addrlen; /* Hardware address length */
86 unsigned char hw_addr[8]; /* Hardware address */
87 size_t data_len; /* Length of packet data */
88 unsigned char payload[0]; /* Optional packet data */
89} ipq_packet_msg_t;
90.fi
91.RE
92.PP
93Each of these fields may be read by the application. If the queue mode
94is
95.B IPQ_COPY_PACKET
96and the
97.I data_len
98value is greater than zero, the packet payload contents may be accessed
99in the memory following the
100.B ipq_packet_msg_t
101structure to a range of
102.I data_len.
103.PP
104The
105.I packet_id
106field contains a packet identifier to be used when calling
107.BR ipq_set_verdict .
108.PP
109The
110.B ipq_get_msgerr
111function should be called if
112.B ipq_message_type
113returns
114.BR NLMSG_ERROR.
115The
116.I buf
117parameter should point to the same data used for the call to
118.BR ipq_message_type .
119The value returned by
120.B ipq_get_msgerr
121is set by higher level kernel code and corresponds to standard
122.B errno
123values.
124.SH BUGS
125None known.
126.SH AUTHOR
127James Morris <jmorris@intercode.com.au>
128.SH COPYRIGHT
James Morris460c7472001-10-16 14:41:02 +0000129Copyright (c) 2000-2001 Netfilter Core Team.
James Morris949810c2000-11-20 14:13:31 +0000130.PP
131Distributed under the GNU General Public License.
132.SH SEE ALSO
133.BR iptables (8),
134.BR libipq (3).