⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tee.cc

📁 Click is a modular router toolkit. To use it you ll need to know how to compile and install the sof
💻 CC
字号:
/* * tee.{cc,hh} -- element duplicates packets * Eddie Kohler * * Copyright (c) 1999-2000 Massachusetts Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, subject to the conditions * listed in the Click LICENSE file. These conditions include: you must * preserve this copyright notice, and you cannot mention the copyright * holders in advertising related to the Software without their permission. * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This * notice is a summary of the Click LICENSE file; the license in that file is * legally binding. */#include <click/config.h>#include "tee.hh"#include <click/confparse.hh>#include <click/error.hh>CLICK_DECLSTee::Tee(){}Tee::~Tee(){}intTee::configure(Vector<String> &conf, ErrorHandler *errh){  int n = noutputs();  if (cp_va_kparse(conf, this, errh,		   "N", cpkP, cpUnsigned, &n,		   cpEnd) < 0)    return -1;  if (n != noutputs())      return errh->error("%d outputs implies %d arms", noutputs(), noutputs());  return 0;}voidTee::push(int, Packet *p){  int n = noutputs();  for (int i = 0; i < n - 1; i++)    if (Packet *q = p->clone())      output(i).push(q);  output(n - 1).push(p);}//// PULLTEE//PullTee::PullTee(){}PullTee::~PullTee(){}intPullTee::configure(Vector<String> &conf, ErrorHandler *errh){  int n = noutputs();  if (cp_va_kparse(conf, this, errh,		   "N", cpkP, cpUnsigned, &n,		   cpEnd) < 0)    return -1;  if (n != noutputs())      return errh->error("%d outputs implies %d arms", noutputs(), noutputs());  return 0;}Packet *PullTee::pull(int){  Packet *p = input(0).pull();  if (p) {    int n = noutputs();    for (int i = 1; i < n; i++)      if (Packet *q = p->clone())	output(i).push(q);  }  return p;}CLICK_ENDDECLSEXPORT_ELEMENT(Tee PullTee)ELEMENT_MT_SAFE(Tee)ELEMENT_MT_SAFE(PullTee)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -