diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2010-09-21 10:45:27 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2010-09-21 10:45:27 +0000 |
commit | 00910b275b246fd21427b36597fed493f24012e8 (patch) | |
tree | 85b9d8a0d32ec4a81327d8153e6c311a5286e8b8 /sys/net | |
parent | 101487b6bab01e760bf0c45b91a26c323a0823db (diff) |
stuff the original (before rewriting) addresses into the already existant
address fields in the pflog header, same for ports, and add a "rewritten"
indicator. ok ryan dlg
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_pflog.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sys/net/if_pflog.c b/sys/net/if_pflog.c index ef5f1455f92..1e74d8c7482 100644 --- a/sys/net/if_pflog.c +++ b/sys/net/if_pflog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflog.c,v 1.29 2010/09/21 04:06:37 henning Exp $ */ +/* $OpenBSD: if_pflog.c,v 1.30 2010/09/21 10:45:26 henning Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -286,6 +286,8 @@ pflog_bpfcopy(const void *src_arg, void *dst_arg, size_t len) } pf_hdrs; struct pf_pdesc pd; + struct pf_addr osaddr, odaddr; + u_int16_t osport, odport; m = src_arg; dst = dst_arg; @@ -297,6 +299,7 @@ pflog_bpfcopy(const void *src_arg, void *dst_arg, size_t len) pfloghdr = mtod(m, struct pfloghdr *); count = min(m->m_len, len); bcopy(pfloghdr, dst, count); + pfloghdr = (struct pfloghdr *)dst; dst += count; len -= count; m = m->m_next; @@ -333,8 +336,20 @@ pflog_bpfcopy(const void *src_arg, void *dst_arg, size_t len) if (pf_setup_pdesc(pfloghdr->af, pfloghdr->dir, &pd, mfake, &action, &reason, NULL, NULL, NULL, NULL, &off, &hdrlen) == -1) return; - if (pf_translate(&pd, &pfloghdr->saddr, pfloghdr->sport, - &pfloghdr->daddr, pfloghdr->dport, 0, pfloghdr->dir, mfake)) + + PF_ACPY(&osaddr, pd.src, pd.af); + PF_ACPY(&odaddr, pd.dst, pd.af); + osport = *pd.sport; + odport = *pd.dport; + + if ((pfloghdr->rewritten = pf_translate(&pd, &pfloghdr->saddr, + pfloghdr->sport, &pfloghdr->daddr, pfloghdr->dport, 0, + pfloghdr->dir, mfake))) { m_copyback(mfake, off, min(mfake->m_len - off, hdrlen), pd.hdr.any, M_NOWAIT); + PF_ACPY(&pfloghdr->saddr, &osaddr, pd.af); + PF_ACPY(&pfloghdr->daddr, &odaddr, pd.af); + pfloghdr->sport = osport; + pfloghdr->dport = odport; + } } |