summaryrefslogtreecommitdiffstats
path: root/libipq/ipq_message_type.3
blob: 4a2de1dcd9778c4967021be52566c8485097f59d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
.TH IPQ_MESSAGE_TYPE 3 "18 November 2000" "Linux iptables 1.1.3+" "Linux Programmer's Manual" 
.\"
.\" $Id: $
.\"
.\"     Copyright (c) 2000 Netfilter Core Team
.\"
.\"     This program is free software; you can redistribute it and/or modify
.\"     it under the terms of the GNU General Public License as published by
.\"     the Free Software Foundation; either version 2 of the License, or
.\"     (at your option) any later version.
.\"
.\"     This program is distributed in the hope that it will be useful,
.\"     but WITHOUT ANY WARRANTY; without even the implied warranty of
.\"     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\"     GNU General Public License for more details.
.\"
.\"     You should have received a copy of the GNU General Public License
.\"     along with this program; if not, write to the Free Software
.\"     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
.\"
.\"
.SH NAME
ipq_message_type, ipq_get_packet, ipq_getmsgerr - query queue messages
.SH SYNOPSIS
.B #include <linux/netfilter.h>
.br
.B #include <libipq.h>
.sp
.BI "int ipq_message_type(const unsigned char *" buf ");"
.br
.BI "ipq_packet_msg_t *ipq_get_packet(const unsigned char *" buf ");"
.br
.BI "int ipq_get_msgerr(const unsigned char *" buf ");"
.SH DESCRIPTION
The
.B ipq_message_type
function returns the type of queue message returned to userspace
via
.BR ipq_read .
.PP
.B ipq_message_type
should always be called following a successful call to
.B ipq_read
to determine whether the message is a packet message or an
error message. The
.I buf
parameter should be the same data obtained from
the previous call to
.BR ipq_read .
.PP
.B ipq_message_type
will return one of the following values:
.TP
.B NLMSG_ERROR
An error message generated by the Netlink transport.
.PP
.TP
.B IPQM_PACKET
A packet message containing packet metadata and optional packet payload data.
.PP
The
.B ipq_get_packet
function should be called if
.B ipq_message_type
returns
.BR IPQM_PACKET .
The
.I buf
parameter should point to the same data used for the call to
.BR ipq_message_type .
The pointer returned by
.B ipq_get_packet
points to a packet message, which is declared as follows:
.PP
.RS
.nf
typedef struct ipq_packet_msg {
	unsigned long packet_id;        /* ID of queued packet */
	unsigned long mark;             /* Netfilter mark value */
	long timestamp_sec;             /* Packet arrival time (seconds) */
	long timestamp_usec;            /* Packet arrvial time (+useconds) */
	unsigned int hook;              /* Netfilter hook we rode in on */
	char indev_name[IFNAMSIZ];      /* Name of incoming interface */
	char outdev_name[IFNAMSIZ];     /* Name of outgoing interface */
	unsigned short hw_protocol;     /* Hardware protocol (network order) */
	unsigned short hw_type;         /* Hardware type */
	unsigned char hw_addrlen;       /* Hardware address length */
	unsigned char hw_addr[8];       /* Hardware address */
	size_t data_len;                /* Length of packet data */
	unsigned char payload[0];       /* Optional packet data */
} ipq_packet_msg_t;
.fi
.RE
.PP
Each of these fields may be read by the application.  If the queue mode
is
.B IPQ_COPY_PACKET
and the
.I data_len
value is greater than zero, the packet payload contents may be accessed
in the memory following the
.B ipq_packet_msg_t
structure to a range of
.I data_len.
.PP
The
.I packet_id
field contains a packet identifier to be used when calling
.BR ipq_set_verdict .
.PP
The
.B ipq_get_msgerr
function should be called if
.B ipq_message_type
returns
.BR NLMSG_ERROR.
The
.I buf
parameter should point to the same data used for the call to
.BR ipq_message_type .
The value returned by
.B ipq_get_msgerr
is set by higher level kernel code and corresponds to standard
.B errno
values.
.SH BUGS
None known.
.SH AUTHOR
James Morris <jmorris@intercode.com.au>
.SH COPYRIGHT
Copyright (c) 2000 Netfilter Core Team.
.PP
Distributed under the GNU General Public License.
.SH SEE ALSO
.BR iptables (8),
.BR libipq (3).