2001-06-04 15:09:51 +00:00
|
|
|
/*-
|
2001-11-03 11:34:09 +00:00
|
|
|
* Copyright (c) 2001 Charles Mott <cm@linktel.net>
|
2001-06-04 15:09:51 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-09-30 21:03:33 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
/*
|
|
|
|
Alias_ftp.c performs special processing for FTP sessions under
|
2000-06-16 20:36:16 +00:00
|
|
|
TCP. Specifically, when a PORT/EPRT command from the client
|
|
|
|
side or 227/229 reply from the server is sent, it is intercepted
|
2000-06-14 16:09:35 +00:00
|
|
|
and modified. The address is changed to the gateway machine
|
|
|
|
and an aliasing port is used.
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
For this routine to work, the message must fit entirely into a
|
|
|
|
single TCP packet. This is typically the case, but exceptions
|
1997-05-23 04:41:31 +00:00
|
|
|
can easily be envisioned under the actual specifications.
|
|
|
|
|
|
|
|
Probably the most troubling aspect of the approach taken here is
|
2000-06-16 20:36:16 +00:00
|
|
|
that the new message will typically be a different length, and
|
1997-05-23 04:41:31 +00:00
|
|
|
this causes a certain amount of bookkeeping to keep track of the
|
|
|
|
changes of sequence and acknowledgment numbers, since the client
|
|
|
|
machine is totally unaware of the modification to the TCP stream.
|
|
|
|
|
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
References: RFC 959, RFC 2428.
|
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
Initial version: August, 1996 (cjm)
|
|
|
|
|
|
|
|
Version 1.6
|
2004-07-05 10:53:28 +00:00
|
|
|
Brian Somers and Martin Renters identified an IP checksum
|
|
|
|
error for modified IP packets.
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
Version 1.7: January 9, 1996 (cjm)
|
2004-07-05 10:53:28 +00:00
|
|
|
Differential checksum computation for change
|
|
|
|
in IP packet length.
|
2000-06-16 20:36:16 +00:00
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
Version 2.1: May, 1997 (cjm)
|
2004-07-05 10:53:28 +00:00
|
|
|
Very minor changes to conform with
|
|
|
|
local/global/function naming conventions
|
|
|
|
within the packet aliasing module.
|
1998-01-09 21:13:35 +00:00
|
|
|
|
2000-06-14 16:09:35 +00:00
|
|
|
Version 3.1: May, 2000 (eds)
|
|
|
|
Add support for passive mode, alias the 227 replies.
|
|
|
|
|
1998-01-09 21:13:35 +00:00
|
|
|
See HISTORY file for record of revisions.
|
1997-05-23 04:41:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Includes */
|
2005-05-05 19:27:32 +00:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/ctype.h>
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
2005-05-05 19:27:32 +00:00
|
|
|
#else
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#include <errno.h>
|
2005-05-05 19:27:32 +00:00
|
|
|
#include <sys/types.h>
|
2000-06-16 20:36:16 +00:00
|
|
|
#include <stdio.h>
|
2005-05-05 19:27:32 +00:00
|
|
|
#endif
|
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
|
2005-05-05 19:27:32 +00:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#include <netinet/libalias/alias.h>
|
2005-05-05 21:55:17 +00:00
|
|
|
#include <netinet/libalias/alias_local.h>
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#include <netinet/libalias/alias_mod.h>
|
2005-05-05 19:27:32 +00:00
|
|
|
#else
|
1997-05-23 04:41:31 +00:00
|
|
|
#include "alias_local.h"
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#include "alias_mod.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FTP_CONTROL_PORT_NUMBER 21
|
|
|
|
|
|
|
|
static void
|
|
|
|
AliasHandleFtpOut(struct libalias *, struct ip *, struct alias_link *,
|
|
|
|
int maxpacketsize);
|
|
|
|
|
|
|
|
static int
|
|
|
|
fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL ||
|
|
|
|
ah->maxpktsize == 0)
|
|
|
|
return (-1);
|
|
|
|
if (ntohs(*ah->dport) == FTP_CONTROL_PORT_NUMBER
|
|
|
|
|| ntohs(*ah->sport) == FTP_CONTROL_PORT_NUMBER)
|
|
|
|
return (0);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah)
|
|
|
|
{
|
|
|
|
|
|
|
|
AliasHandleFtpOut(la, pip, ah->lnk, ah->maxpktsize);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct proto_handler handlers[] = {
|
|
|
|
{
|
|
|
|
.pri = 80,
|
|
|
|
.dir = OUT,
|
|
|
|
.proto = TCP,
|
|
|
|
.fingerprint = &fingerprint,
|
|
|
|
.protohandler = &protohandler
|
|
|
|
},
|
|
|
|
{ EOH }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
mod_handler(module_t mod, int type, void *data)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case MOD_LOAD:
|
|
|
|
error = 0;
|
|
|
|
LibAliasAttachHandlers(handlers);
|
|
|
|
break;
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
error = 0;
|
|
|
|
LibAliasDetachHandlers(handlers);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
static
|
|
|
|
#endif
|
|
|
|
moduledata_t alias_mod = {
|
|
|
|
"alias_ftp", mod_handler, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
DECLARE_MODULE(alias_ftp, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
|
|
|
|
MODULE_VERSION(alias_ftp, 1);
|
|
|
|
MODULE_DEPEND(alias_ftp, libalias, 1, 1, 1);
|
2005-05-05 19:27:32 +00:00
|
|
|
#endif
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
#define FTP_CONTROL_PORT_NUMBER 21
|
|
|
|
#define MAX_MESSAGE_SIZE 128
|
2000-06-14 16:09:35 +00:00
|
|
|
|
2001-05-30 14:24:35 +00:00
|
|
|
/* FTP protocol flags. */
|
|
|
|
#define WAIT_CRLF 0x01
|
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
enum ftp_message_type {
|
2004-03-16 21:30:41 +00:00
|
|
|
FTP_PORT_COMMAND,
|
|
|
|
FTP_EPRT_COMMAND,
|
|
|
|
FTP_227_REPLY,
|
|
|
|
FTP_229_REPLY,
|
|
|
|
FTP_UNKNOWN_MESSAGE
|
2000-06-16 20:36:16 +00:00
|
|
|
};
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
static int ParseFtpPortCommand(struct libalias *la, char *, int);
|
|
|
|
static int ParseFtpEprtCommand(struct libalias *la, char *, int);
|
|
|
|
static int ParseFtp227Reply(struct libalias *la, char *, int);
|
|
|
|
static int ParseFtp229Reply(struct libalias *la, char *, int);
|
|
|
|
static void NewFtpMessage(struct libalias *la, struct ip *, struct alias_link *, int, int);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
static void
|
1997-05-23 04:41:31 +00:00
|
|
|
AliasHandleFtpOut(
|
2004-03-16 21:30:41 +00:00
|
|
|
struct libalias *la,
|
|
|
|
struct ip *pip, /* IP packet to examine/patch */
|
2004-07-05 11:10:57 +00:00
|
|
|
struct alias_link *lnk, /* The link to go through (aliased port) */
|
2004-03-16 21:30:41 +00:00
|
|
|
int maxpacketsize /* The maximum size this packet can grow to
|
2004-07-05 10:53:28 +00:00
|
|
|
(including headers) */ )
|
1997-05-23 04:41:31 +00:00
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
int hlen, tlen, dlen, pflags;
|
|
|
|
char *sptr;
|
|
|
|
struct tcphdr *tc;
|
|
|
|
int ftp_message_type;
|
2000-06-16 20:36:16 +00:00
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
/* Calculate data length of TCP packet */
|
2004-07-06 12:13:28 +00:00
|
|
|
tc = (struct tcphdr *)ip_next(pip);
|
2004-03-16 21:30:41 +00:00
|
|
|
hlen = (pip->ip_hl + tc->th_off) << 2;
|
|
|
|
tlen = ntohs(pip->ip_len);
|
|
|
|
dlen = tlen - hlen;
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* Place string pointer and beginning of data */
|
2004-03-16 21:30:41 +00:00
|
|
|
sptr = (char *)pip;
|
|
|
|
sptr += hlen;
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
/*
|
|
|
|
* Check that data length is not too long and previous message was
|
|
|
|
* properly terminated with CRLF.
|
|
|
|
*/
|
2004-07-05 11:10:57 +00:00
|
|
|
pflags = GetProtocolFlags(lnk);
|
2004-03-16 21:30:41 +00:00
|
|
|
if (dlen <= MAX_MESSAGE_SIZE && !(pflags & WAIT_CRLF)) {
|
|
|
|
ftp_message_type = FTP_UNKNOWN_MESSAGE;
|
2000-06-16 20:36:16 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER) {
|
2000-06-16 20:36:16 +00:00
|
|
|
/*
|
|
|
|
* When aliasing a client, check for the PORT/EPRT command.
|
|
|
|
*/
|
2004-03-16 21:30:41 +00:00
|
|
|
if (ParseFtpPortCommand(la, sptr, dlen))
|
|
|
|
ftp_message_type = FTP_PORT_COMMAND;
|
|
|
|
else if (ParseFtpEprtCommand(la, sptr, dlen))
|
|
|
|
ftp_message_type = FTP_EPRT_COMMAND;
|
|
|
|
} else {
|
2000-06-16 20:36:16 +00:00
|
|
|
/*
|
|
|
|
* When aliasing a server, check for the 227/229 reply.
|
|
|
|
*/
|
2004-03-16 21:30:41 +00:00
|
|
|
if (ParseFtp227Reply(la, sptr, dlen))
|
|
|
|
ftp_message_type = FTP_227_REPLY;
|
|
|
|
else if (ParseFtp229Reply(la, sptr, dlen)) {
|
|
|
|
ftp_message_type = FTP_229_REPLY;
|
|
|
|
la->true_addr.s_addr = pip->ip_src.s_addr;
|
|
|
|
}
|
|
|
|
}
|
2000-06-14 16:09:35 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
if (ftp_message_type != FTP_UNKNOWN_MESSAGE)
|
2004-07-05 11:10:57 +00:00
|
|
|
NewFtpMessage(la, pip, lnk, maxpacketsize, ftp_message_type);
|
2004-03-16 21:30:41 +00:00
|
|
|
}
|
2000-06-14 16:09:35 +00:00
|
|
|
/* Track the msgs which are CRLF term'd for PORT/PASV FW breach */
|
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
if (dlen) { /* only if there's data */
|
|
|
|
sptr = (char *)pip; /* start over at beginning */
|
|
|
|
tlen = ntohs(pip->ip_len); /* recalc tlen, pkt may
|
|
|
|
* have grown */
|
|
|
|
if (sptr[tlen - 2] == '\r' && sptr[tlen - 1] == '\n')
|
|
|
|
pflags &= ~WAIT_CRLF;
|
|
|
|
else
|
|
|
|
pflags |= WAIT_CRLF;
|
2004-07-05 11:10:57 +00:00
|
|
|
SetProtocolFlags(lnk, pflags);
|
2004-03-16 21:30:41 +00:00
|
|
|
}
|
2000-04-06 15:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-01-17 10:52:21 +00:00
|
|
|
ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
|
2000-04-06 15:54:52 +00:00
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
char ch;
|
|
|
|
int i, state;
|
|
|
|
u_int32_t addr;
|
|
|
|
u_short port;
|
|
|
|
u_int8_t octet;
|
|
|
|
|
|
|
|
/* Format: "PORT A,D,D,R,PO,RT". */
|
|
|
|
|
|
|
|
/* Return if data length is too short. */
|
|
|
|
if (dlen < 18)
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
addr = port = octet = 0;
|
|
|
|
state = -4;
|
|
|
|
for (i = 0; i < dlen; i++) {
|
|
|
|
ch = sptr[i];
|
|
|
|
switch (state) {
|
|
|
|
case -4:
|
|
|
|
if (ch == 'P')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -3:
|
|
|
|
if (ch == 'O')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
if (ch == 'R')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
if (ch == 'T')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
if (isspace(ch))
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
state++;
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
case 5:
|
|
|
|
case 7:
|
|
|
|
case 9:
|
|
|
|
case 11:
|
|
|
|
if (isdigit(ch)) {
|
|
|
|
octet = ch - '0';
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 6:
|
|
|
|
case 8:
|
|
|
|
if (isdigit(ch))
|
|
|
|
octet = 10 * octet + ch - '0';
|
|
|
|
else if (ch == ',') {
|
|
|
|
addr = (addr << 8) + octet;
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
case 12:
|
|
|
|
if (isdigit(ch))
|
|
|
|
octet = 10 * octet + ch - '0';
|
|
|
|
else if (ch == ',' || state == 12) {
|
|
|
|
port = (port << 8) + octet;
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-04-06 15:54:52 +00:00
|
|
|
}
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
if (state == 13) {
|
|
|
|
la->true_addr.s_addr = htonl(addr);
|
|
|
|
la->true_port = port;
|
2004-07-05 10:55:23 +00:00
|
|
|
return (1);
|
2004-03-16 21:30:41 +00:00
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2000-04-06 15:54:52 +00:00
|
|
|
}
|
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
static int
|
2004-01-17 10:52:21 +00:00
|
|
|
ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
|
2000-04-06 15:54:52 +00:00
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
char ch, delim;
|
|
|
|
int i, state;
|
|
|
|
u_int32_t addr;
|
|
|
|
u_short port;
|
|
|
|
u_int8_t octet;
|
|
|
|
|
|
|
|
/* Format: "EPRT |1|A.D.D.R|PORT|". */
|
|
|
|
|
|
|
|
/* Return if data length is too short. */
|
|
|
|
if (dlen < 18)
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
addr = port = octet = 0;
|
|
|
|
delim = '|'; /* XXX gcc -Wuninitialized */
|
|
|
|
state = -4;
|
|
|
|
for (i = 0; i < dlen; i++) {
|
|
|
|
ch = sptr[i];
|
|
|
|
switch (state) {
|
|
|
|
case -4:
|
|
|
|
if (ch == 'E')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -3:
|
|
|
|
if (ch == 'P')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
if (ch == 'R')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
if (ch == 'T')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
if (!isspace(ch)) {
|
|
|
|
delim = ch;
|
|
|
|
state++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (ch == '1') /* IPv4 address */
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (ch == delim)
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 5:
|
|
|
|
case 7:
|
|
|
|
case 9:
|
|
|
|
if (isdigit(ch)) {
|
|
|
|
octet = ch - '0';
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 6:
|
|
|
|
case 8:
|
|
|
|
case 10:
|
|
|
|
if (isdigit(ch))
|
|
|
|
octet = 10 * octet + ch - '0';
|
|
|
|
else if (ch == '.' || state == 10) {
|
|
|
|
addr = (addr << 8) + octet;
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
if (isdigit(ch)) {
|
|
|
|
port = ch - '0';
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
if (isdigit(ch))
|
|
|
|
port = 10 * port + ch - '0';
|
|
|
|
else if (ch == delim)
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-04-06 15:54:52 +00:00
|
|
|
}
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
if (state == 13) {
|
|
|
|
la->true_addr.s_addr = htonl(addr);
|
|
|
|
la->true_port = port;
|
2004-07-05 10:55:23 +00:00
|
|
|
return (1);
|
2004-03-16 21:30:41 +00:00
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2000-06-14 16:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-01-17 10:52:21 +00:00
|
|
|
ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
|
2000-06-14 16:09:35 +00:00
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
char ch;
|
|
|
|
int i, state;
|
|
|
|
u_int32_t addr;
|
|
|
|
u_short port;
|
|
|
|
u_int8_t octet;
|
|
|
|
|
|
|
|
/* Format: "227 Entering Passive Mode (A,D,D,R,PO,RT)" */
|
|
|
|
|
|
|
|
/* Return if data length is too short. */
|
|
|
|
if (dlen < 17)
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
addr = port = octet = 0;
|
|
|
|
|
|
|
|
state = -3;
|
|
|
|
for (i = 0; i < dlen; i++) {
|
|
|
|
ch = sptr[i];
|
|
|
|
switch (state) {
|
|
|
|
case -3:
|
|
|
|
if (ch == '2')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
if (ch == '2')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
if (ch == '7')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
if (ch == '(')
|
|
|
|
state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
case 5:
|
|
|
|
case 7:
|
|
|
|
case 9:
|
|
|
|
case 11:
|
|
|
|
if (isdigit(ch)) {
|
|
|
|
octet = ch - '0';
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 6:
|
|
|
|
case 8:
|
|
|
|
if (isdigit(ch))
|
|
|
|
octet = 10 * octet + ch - '0';
|
|
|
|
else if (ch == ',') {
|
|
|
|
addr = (addr << 8) + octet;
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
case 12:
|
|
|
|
if (isdigit(ch))
|
|
|
|
octet = 10 * octet + ch - '0';
|
|
|
|
else if (ch == ',' || (state == 12 && ch == ')')) {
|
|
|
|
port = (port << 8) + octet;
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-06-16 20:36:16 +00:00
|
|
|
}
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
if (state == 13) {
|
|
|
|
la->true_port = port;
|
|
|
|
la->true_addr.s_addr = htonl(addr);
|
2004-07-05 10:55:23 +00:00
|
|
|
return (1);
|
2004-03-16 21:30:41 +00:00
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2000-06-16 20:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-01-17 10:52:21 +00:00
|
|
|
ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
|
2000-06-16 20:36:16 +00:00
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
char ch, delim;
|
|
|
|
int i, state;
|
|
|
|
u_short port;
|
|
|
|
|
|
|
|
/* Format: "229 Entering Extended Passive Mode (|||PORT|)" */
|
|
|
|
|
|
|
|
/* Return if data length is too short. */
|
|
|
|
if (dlen < 11)
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
port = 0;
|
|
|
|
delim = '|'; /* XXX gcc -Wuninitialized */
|
|
|
|
|
|
|
|
state = -3;
|
|
|
|
for (i = 0; i < dlen; i++) {
|
|
|
|
ch = sptr[i];
|
|
|
|
switch (state) {
|
|
|
|
case -3:
|
|
|
|
if (ch == '2')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
if (ch == '2')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
if (ch == '9')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
if (ch == '(')
|
|
|
|
state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
delim = ch;
|
|
|
|
state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
if (ch == delim)
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (isdigit(ch)) {
|
|
|
|
port = ch - '0';
|
|
|
|
state++;
|
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (isdigit(ch))
|
|
|
|
port = 10 * port + ch - '0';
|
|
|
|
else if (ch == delim)
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (ch == ')')
|
|
|
|
state++;
|
|
|
|
else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-06-16 20:36:16 +00:00
|
|
|
}
|
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
if (state == 7) {
|
|
|
|
la->true_port = port;
|
2004-07-05 10:55:23 +00:00
|
|
|
return (1);
|
2004-03-16 21:30:41 +00:00
|
|
|
} else
|
2004-07-05 10:55:23 +00:00
|
|
|
return (0);
|
1997-05-23 04:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-01-17 10:52:21 +00:00
|
|
|
NewFtpMessage(struct libalias *la, struct ip *pip,
|
2004-07-05 11:10:57 +00:00
|
|
|
struct alias_link *lnk,
|
2004-03-16 21:30:41 +00:00
|
|
|
int maxpacketsize,
|
|
|
|
int ftp_message_type)
|
2000-06-16 20:36:16 +00:00
|
|
|
{
|
2004-07-05 11:10:57 +00:00
|
|
|
struct alias_link *ftp_lnk;
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
/* Security checks. */
|
2004-03-16 21:30:41 +00:00
|
|
|
if (pip->ip_src.s_addr != la->true_addr.s_addr)
|
|
|
|
return;
|
2000-06-16 20:36:16 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
if (la->true_port < IPPORT_RESERVED)
|
|
|
|
return;
|
2000-06-16 20:36:16 +00:00
|
|
|
|
|
|
|
/* Establish link to address and port found in FTP control message. */
|
2004-07-05 11:10:57 +00:00
|
|
|
ftp_lnk = FindUdpTcpOut(la, la->true_addr, GetDestAddress(lnk),
|
2004-03-16 21:30:41 +00:00
|
|
|
htons(la->true_port), 0, IPPROTO_TCP, 1);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2004-07-05 11:10:57 +00:00
|
|
|
if (ftp_lnk != NULL) {
|
2004-03-16 21:30:41 +00:00
|
|
|
int slen, hlen, tlen, dlen;
|
|
|
|
struct tcphdr *tc;
|
1997-05-23 04:41:31 +00:00
|
|
|
|
1998-06-06 21:52:37 +00:00
|
|
|
#ifndef NO_FW_PUNCH
|
2004-03-16 21:30:41 +00:00
|
|
|
/* Punch hole in firewall */
|
2004-07-05 11:10:57 +00:00
|
|
|
PunchFWHole(ftp_lnk);
|
1998-06-06 21:52:37 +00:00
|
|
|
#endif
|
1998-01-09 21:13:35 +00:00
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
/* Calculate data length of TCP packet */
|
2004-07-06 12:13:28 +00:00
|
|
|
tc = (struct tcphdr *)ip_next(pip);
|
2004-03-16 21:30:41 +00:00
|
|
|
hlen = (pip->ip_hl + tc->th_off) << 2;
|
|
|
|
tlen = ntohs(pip->ip_len);
|
|
|
|
dlen = tlen - hlen;
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
/* Create new FTP message. */
|
2004-03-16 21:30:41 +00:00
|
|
|
{
|
|
|
|
char stemp[MAX_MESSAGE_SIZE + 1];
|
|
|
|
char *sptr;
|
|
|
|
u_short alias_port;
|
|
|
|
u_char *ptr;
|
|
|
|
int a1, a2, a3, a4, p1, p2;
|
|
|
|
struct in_addr alias_address;
|
2000-06-16 20:36:16 +00:00
|
|
|
|
1997-05-23 04:41:31 +00:00
|
|
|
/* Decompose alias address into quad format */
|
2004-07-05 11:10:57 +00:00
|
|
|
alias_address = GetAliasAddress(lnk);
|
2004-03-16 21:30:41 +00:00
|
|
|
ptr = (u_char *) & alias_address.s_addr;
|
|
|
|
a1 = *ptr++;
|
|
|
|
a2 = *ptr++;
|
|
|
|
a3 = *ptr++;
|
|
|
|
a4 = *ptr;
|
|
|
|
|
2004-07-05 11:10:57 +00:00
|
|
|
alias_port = GetAliasPort(ftp_lnk);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
switch (ftp_message_type) {
|
|
|
|
case FTP_PORT_COMMAND:
|
|
|
|
case FTP_227_REPLY:
|
|
|
|
/* Decompose alias port into pair format. */
|
|
|
|
ptr = (char *)&alias_port;
|
|
|
|
p1 = *ptr++;
|
|
|
|
p2 = *ptr;
|
|
|
|
|
|
|
|
if (ftp_message_type == FTP_PORT_COMMAND) {
|
|
|
|
/* Generate PORT command string. */
|
|
|
|
sprintf(stemp, "PORT %d,%d,%d,%d,%d,%d\r\n",
|
|
|
|
a1, a2, a3, a4, p1, p2);
|
|
|
|
} else {
|
|
|
|
/* Generate 227 reply string. */
|
|
|
|
sprintf(stemp,
|
|
|
|
"227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n",
|
|
|
|
a1, a2, a3, a4, p1, p2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FTP_EPRT_COMMAND:
|
|
|
|
/* Generate EPRT command string. */
|
|
|
|
sprintf(stemp, "EPRT |1|%d.%d.%d.%d|%d|\r\n",
|
|
|
|
a1, a2, a3, a4, ntohs(alias_port));
|
|
|
|
break;
|
|
|
|
case FTP_229_REPLY:
|
|
|
|
/* Generate 229 reply string. */
|
|
|
|
sprintf(stemp, "229 Entering Extended Passive Mode (|||%d|)\r\n",
|
|
|
|
ntohs(alias_port));
|
|
|
|
break;
|
|
|
|
}
|
1997-05-23 04:41:31 +00:00
|
|
|
|
|
|
|
/* Save string length for IP header modification */
|
2004-03-16 21:30:41 +00:00
|
|
|
slen = strlen(stemp);
|
1997-05-23 04:41:31 +00:00
|
|
|
|
2000-06-16 20:36:16 +00:00
|
|
|
/* Copy modified buffer into IP packet. */
|
2004-03-16 21:30:41 +00:00
|
|
|
sptr = (char *)pip;
|
|
|
|
sptr += hlen;
|
|
|
|
strncpy(sptr, stemp, maxpacketsize - hlen);
|
|
|
|
}
|
2000-06-14 16:09:35 +00:00
|
|
|
|
|
|
|
/* Save information regarding modified seq and ack numbers */
|
2004-03-16 21:30:41 +00:00
|
|
|
{
|
|
|
|
int delta;
|
2000-06-14 16:09:35 +00:00
|
|
|
|
2004-07-05 11:10:57 +00:00
|
|
|
SetAckModified(lnk);
|
|
|
|
delta = GetDeltaSeqOut(pip, lnk);
|
|
|
|
AddSeq(pip, lnk, delta + slen - dlen);
|
2004-03-16 21:30:41 +00:00
|
|
|
}
|
2000-06-14 16:09:35 +00:00
|
|
|
|
|
|
|
/* Revise IP header */
|
2004-03-16 21:30:41 +00:00
|
|
|
{
|
|
|
|
u_short new_len;
|
|
|
|
|
|
|
|
new_len = htons(hlen + slen);
|
|
|
|
DifferentialChecksum(&pip->ip_sum,
|
|
|
|
&new_len,
|
|
|
|
&pip->ip_len,
|
|
|
|
1);
|
|
|
|
pip->ip_len = new_len;
|
|
|
|
}
|
2000-06-14 16:09:35 +00:00
|
|
|
|
|
|
|
/* Compute TCP checksum for revised packet */
|
2004-03-16 21:30:41 +00:00
|
|
|
tc->th_sum = 0;
|
2005-06-27 07:36:02 +00:00
|
|
|
#ifdef _KERNEL
|
|
|
|
tc->th_x2 = 1;
|
|
|
|
#else
|
2004-03-16 21:30:41 +00:00
|
|
|
tc->th_sum = TcpChecksum(pip);
|
2005-06-27 07:36:02 +00:00
|
|
|
#endif
|
2004-03-16 21:30:41 +00:00
|
|
|
} else {
|
2005-05-06 11:07:49 +00:00
|
|
|
#ifdef LIBALIAS_DEBUG
|
2004-03-16 21:30:41 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"PacketAlias/HandleFtpOut: Cannot allocate FTP data port\n");
|
1999-03-09 23:44:00 +00:00
|
|
|
#endif
|
2004-03-16 21:30:41 +00:00
|
|
|
}
|
1997-05-23 04:41:31 +00:00
|
|
|
}
|