Deleted Added
full compact
ng_tee.c (129942) ng_tee.c (131155)
1
2/*
3 * ng_tee.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

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

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Julian Elischer <julian@freebsd.org>
38 *
1
2/*
3 * ng_tee.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

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

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Julian Elischer <julian@freebsd.org>
38 *
39 * $FreeBSD: head/sys/netgraph/ng_tee.c 129942 2004-06-01 13:15:32Z ru $
39 * $FreeBSD: head/sys/netgraph/ng_tee.c 131155 2004-06-26 22:24:16Z julian $
40 * $Whistle: ng_tee.c,v 1.18 1999/11/01 09:24:52 julian Exp $
41 */
42
43/*
44 * This node is like the tee(1) command and is useful for ``snooping.''
45 * It has 4 hooks: left, right, left2right, and right2left. Data
46 * entering from the right is passed to the left and duplicated on
47 * right2left, and data entering from the left is passed to the right

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

286ngt_rcvdata(hook_p hook, item_p item)
287{
288 const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
289 struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook);
290 struct hookinfo *dest;
291 struct hookinfo *dup;
292 int error = 0;
293 struct mbuf *m;
40 * $Whistle: ng_tee.c,v 1.18 1999/11/01 09:24:52 julian Exp $
41 */
42
43/*
44 * This node is like the tee(1) command and is useful for ``snooping.''
45 * It has 4 hooks: left, right, left2right, and right2left. Data
46 * entering from the right is passed to the left and duplicated on
47 * right2left, and data entering from the left is passed to the right

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

286ngt_rcvdata(hook_p hook, item_p item)
287{
288 const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
289 struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook);
290 struct hookinfo *dest;
291 struct hookinfo *dup;
292 int error = 0;
293 struct mbuf *m;
294 meta_p meta;
295
296 m = NGI_M(item);
294
295 m = NGI_M(item);
297 meta = NGI_META(item); /* leave these owned by the item */
298 /* Which hook? */
299 if (hinfo == &sc->left) {
300 dup = &sc->left2right;
301 dest = &sc->right;
302 } else if (hinfo == &sc->right) {
303 dup = &sc->right2left;
304 dest = &sc->left;
305 } else if (hinfo == &sc->right2left) {

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

322 /*
323 * Don't make a copy if only the dup hook exists.
324 */
325 if ((dup && dup->hook) && (dest->hook == NULL)) {
326 dest = dup;
327 dup = NULL;
328 }
329
296 /* Which hook? */
297 if (hinfo == &sc->left) {
298 dup = &sc->left2right;
299 dest = &sc->right;
300 } else if (hinfo == &sc->right) {
301 dup = &sc->right2left;
302 dest = &sc->left;
303 } else if (hinfo == &sc->right2left) {

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

320 /*
321 * Don't make a copy if only the dup hook exists.
322 */
323 if ((dup && dup->hook) && (dest->hook == NULL)) {
324 dest = dup;
325 dup = NULL;
326 }
327
330 /* Duplicate packet and meta info if requried */
328 /* Duplicate packet if requried */
331 if (dup && dup->hook) {
332 struct mbuf *m2;
329 if (dup && dup->hook) {
330 struct mbuf *m2;
333 meta_p meta2;
334
335 /* Copy packet (failure will not stop the original)*/
336 m2 = m_dup(m, M_DONTWAIT);
337 if (m2) {
331
332 /* Copy packet (failure will not stop the original)*/
333 m2 = m_dup(m, M_DONTWAIT);
334 if (m2) {
338
339 /* Copy meta info */
340 /* If we can't get a copy, tough.. */
341 if (meta != NULL) {
342 meta2 = ng_copy_meta(meta);
343 } else
344 meta2 = NULL;
345
346 /* Deliver duplicate */
347 dup->stats.outOctets += m->m_pkthdr.len;
348 dup->stats.outFrames++;
335 /* Deliver duplicate */
336 dup->stats.outOctets += m->m_pkthdr.len;
337 dup->stats.outFrames++;
349 NG_SEND_DATA(error, dup->hook, m2, meta2);
338 NG_SEND_DATA_ONLY(error, dup->hook, m2);
350 }
351 }
352 /* Deliver frame out destination hook */
353 if (dest->hook) {
354 dest->stats.outOctets += m->m_pkthdr.len;
355 dest->stats.outFrames++;
356 NG_FWD_ITEM_HOOK(error, item, dest->hook);
357 } else

--- 52 unchanged lines hidden ---
339 }
340 }
341 /* Deliver frame out destination hook */
342 if (dest->hook) {
343 dest->stats.outOctets += m->m_pkthdr.len;
344 dest->stats.outFrames++;
345 NG_FWD_ITEM_HOOK(error, item, dest->hook);
346 } else

--- 52 unchanged lines hidden ---