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

📄 suppressor.cc

📁 Click is a modular router toolkit. To use it you ll need to know how to compile and install the sof
💻 CC
字号:
/* * suppressor.{cc,hh} -- element for Ethernet switch * John Jannotti * * 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 "suppressor.hh"#include <click/bitvector.hh>#include <click/confparse.hh>#include <click/error.hh>CLICK_DECLSSuppressor::Suppressor(){}Suppressor::~Suppressor(){}intSuppressor::configure(Vector<String> &, ErrorHandler *){    _suppressed.assign(noutputs(), false);    return 0;}voidSuppressor::push(int source, Packet *p){    if (suppressed(source))	p->kill();    else			// forward	output(source).push(p);}Packet *Suppressor::pull(int source){    if (suppressed(source))	return 0;    else	return input(source).pull();}static Stringread_active(Element *e, void *thunk){    Suppressor *sup = static_cast<Suppressor *>(e);    int port = (int) reinterpret_cast<intptr_t>(thunk);    return (sup->suppressed(port) ? "false" : "true");}static intwrite_active(const String &s, Element *e, void *thunk, ErrorHandler *errh){    Suppressor *sup = static_cast<Suppressor *>(e);    int port = (int) reinterpret_cast<intptr_t>(thunk);    bool active;    if (!cp_bool(s, &active))	return errh->error("active value must be boolean");    else {	sup->set(port, !active);	return 0;    }}static intwrite_reset(const String &, Element *e, void *, ErrorHandler *){    Suppressor *sup = static_cast<Suppressor *>(e);    sup->allow_all();    return 0;}voidSuppressor::add_handlers(){    for (int i = 0; i < ninputs(); i++) {	String s = "active" + String(i);	add_read_handler(s, read_active, i, Handler::CHECKBOX);	add_write_handler(s, write_active, i);    }    add_write_handler("reset", write_reset, 0, Handler::BUTTON);}CLICK_ENDDECLSEXPORT_ELEMENT(Suppressor)

⌨️ 快捷键说明

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