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 /lib/libalias | |
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 'lib/libalias')
-rw-r--r-- | lib/libalias/alias_db.c | 16 | ||||
-rw-r--r-- | lib/libalias/alias_ftp.c | 15 | ||||
-rw-r--r-- | lib/libalias/alias_local.h | 4 |
3 files changed, 20 insertions, 15 deletions
diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c index 60d425f..7234cdd 100644 --- a/lib/libalias/alias_db.c +++ b/lib/libalias/alias_db.c @@ -279,6 +279,7 @@ struct alias_link /* Main data structure */ #define LINK_PPTP (IPPROTO_MAX + 4) int flags; /* indicates special characteristics */ + int pflags; /* protocol-specific flags */ /* flag bits */ #define LINK_UNKNOWN_DEST_PORT 0x01 @@ -286,7 +287,6 @@ struct alias_link /* Main data structure */ #define LINK_PERMANENT 0x04 #define LINK_PARTIALLY_SPECIFIED 0x03 /* logical-or of first two bits */ #define LINK_UNFIREWALLED 0x08 -#define LINK_LAST_LINE_CRLF_TERMED 0x10 int timestamp; /* Time link was last accessed */ int expire_time; /* Expire time for link */ @@ -991,6 +991,7 @@ AddLink(struct in_addr src_addr, link->link_type = link_type; link->sockfd = -1; link->flags = 0; + link->pflags = 0; link->timestamp = timeStamp; /* Expiration time */ @@ -1829,7 +1830,7 @@ FindAliasAddress(struct in_addr original_addr) GetOriginalPort(), GetAliasPort() SetAckModified(), GetAckModified() GetDeltaAckIn(), GetDeltaSeqOut(), AddSeq() - SetLastLineCrlfTermed(), GetLastLineCrlfTermed() + SetProtocolFlags(), GetProtocolFlags() SetDestCallId() */ @@ -2197,20 +2198,17 @@ ClearCheckNewLink(void) } void -SetLastLineCrlfTermed(struct alias_link *link, int yes) +SetProtocolFlags(struct alias_link *link, int pflags) { - if (yes) - link->flags |= LINK_LAST_LINE_CRLF_TERMED; - else - link->flags &= ~LINK_LAST_LINE_CRLF_TERMED; + link->pflags = pflags;; } int -GetLastLineCrlfTermed(struct alias_link *link) +GetProtocolFlags(struct alias_link *link) { - return (link->flags & LINK_LAST_LINE_CRLF_TERMED); + return (link->pflags); } void diff --git a/lib/libalias/alias_ftp.c b/lib/libalias/alias_ftp.c index d5978f9..e2152ee 100644 --- a/lib/libalias/alias_ftp.c +++ b/lib/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); } } diff --git a/lib/libalias/alias_local.h b/lib/libalias/alias_local.h index 152406d..eca4841 100644 --- a/lib/libalias/alias_local.h +++ b/lib/libalias/alias_local.h @@ -144,8 +144,8 @@ int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_link); void AddSeq(struct ip *_pip, struct alias_link *_link, int _delta); void SetExpire(struct alias_link *_link, int _expire); void ClearCheckNewLink(void); -void SetLastLineCrlfTermed(struct alias_link *_link, int _yes); -int GetLastLineCrlfTermed(struct alias_link *_link); +void SetProtocolFlags(struct alias_link *_link, int _pflags); +int GetProtocolFlags(struct alias_link *_link); void SetDestCallId(struct alias_link *_link, u_int16_t _cid); #ifndef NO_FW_PUNCH void PunchFWHole(struct alias_link *_link); |