Deleted Added
full compact
alias.c (179920) alias.c (188294)
1/*-
2 * Copyright (c) 2001 Charles Mott <cm@linktel.net>
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

--- 11 unchanged lines hidden (view full) ---

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>
1/*-
2 * Copyright (c) 2001 Charles Mott <cm@linktel.net>
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

--- 11 unchanged lines hidden (view full) ---

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: head/sys/netinet/libalias/alias.c 179920 2008-06-21 20:18:57Z mav $");
28__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias.c 188294 2009-02-07 18:49:42Z piso $");
29
30/*
31 Alias.c provides supervisory control for the functions of the
32 packet aliasing software. It consists of routines to monitor
33 TCP connection state, protocol-specific aliasing routines,
34 fragment handling and the following outside world functional
35 interfaces: SaveFragmentPtr, GetFragmentPtr, FragmentAliasIn,
36 PacketAliasIn and PacketAliasOut.

--- 73 unchanged lines hidden (view full) ---

110
111 See HISTORY file for additional revisions.
112*/
113
114#ifdef _KERNEL
115#include <sys/param.h>
116#include <sys/systm.h>
117#include <sys/mbuf.h>
29
30/*
31 Alias.c provides supervisory control for the functions of the
32 packet aliasing software. It consists of routines to monitor
33 TCP connection state, protocol-specific aliasing routines,
34 fragment handling and the following outside world functional
35 interfaces: SaveFragmentPtr, GetFragmentPtr, FragmentAliasIn,
36 PacketAliasIn and PacketAliasOut.

--- 73 unchanged lines hidden (view full) ---

110
111 See HISTORY file for additional revisions.
112*/
113
114#ifdef _KERNEL
115#include <sys/param.h>
116#include <sys/systm.h>
117#include <sys/mbuf.h>
118#include <sys/sysctl.h>
118#else
119#include <sys/types.h>
120#include <stdlib.h>
121#include <stdio.h>
122#include <ctype.h>
123#include <dlfcn.h>
124#include <errno.h>
125#include <string.h>

--- 12 unchanged lines hidden (view full) ---

138#include <netinet/libalias/alias_mod.h>
139#else
140#include <err.h>
141#include "alias.h"
142#include "alias_local.h"
143#include "alias_mod.h"
144#endif
145
119#else
120#include <sys/types.h>
121#include <stdlib.h>
122#include <stdio.h>
123#include <ctype.h>
124#include <dlfcn.h>
125#include <errno.h>
126#include <string.h>

--- 12 unchanged lines hidden (view full) ---

139#include <netinet/libalias/alias_mod.h>
140#else
141#include <err.h>
142#include "alias.h"
143#include "alias_local.h"
144#include "alias_mod.h"
145#endif
146
147/*
148 * Define libalias SYSCTL Node
149 */
150#ifdef SYSCTL_NODE
151
152SYSCTL_DECL(_net_inet);
153SYSCTL_DECL(_net_inet_ip);
154SYSCTL_NODE(_net_inet_ip, OID_AUTO, alias, CTLFLAG_RW, NULL, "Libalias sysctl API");
155
156#endif
157
146static __inline int
147twowords(void *p)
148{
149 uint8_t *c = p;
150
151#if BYTE_ORDER == LITTLE_ENDIAN
152 uint16_t s1 = ((uint16_t)c[1] << 8) + (uint16_t)c[0];
153 uint16_t s2 = ((uint16_t)c[3] << 8) + (uint16_t)c[2];

--- 1176 unchanged lines hidden (view full) ---

1330 iresult = IcmpAliasIn(la, pip);
1331 break;
1332 case IPPROTO_UDP:
1333 iresult = UdpAliasIn(la, pip);
1334 break;
1335 case IPPROTO_TCP:
1336 iresult = TcpAliasIn(la, pip);
1337 break;
158static __inline int
159twowords(void *p)
160{
161 uint8_t *c = p;
162
163#if BYTE_ORDER == LITTLE_ENDIAN
164 uint16_t s1 = ((uint16_t)c[1] << 8) + (uint16_t)c[0];
165 uint16_t s2 = ((uint16_t)c[3] << 8) + (uint16_t)c[2];

--- 1176 unchanged lines hidden (view full) ---

1342 iresult = IcmpAliasIn(la, pip);
1343 break;
1344 case IPPROTO_UDP:
1345 iresult = UdpAliasIn(la, pip);
1346 break;
1347 case IPPROTO_TCP:
1348 iresult = TcpAliasIn(la, pip);
1349 break;
1350#ifdef _KERNEL
1351 case IPPROTO_SCTP:
1352 iresult = SctpAlias(la, pip, SN_TO_LOCAL);
1353 break;
1354#endif
1338 case IPPROTO_GRE: {
1339 int error;
1340 struct alias_data ad = {
1341 .lnk = NULL,
1342 .oaddr = NULL,
1343 .aaddr = NULL,
1344 .aport = NULL,
1345 .sport = NULL,

--- 126 unchanged lines hidden (view full) ---

1472 if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0) {
1473 switch (pip->ip_p) {
1474 case IPPROTO_ICMP:
1475 iresult = IcmpAliasOut(la, pip, create);
1476 break;
1477 case IPPROTO_UDP:
1478 iresult = UdpAliasOut(la, pip, maxpacketsize, create);
1479 break;
1355 case IPPROTO_GRE: {
1356 int error;
1357 struct alias_data ad = {
1358 .lnk = NULL,
1359 .oaddr = NULL,
1360 .aaddr = NULL,
1361 .aport = NULL,
1362 .sport = NULL,

--- 126 unchanged lines hidden (view full) ---

1489 if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0) {
1490 switch (pip->ip_p) {
1491 case IPPROTO_ICMP:
1492 iresult = IcmpAliasOut(la, pip, create);
1493 break;
1494 case IPPROTO_UDP:
1495 iresult = UdpAliasOut(la, pip, maxpacketsize, create);
1496 break;
1480 case IPPROTO_TCP:
1497 case IPPROTO_TCP:
1481 iresult = TcpAliasOut(la, pip, maxpacketsize, create);
1482 break;
1498 iresult = TcpAliasOut(la, pip, maxpacketsize, create);
1499 break;
1483 case IPPROTO_GRE: {
1500#ifdef _KERNEL
1501 case IPPROTO_SCTP:
1502 iresult = SctpAlias(la, pip, SN_TO_GLOBAL);
1503 break;
1504#endif
1505 case IPPROTO_GRE: {
1484 int error;
1485 struct alias_data ad = {
1486 .lnk = NULL,
1487 .oaddr = NULL,
1488 .aaddr = NULL,
1489 .aport = NULL,
1490 .sport = NULL,
1491 .dport = NULL,

--- 284 unchanged lines hidden ---
1506 int error;
1507 struct alias_data ad = {
1508 .lnk = NULL,
1509 .oaddr = NULL,
1510 .aaddr = NULL,
1511 .aport = NULL,
1512 .sport = NULL,
1513 .dport = NULL,

--- 284 unchanged lines hidden ---