diff options
author | ru <ru@FreeBSD.org> | 2001-05-30 14:24:35 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2001-05-30 14:24:35 +0000 |
commit | f478ecd8d334e9395eb4e931a970ee3c805583b5 (patch) | |
tree | b10e10e5922844612c14ddcebbd16608df4a0ba9 /sys/netinet/libalias/alias_ftp.c | |
parent | 8c9c53e10bddc36c22314723b2270de95572f1d4 (diff) | |
download | FreeBSD-src-f478ecd8d334e9395eb4e931a970ee3c805583b5.zip FreeBSD-src-f478ecd8d334e9395eb4e931a970ee3c805583b5.tar.gz |
Add an integer field to keep protocol-specific flags with links.
For FTP control connection, keep the CRLF end-of-line termination
status in there.
Fixed the bug when the first FTP command in a session was ignored.
PR: 24048
MFC after: 1 week
Diffstat (limited to 'sys/netinet/libalias/alias_ftp.c')
-rw-r--r-- | sys/netinet/libalias/alias_ftp.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/netinet/libalias/alias_ftp.c b/sys/netinet/libalias/alias_ftp.c index d5978f9..e2152ee 100644 --- a/sys/netinet/libalias/alias_ftp.c +++ b/sys/netinet/libalias/alias_ftp.c @@ -59,6 +59,9 @@ #define FTP_CONTROL_PORT_NUMBER 21 #define MAX_MESSAGE_SIZE 128 +/* FTP protocol flags. */ +#define WAIT_CRLF 0x01 + enum ftp_message_type { FTP_PORT_COMMAND, FTP_EPRT_COMMAND, @@ -82,7 +85,7 @@ struct ip *pip, /* IP packet to examine/patch */ struct alias_link *link, /* The link to go through (aliased port) */ int maxpacketsize /* The maximum size this packet can grow to (including headers) */) { - int hlen, tlen, dlen; + int hlen, tlen, dlen, pflags; char *sptr; struct tcphdr *tc; int ftp_message_type; @@ -101,7 +104,8 @@ int maxpacketsize /* The maximum size this packet can grow to (including header * Check that data length is not too long and previous message was * properly terminated with CRLF. */ - if (dlen <= MAX_MESSAGE_SIZE && GetLastLineCrlfTermed(link)) { + pflags = GetProtocolFlags(link); + if (dlen <= MAX_MESSAGE_SIZE && (pflags & WAIT_CRLF)) { ftp_message_type = FTP_UNKNOWN_MESSAGE; if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER) { @@ -131,8 +135,11 @@ int maxpacketsize /* The maximum size this packet can grow to (including header 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 */ - SetLastLineCrlfTermed(link, - (sptr[tlen-2] == '\r') && (sptr[tlen-1] == '\n')); + if (sptr[tlen-2] == '\r' && sptr[tlen-1] == '\n') + pflags &= ~WAIT_CRLF; + else + pflags |= WAIT_CRLF; + SetProtocolFlags(link, pflags); } } |