ng_tee.c (58acf05adef4fbe7be5bb9c0072a94d0f7a52487) ng_tee.c (3ca24c284d7116d2764cd8bca4fa357a0bea07db)
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

--- 277 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;
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

--- 277 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 ---