summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2001-07-13 02:03:38 +0000
committerbrian <brian@cvs.openbsd.org>2001-07-13 02:03:38 +0000
commitef4896e73139a0b31cd932f36e898c00779e7585 (patch)
tree3d844fa9abc18c58582858f997b55b9f58f1a644 /usr.sbin
parent73d29fae178f1f3efb4a95c92538cc2e6a95298b (diff)
Perform MSS fixups on incoming packets as well as outgoing.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/ppp/tcpmss.c75
1 files changed, 43 insertions, 32 deletions
diff --git a/usr.sbin/ppp/ppp/tcpmss.c b/usr.sbin/ppp/ppp/tcpmss.c
index f8debc8805e..50606ebee69 100644
--- a/usr.sbin/ppp/ppp/tcpmss.c
+++ b/usr.sbin/ppp/ppp/tcpmss.c
@@ -70,37 +70,6 @@
#define MAXMSS(mtu) (mtu - sizeof(struct ip) - sizeof(struct tcphdr))
-static void MSSFixup(struct tcphdr *, ssize_t, u_int16_t);
-
-
-static struct mbuf *
-tcpmss_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
- int pri, u_short *proto)
-{
- struct ip *pip;
- int hlen, plen;
-
- if (!Enabled(bundle, OPT_TCPMSSFIXUP))
- return bp;
-
- bp = m_pullup(bp);
- plen = m_length(bp);
- pip = (struct ip *)MBUF_CTOP(bp);
- hlen = pip->ip_hl << 2;
-
- /*
- * Check for MSS option only for TCP packets with zero fragment offsets
- * and correct total and header lengths.
- */
- if (pip->ip_p == IPPROTO_TCP && (ntohs(pip->ip_off) & IP_OFFMASK) == 0 &&
- ntohs(pip->ip_len) == plen && hlen <= plen &&
- plen - hlen >= sizeof(struct tcphdr))
- MSSFixup((struct tcphdr *)(MBUF_CTOP(bp) + hlen), plen - hlen,
- MAXMSS(bundle->iface->mtu));
-
- return bp;
-}
-
/*-
* The following macro is used to update an
* internet checksum. "acc" is a 32-bit
@@ -168,4 +137,46 @@ MSSFixup(struct tcphdr *tc, ssize_t pktlen, u_int16_t maxmss)
}
}
-struct layer tcpmsslayer = { LAYER_PROTO, "tcpmss", tcpmss_LayerPush, NULL };
+static struct mbuf *
+tcpmss_Check(struct bundle *bundle, struct mbuf *bp)
+{
+ struct ip *pip;
+ int hlen, plen;
+
+ if (!Enabled(bundle, OPT_TCPMSSFIXUP))
+ return bp;
+
+ bp = m_pullup(bp);
+ plen = m_length(bp);
+ pip = (struct ip *)MBUF_CTOP(bp);
+ hlen = pip->ip_hl << 2;
+
+ /*
+ * Check for MSS option only for TCP packets with zero fragment offsets
+ * and correct total and header lengths.
+ */
+ if (pip->ip_p == IPPROTO_TCP && (ntohs(pip->ip_off) & IP_OFFMASK) == 0 &&
+ ntohs(pip->ip_len) == plen && hlen <= plen &&
+ plen - hlen >= sizeof(struct tcphdr))
+ MSSFixup((struct tcphdr *)(MBUF_CTOP(bp) + hlen), plen - hlen,
+ MAXMSS(bundle->iface->mtu));
+
+ return bp;
+}
+
+static struct mbuf *
+tcpmss_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
+ int pri, u_short *proto)
+{
+ return tcpmss_Check(bundle, bp);
+}
+
+static struct mbuf *
+tcpmss_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp,
+ u_short *proto)
+{
+ return tcpmss_Check(bundle, bp);
+}
+
+struct layer tcpmsslayer =
+ { LAYER_PROTO, "tcpmss", tcpmss_LayerPush, tcpmss_LayerPull };