📄 locationhistogram.cc
字号:
/* * LocationHistogram.{cc,hh} -- sets wifi txrate annotation on a packet * John Bicket * * Copyright (c) 2003 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 <click/confparse.hh>#include <click/error.hh>#include <click/glue.hh>#include <click/packet_anno.hh>#include <click/straccum.hh>#include <clicknet/ether.h>#include "locationhistogram.hh"CLICK_DECLSLocationHistogram::LocationHistogram() : Element(1,1){}LocationHistogram::~LocationHistogram(){}intLocationHistogram::configure(Vector<String> &conf, ErrorHandler *errh){ _length = 0; if (cp_va_parse(conf, this, errh, cpKeywords, "LENGTH", cpUnsigned, "", &_length, cpEnd) < 0) { return -1; } while ((unsigned) _byte_errors.size() < _length) { _byte_errors.push_back(0); } return 0;}voidLocationHistogram::push (int port, Packet *p_in){ unsigned const char *ptr = p_in->data(); for (unsigned int x = 0; x < _length; x++) { bool error = false; if (x < p_in->length()) { error = (ptr[x] != 0xff); } else { error = true; } if (error) { _byte_errors[x]++; } } output(port).push(p_in); return;}enum {H_HISTOGRAM};static StringLocationHistogram_read_param(Element *e, void *thunk){ LocationHistogram *td = (LocationHistogram *)e; switch ((uintptr_t) thunk) { case H_HISTOGRAM: { StringAccum sa; for (int x = 0; x < td->_byte_errors.size(); x++) { sa << "histogram " << x << " " << td->_byte_errors[x] << "\n"; } return sa.take_string(); } default: return String(); } } voidLocationHistogram::add_handlers(){ add_default_handlers(true); add_read_handler("histogram", LocationHistogram_read_param, (void *) H_HISTOGRAM);}CLICK_ENDDECLSEXPORT_ELEMENT(LocationHistogram)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -