summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiso <piso@FreeBSD.org>2006-12-01 16:27:11 +0000
committerpiso <piso@FreeBSD.org>2006-12-01 16:27:11 +0000
commite2023fe5e931c743cc5f6c589caa512597dd233b (patch)
tree53369476c21225a3348df4261d25351b719174f9
parent029c1b6cc668f225977b230b2f6fcafe386cb259 (diff)
downloadFreeBSD-src-e2023fe5e931c743cc5f6c589caa512597dd233b.zip
FreeBSD-src-e2023fe5e931c743cc5f6c589caa512597dd233b.tar.gz
Remove m_megapullup from ng_nat and put it under libalias.
Approved by: gleb
-rw-r--r--sys/netgraph/ng_nat.c35
-rw-r--r--sys/netinet/libalias/alias.c38
-rw-r--r--sys/netinet/libalias/alias.h3
3 files changed, 41 insertions, 35 deletions
diff --git a/sys/netgraph/ng_nat.c b/sys/netgraph/ng_nat.c
index 84d3598..f5abdfb 100644
--- a/sys/netgraph/ng_nat.c
+++ b/sys/netgraph/ng_nat.c
@@ -56,8 +56,6 @@ static ng_newhook_t ng_nat_newhook;
static ng_rcvdata_t ng_nat_rcvdata;
static ng_disconnect_t ng_nat_disconnect;
-static struct mbuf * m_megapullup(struct mbuf *, int);
-
/* List of commands and how to convert arguments to/from ASCII. */
static const struct ng_cmdlist ng_nat_cmdlist[] = {
{
@@ -327,36 +325,3 @@ ng_nat_disconnect(hook_p hook)
return (0);
}
-/*
- * m_megapullup() function is a big hack.
- *
- * It allocates an mbuf with cluster and copies the whole
- * chain into cluster, so that it is all contigous and the
- * whole packet can be accessed via char pointer.
- *
- * This is required, because libalias doesn't have idea
- * about mbufs.
- */
-static struct mbuf *
-m_megapullup(struct mbuf *m, int len)
-{
- struct mbuf *mcl;
- caddr_t cp;
-
- if (len > MCLBYTES)
- goto bad;
-
- if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL)
- goto bad;
-
- cp = mtod(mcl, caddr_t);
- m_copydata(m, 0, len, cp);
- m_move_pkthdr(mcl, m);
- mcl->m_len = mcl->m_pkthdr.len;
- m_freem(m);
-
- return (mcl);
-bad:
- m_freem(m);
- return (NULL);
-}
diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c
index 0120c19..6747232 100644
--- a/sys/netinet/libalias/alias.c
+++ b/sys/netinet/libalias/alias.c
@@ -1574,3 +1574,41 @@ LibAliasUnLoadAllModule(void)
}
#endif
+
+#ifdef _KERNEL
+/*
+ * m_megapullup() function is a big hack (only used in ng_nat and ipfw+nat).
+ *
+ * It allocates an mbuf with cluster and copies the whole
+ * chain into cluster, so that it is all contigous and the
+ * whole packet can be accessed via char pointer.
+ * This is required, because libalias doesn't have idea
+ * about mbufs.
+ *
+ * On success, m_megapullup returns an mbuf with cluster
+ * containing the input packet, on failure NULL.
+ * In both cases, the input packet is consumed.
+ */
+struct mbuf *
+m_megapullup(struct mbuf *m, int len) {
+ struct mbuf *mcl;
+ caddr_t cp;
+
+ if (len > MCLBYTES)
+ goto bad;
+
+ if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL)
+ goto bad;
+
+ cp = mtod(mcl, caddr_t);
+ m_copydata(m, 0, len, cp);
+ m_move_pkthdr(mcl, m);
+ mcl->m_len = mcl->m_pkthdr.len;
+ m_freem(m);
+
+ return (mcl);
+bad:
+ m_freem(m);
+ return (NULL);
+}
+#endif
diff --git a/sys/netinet/libalias/alias.h b/sys/netinet/libalias/alias.h
index 4a809f4..358109c 100644
--- a/sys/netinet/libalias/alias.h
+++ b/sys/netinet/libalias/alias.h
@@ -189,6 +189,9 @@ int LibAliasLoadModule(char *);
int LibAliasUnLoadAllModule(void);
int LibAliasRefreshModules(void);
+/* Mbuf helper function. */
+struct mbuf *m_megapullup(struct mbuf *, int);
+
/*
* Mode flags and other constants.
*/
OpenPOWER on IntegriCloud