]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/man/ipl.4
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / man / ipl.4
1 .\"     $FreeBSD$
2 .\"
3 .TH IPL 4
4 .SH NAME
5 ipl \- IP packet log device
6 .SH DESCRIPTION
7 The \fBipl\fP pseudo device's purpose is to provide an easy way to gather
8 packet headers of packets you wish to log.  If a packet header is to be
9 logged, the entire header is logged (including any IP options \- TCP/UDP
10 options are not included when it calculates header size) or not at all.
11 The packet contents are also logged after the header.  If the log reader
12 is busy or otherwise unable to read log records, up to IPLLOGSIZE (8192 is the
13 default) bytes of data are stored.
14 .PP
15 Prepending every packet header logged is a structure containing information
16 relevant to the packet following and why it was logged.  The structure's
17 format is as follows:
18 .LP
19 .nf
20 /*
21  * Log structure.  Each packet header logged is prepended by one of these.
22  * Following this in the log records read from the device will be an ipflog
23  * structure which is then followed by any packet data.
24  */
25 typedef struct iplog    {
26         u_long  ipl_sec;
27         u_long  ipl_usec;
28         u_int   ipl_len;
29         u_int   ipl_count;
30         size_t  ipl_dsize;
31         struct  iplog   *ipl_next;
32 } iplog_t;
33
34
35 typedef struct  ipflog  {
36 #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603))
37         u_char  fl_ifname[IFNAMSIZ];
38 #else
39         u_int   fl_unit;
40         u_char  fl_ifname[4];
41 #endif
42         u_char  fl_plen;        /* extra data after hlen */
43         u_char  fl_hlen;        /* length of IP headers saved */
44         u_short fl_rule;        /* assume never more than 64k rules, total */
45         u_32_t  fl_flags;
46 } ipflog_t;
47
48 .fi
49 .PP
50 When reading from the \fBipl\fP device, it is necessary to call read(2) with
51 a buffer big enough to hold at least 1 complete log record - reading of partial
52 log records is not supported.
53 .PP
54 If the packet contents are more than 128 bytes when \fBlog body\fP is used,
55 then only 128 bytes of the packet contents are logged.
56 .PP
57 Although it is only possible to read from the \fBipl\fP device, opening it
58 for writing is required when using an ioctl which changes any kernel data.
59 .PP
60 The ioctls which are loaded with this device can be found under \fBipf(4)\fP.
61 The ioctls which are for use with logging and don't affect the filter are:
62 .LP
63 .nf
64         ioctl(fd, SIOCIPFFB, int *)
65         ioctl(fd, FIONREAD, int *)
66 .fi
67 .PP
68 The SIOCIPFFB ioctl flushes the log buffer and returns the number of bytes
69 flushed.  FIONREAD returns the number of bytes currently used for storing
70 log data.  If IPFILTER_LOG is not defined when compiling, SIOCIPFFB is not
71 available and FIONREAD will return but not do anything.
72 .PP
73 There is currently no support for non-blocking IO with this device, meaning
74 all read operations should be considered blocking in nature (if there is no
75 data to read, it will sleep until some is made available).
76 .SH SEE ALSO
77 ipf(4)
78 .SH BUGS
79 Packet headers are dropped when the internal buffer (static size) fills.
80 .SH FILES
81 /dev/ipl0