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