Blame libipq/ipq_message_type.3

Packit 7b22a4
.TH IPQ_MESSAGE_TYPE 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual" 
Packit 7b22a4
.\"
Packit 7b22a4
.\"     Copyright (c) 2000-2001 Netfilter Core Team
Packit 7b22a4
.\"
Packit 7b22a4
.\"     This program is free software; you can redistribute it and/or modify
Packit 7b22a4
.\"     it under the terms of the GNU General Public License as published by
Packit 7b22a4
.\"     the Free Software Foundation; either version 2 of the License, or
Packit 7b22a4
.\"     (at your option) any later version.
Packit 7b22a4
.\"
Packit 7b22a4
.\"     This program is distributed in the hope that it will be useful,
Packit 7b22a4
.\"     but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7b22a4
.\"     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7b22a4
.\"     GNU General Public License for more details.
Packit 7b22a4
.\"
Packit 7b22a4
.\"     You should have received a copy of the GNU General Public License
Packit 7b22a4
.\"     along with this program; if not, write to the Free Software
Packit 7b22a4
.\"     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit 7b22a4
.\"
Packit 7b22a4
.\"
Packit 7b22a4
.SH NAME
Packit 7b22a4
ipq_message_type, ipq_get_packet, ipq_getmsgerr \(em query queue messages
Packit 7b22a4
.SH SYNOPSIS
Packit 7b22a4
.B #include <linux/netfilter.h>
Packit 7b22a4
.br
Packit 7b22a4
.B #include <libipq.h>
Packit 7b22a4
.sp
Packit 7b22a4
.BI "int ipq_message_type(const unsigned char *" buf ");"
Packit 7b22a4
.br
Packit 7b22a4
.BI "ipq_packet_msg_t *ipq_get_packet(const unsigned char *" buf ");"
Packit 7b22a4
.br
Packit 7b22a4
.BI "int ipq_get_msgerr(const unsigned char *" buf ");"
Packit 7b22a4
.SH DESCRIPTION
Packit 7b22a4
The
Packit 7b22a4
.B ipq_message_type
Packit 7b22a4
function returns the type of queue message returned to userspace
Packit 7b22a4
via
Packit 7b22a4
.BR ipq_read .
Packit 7b22a4
.PP
Packit 7b22a4
.B ipq_message_type
Packit 7b22a4
should always be called following a successful call to
Packit 7b22a4
.B ipq_read
Packit 7b22a4
to determine whether the message is a packet message or an
Packit 7b22a4
error message. The
Packit 7b22a4
.I buf
Packit 7b22a4
parameter should be the same data obtained from
Packit 7b22a4
the previous call to
Packit 7b22a4
.BR ipq_read .
Packit 7b22a4
.PP
Packit 7b22a4
.B ipq_message_type
Packit 7b22a4
will return one of the following values:
Packit 7b22a4
.TP
Packit 7b22a4
.B NLMSG_ERROR
Packit 7b22a4
An error message generated by the Netlink transport.
Packit 7b22a4
.PP
Packit 7b22a4
.TP
Packit 7b22a4
.B IPQM_PACKET
Packit 7b22a4
A packet message containing packet metadata and optional packet payload data.
Packit 7b22a4
.PP
Packit 7b22a4
The
Packit 7b22a4
.B ipq_get_packet
Packit 7b22a4
function should be called if
Packit 7b22a4
.B ipq_message_type
Packit 7b22a4
returns
Packit 7b22a4
.BR IPQM_PACKET .
Packit 7b22a4
The
Packit 7b22a4
.I buf
Packit 7b22a4
parameter should point to the same data used for the call to
Packit 7b22a4
.BR ipq_message_type .
Packit 7b22a4
The pointer returned by
Packit 7b22a4
.B ipq_get_packet
Packit 7b22a4
points to a packet message, which is declared as follows:
Packit 7b22a4
.PP
Packit 7b22a4
.RS
Packit 7b22a4
.nf
Packit 7b22a4
typedef struct ipq_packet_msg {
Packit 7b22a4
	unsigned long packet_id;        /* ID of queued packet */
Packit 7b22a4
	unsigned long mark;             /* Netfilter mark value */
Packit 7b22a4
	long timestamp_sec;             /* Packet arrival time (seconds) */
Packit 7b22a4
	long timestamp_usec;            /* Packet arrvial time (+useconds) */
Packit 7b22a4
	unsigned int hook;              /* Netfilter hook we rode in on */
Packit 7b22a4
	char indev_name[IFNAMSIZ];      /* Name of incoming interface */
Packit 7b22a4
	char outdev_name[IFNAMSIZ];     /* Name of outgoing interface */
Packit 7b22a4
	unsigned short hw_protocol;     /* Hardware protocol (network order) */
Packit 7b22a4
	unsigned short hw_type;         /* Hardware type */
Packit 7b22a4
	unsigned char hw_addrlen;       /* Hardware address length */
Packit 7b22a4
	unsigned char hw_addr[8];       /* Hardware address */
Packit 7b22a4
	size_t data_len;                /* Length of packet data */
Packit 7b22a4
	unsigned char payload[0];       /* Optional packet data */
Packit 7b22a4
} ipq_packet_msg_t;
Packit 7b22a4
.fi
Packit 7b22a4
.RE
Packit 7b22a4
.PP
Packit 7b22a4
Each of these fields may be read by the application.  If the queue mode
Packit 7b22a4
is
Packit 7b22a4
.B IPQ_COPY_PACKET
Packit 7b22a4
and the
Packit 7b22a4
.I data_len
Packit 7b22a4
value is greater than zero, the packet payload contents may be accessed
Packit 7b22a4
in the memory following the
Packit 7b22a4
.B ipq_packet_msg_t
Packit 7b22a4
structure to a range of
Packit 7b22a4
.I data_len.
Packit 7b22a4
.PP
Packit 7b22a4
The
Packit 7b22a4
.I packet_id
Packit 7b22a4
field contains a packet identifier to be used when calling
Packit 7b22a4
.BR ipq_set_verdict .
Packit 7b22a4
.PP
Packit 7b22a4
The
Packit 7b22a4
.B ipq_get_msgerr
Packit 7b22a4
function should be called if
Packit 7b22a4
.B ipq_message_type
Packit 7b22a4
returns
Packit 7b22a4
.BR NLMSG_ERROR.
Packit 7b22a4
The
Packit 7b22a4
.I buf
Packit 7b22a4
parameter should point to the same data used for the call to
Packit 7b22a4
.BR ipq_message_type .
Packit 7b22a4
The value returned by
Packit 7b22a4
.B ipq_get_msgerr
Packit 7b22a4
is set by higher level kernel code and corresponds to standard
Packit 7b22a4
.B errno
Packit 7b22a4
values.
Packit 7b22a4
.SH BUGS
Packit 7b22a4
None known.
Packit 7b22a4
.SH AUTHOR
Packit 7b22a4
James Morris <jmorris@intercode.com.au>
Packit 7b22a4
.SH COPYRIGHT
Packit 7b22a4
Copyright (c) 2000-2001 Netfilter Core Team.
Packit 7b22a4
.PP
Packit 7b22a4
Distributed under the GNU General Public License.
Packit 7b22a4
.SH SEE ALSO
Packit 7b22a4
.BR iptables (8),
Packit 7b22a4
.BR libipq (3).