Deleted Added
full compact
ng_nat.c (163297) ng_nat.c (164797)
1/*-
2 * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/netgraph/ng_nat.c 163297 2006-10-13 09:11:12Z glebius $
26 * $FreeBSD: head/sys/netgraph/ng_nat.c 164797 2006-12-01 16:27:11Z piso $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/kernel.h>
32#include <sys/mbuf.h>
33#include <sys/malloc.h>
34#include <sys/ctype.h>

--- 16 unchanged lines hidden (view full) ---

51
52static ng_constructor_t ng_nat_constructor;
53static ng_rcvmsg_t ng_nat_rcvmsg;
54static ng_shutdown_t ng_nat_shutdown;
55static ng_newhook_t ng_nat_newhook;
56static ng_rcvdata_t ng_nat_rcvdata;
57static ng_disconnect_t ng_nat_disconnect;
58
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/kernel.h>
32#include <sys/mbuf.h>
33#include <sys/malloc.h>
34#include <sys/ctype.h>

--- 16 unchanged lines hidden (view full) ---

51
52static ng_constructor_t ng_nat_constructor;
53static ng_rcvmsg_t ng_nat_rcvmsg;
54static ng_shutdown_t ng_nat_shutdown;
55static ng_newhook_t ng_nat_newhook;
56static ng_rcvdata_t ng_nat_rcvdata;
57static ng_disconnect_t ng_nat_disconnect;
58
59static struct mbuf * m_megapullup(struct mbuf *, int);
60
61/* List of commands and how to convert arguments to/from ASCII. */
62static const struct ng_cmdlist ng_nat_cmdlist[] = {
63 {
64 NGM_NAT_COOKIE,
65 NGM_NAT_SET_IPADDR,
66 "setaliasaddr",
67 &ng_parse_ipaddr_type,
68 NULL

--- 253 unchanged lines hidden (view full) ---

322 priv->in = NULL;
323
324 if (priv->out == NULL && priv->in == NULL)
325 ng_rmnode_self(NG_HOOK_NODE(hook));
326
327 return (0);
328}
329
59/* List of commands and how to convert arguments to/from ASCII. */
60static const struct ng_cmdlist ng_nat_cmdlist[] = {
61 {
62 NGM_NAT_COOKIE,
63 NGM_NAT_SET_IPADDR,
64 "setaliasaddr",
65 &ng_parse_ipaddr_type,
66 NULL

--- 253 unchanged lines hidden (view full) ---

320 priv->in = NULL;
321
322 if (priv->out == NULL && priv->in == NULL)
323 ng_rmnode_self(NG_HOOK_NODE(hook));
324
325 return (0);
326}
327
330/*
331 * m_megapullup() function is a big hack.
332 *
333 * It allocates an mbuf with cluster and copies the whole
334 * chain into cluster, so that it is all contigous and the
335 * whole packet can be accessed via char pointer.
336 *
337 * This is required, because libalias doesn't have idea
338 * about mbufs.
339 */
340static struct mbuf *
341m_megapullup(struct mbuf *m, int len)
342{
343 struct mbuf *mcl;
344 caddr_t cp;
345
346 if (len > MCLBYTES)
347 goto bad;
348
349 if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL)
350 goto bad;
351
352 cp = mtod(mcl, caddr_t);
353 m_copydata(m, 0, len, cp);
354 m_move_pkthdr(mcl, m);
355 mcl->m_len = mcl->m_pkthdr.len;
356 m_freem(m);
357
358 return (mcl);
359bad:
360 m_freem(m);
361 return (NULL);
362}