Line data Source code
1 : /* $OpenBSD: ip_ipcomp.h,v 1.10 2017/11/08 16:29:20 visa Exp $ */
2 :
3 : /*
4 : * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org)
5 : *
6 : * Redistribution and use in source and binary forms, with or without
7 : * modification, are permitted provided that the following conditions
8 : * are met:
9 : *
10 : * 1. Redistributions of source code must retain the above copyright
11 : * notice, this list of conditions and the following disclaimer.
12 : * 2. Redistributions in binary form must reproduce the above copyright
13 : * notice, this list of conditions and the following disclaimer in the
14 : * documentation and/or other materials provided with the distribution.
15 : * 3. The name of the author may not be used to endorse or promote products
16 : * derived from this software without specific prior written permission.
17 : *
18 : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 : * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 : * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 : * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 : * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 : * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 : * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 : * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 : * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 : * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 : */
29 :
30 : /* IP payload compression protocol (IPComp), see RFC 2393 */
31 :
32 : #ifndef _NETINET_IP_IPCOMP_H_
33 : #define _NETINET_IP_IPCOMP_H_
34 :
35 : struct ipcompstat {
36 : uint64_t ipcomps_hdrops; /* Packet shorter than header shows */
37 : uint64_t ipcomps_nopf; /* Protocol family not supported */
38 : uint64_t ipcomps_notdb;
39 : uint64_t ipcomps_badkcr;
40 : uint64_t ipcomps_qfull;
41 : uint64_t ipcomps_noxform;
42 : uint64_t ipcomps_wrap;
43 : uint64_t ipcomps_input; /* Input IPcomp packets */
44 : uint64_t ipcomps_output; /* Output IPcomp packets */
45 : uint64_t ipcomps_invalid; /* Trying to use an invalid
46 : * TDB */
47 : uint64_t ipcomps_ibytes; /* Input bytes */
48 : uint64_t ipcomps_obytes; /* Output bytes */
49 : uint64_t ipcomps_toobig; /* Packet got larger than
50 : * IP_MAXPACKET */
51 : uint64_t ipcomps_pdrops; /* Packet blocked due to policy */
52 : uint64_t ipcomps_crypto; /* "Crypto" processing failure */
53 : uint64_t ipcomps_minlen; /* packets too short for compress */
54 : uint64_t ipcomps_outfail; /* Packet output failure */
55 : };
56 :
57 : /* IPCOMP header */
58 : struct ipcomp {
59 : u_int8_t ipcomp_nh; /* Next header */
60 : u_int8_t ipcomp_flags; /* Flags: reserved field: 0 */
61 : u_int16_t ipcomp_cpi; /* Compression Parameter Index,
62 : * Network order */
63 : };
64 :
65 : /* Length of IPCOMP header */
66 : #define IPCOMP_HLENGTH 4
67 :
68 : /*
69 : * Names for IPCOMP sysctl objects
70 : */
71 : #define IPCOMPCTL_ENABLE 1 /* Enable COMP processing */
72 : #define IPCOMPCTL_STATS 2 /* COMP stats */
73 : #define IPCOMPCTL_MAXID 3
74 :
75 : #define IPCOMPCTL_NAMES { \
76 : { 0, 0 }, \
77 : { "enable", CTLTYPE_INT }, \
78 : { "stats", CTLTYPE_STRUCT }, \
79 : }
80 :
81 : #define IPCOMPCTL_VARS { \
82 : NULL, \
83 : &ipcomp_enable, \
84 : NULL \
85 : }
86 :
87 : #ifdef _KERNEL
88 :
89 : #include <sys/percpu.h>
90 :
91 : enum ipcomp_counters {
92 : ipcomps_hdrops, /* Packet shorter than header shows */
93 : ipcomps_nopf, /* Protocol family not supported */
94 : ipcomps_notdb,
95 : ipcomps_badkcr,
96 : ipcomps_qfull,
97 : ipcomps_noxform,
98 : ipcomps_wrap,
99 : ipcomps_input, /* Input IPcomp packets */
100 : ipcomps_output, /* Output IPcomp packets */
101 : ipcomps_invalid, /* Trying to use an invalid
102 : * TDB */
103 : ipcomps_ibytes, /* Input bytes */
104 : ipcomps_obytes, /* Output bytes */
105 : ipcomps_toobig, /* Packet got larger than
106 : * IP_MAXPACKET */
107 : ipcomps_pdrops, /* Packet blocked due to policy */
108 : ipcomps_crypto, /* "Crypto" processing failure */
109 : ipcomps_minlen, /* packets too short for compress */
110 : ipcomps_outfail, /* Packet output failure */
111 :
112 : ipcomps_ncounters
113 : };
114 :
115 : extern struct cpumem *ipcompcounters;
116 :
117 : static inline void
118 0 : ipcompstat_inc(enum ipcomp_counters c)
119 : {
120 0 : counters_inc(ipcompcounters, c);
121 0 : }
122 :
123 : static inline void
124 0 : ipcompstat_add(enum ipcomp_counters c, uint64_t v)
125 : {
126 0 : counters_add(ipcompcounters, c, v);
127 0 : }
128 :
129 : extern int ipcomp_enable;
130 :
131 : #endif /* _KERNEL */
132 : #endif /* _NETINET_IP_IPCOMP_H_ */
|