]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/netinet/libalias/alias_old.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / netinet / libalias / alias_old.c
1 /*-
2  * Copyright (c) 2004 Poul-Henning Kamp <phk@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #ifdef _KERNEL
31 #include <sys/param.h>
32 #include <sys/proc.h>
33 #else
34 #include <sys/types.h>
35 #include <stdlib.h>
36 #endif
37
38 #include <netinet/in.h>
39
40 #ifdef _KERNEL
41 #include <netinet/libalias/alias.h>
42 #else
43 #include "alias.h"
44 #endif
45
46 /*
47  * These functions are for backwards compatibility and because apps may
48  * be linked against shlib versions, they have to be actual functions,
49  * we cannot inline them.
50  */
51
52 static struct libalias *la;
53
54 void
55 PacketAliasInit(void)
56 {
57
58         la = LibAliasInit(la);
59 }
60
61 void
62 PacketAliasSetAddress(struct in_addr _addr)
63 {
64
65         LibAliasSetAddress(la, _addr);
66 }
67
68 void
69 PacketAliasSetFWBase(unsigned int _base, unsigned int _num)
70 {
71
72         LibAliasSetFWBase(la, _base, _num);
73 }
74
75 void
76 PacketAliasSetSkinnyPort(unsigned int _port)
77 {
78
79         LibAliasSetSkinnyPort(la, _port);
80 }
81
82 unsigned int
83 PacketAliasSetMode(unsigned int _flags, unsigned int _mask)
84 {
85
86         return LibAliasSetMode(la, _flags, _mask);
87 }
88
89 void
90 PacketAliasUninit(void)
91 {
92
93         LibAliasUninit(la);
94         la = NULL;
95 }
96
97 int
98 PacketAliasIn(char *_ptr, int _maxpacketsize)
99 {
100         return LibAliasIn(la, _ptr, _maxpacketsize);
101 }
102
103 int
104 PacketAliasOut(char *_ptr, int _maxpacketsize)
105 {
106
107         return LibAliasOut(la, _ptr, _maxpacketsize);
108 }
109
110 int
111 PacketUnaliasOut(char *_ptr, int _maxpacketsize)
112 {
113
114         return LibAliasUnaliasOut(la, _ptr, _maxpacketsize);
115 }
116
117 int
118 PacketAliasAddServer(struct alias_link *_lnk,
119     struct in_addr _addr, unsigned short _port)
120 {
121
122         return LibAliasAddServer(la, _lnk, _addr, _port);
123 }
124
125 struct alias_link *
126 PacketAliasRedirectAddr(struct in_addr _src_addr,
127     struct in_addr _alias_addr)
128 {
129
130         return LibAliasRedirectAddr(la, _src_addr, _alias_addr);
131 }
132
133
134 int
135 PacketAliasRedirectDynamic(struct alias_link *_lnk)
136 {
137
138         return LibAliasRedirectDynamic(la, _lnk);
139 }
140
141 void
142 PacketAliasRedirectDelete(struct alias_link *_lnk)
143 {
144
145         LibAliasRedirectDelete(la, _lnk);
146 }
147
148 struct alias_link *
149 PacketAliasRedirectPort(struct in_addr _src_addr,
150     unsigned short _src_port, struct in_addr _dst_addr,
151     unsigned short _dst_port, struct in_addr _alias_addr,
152     unsigned short _alias_port, unsigned char _proto)
153 {
154
155         return LibAliasRedirectPort(la, _src_addr, _src_port, _dst_addr,
156             _dst_port, _alias_addr, _alias_port, _proto);
157 }
158
159 struct alias_link *
160 PacketAliasRedirectProto(struct in_addr _src_addr,
161     struct in_addr _dst_addr, struct in_addr _alias_addr,
162     unsigned char _proto)
163 {
164
165         return LibAliasRedirectProto(la, _src_addr, _dst_addr, _alias_addr,
166             _proto);
167 }
168
169 void
170 PacketAliasFragmentIn(char *_ptr, char *_ptr_fragment)
171 {
172
173         LibAliasFragmentIn(la, _ptr, _ptr_fragment);
174 }
175
176 char           *
177 PacketAliasGetFragment(char *_ptr)
178 {
179
180         return LibAliasGetFragment(la, _ptr);
181 }
182
183 int
184 PacketAliasSaveFragment(char *_ptr)
185 {
186         return LibAliasSaveFragment(la, _ptr);
187 }
188
189 int
190 PacketAliasCheckNewLink(void)
191 {
192
193         return LibAliasCheckNewLink(la);
194 }
195
196 unsigned short
197 PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes)
198 {
199
200         return LibAliasInternetChecksum(la, _ptr, _nbytes);
201 }
202
203 void
204 PacketAliasSetTarget(struct in_addr _target_addr)
205 {
206
207         LibAliasSetTarget(la, _target_addr);
208 }
209
210 /* Transparent proxying routines. */
211 int
212 PacketAliasProxyRule(const char *_cmd)
213 {
214
215         return LibAliasProxyRule(la, _cmd);
216 }