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

📄 setretry.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
/* * setretry.{cc,hh} -- (re)sets wifi max retries annotation on a packet * Wenjun Hu * * Copyright (c) 2005 University of Cambridge * Copyright (c) 2005 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 "setretry.hh"//#include <clicknet/ether.h>//#include <click/etheraddress.hh>#include <clicknet/wifi.h>CLICK_DECLSSetRetry::SetRetry()  : Element(1, 1), _retries(WIFI_MAX_RETRIES){}SetRetry::~SetRetry(){}intSetRetry::configure(Vector<String> &conf, ErrorHandler *errh){  if (cp_va_parse(conf, this, errh,		  cpOptional,		  cpUnsigned, "retries", &_retries, 		  cpKeywords, 		  "RETRIES", cpUnsigned, "retries", &_retries, 		  cpEnd) < 0) {    return -1;  }  if (_retries < 0) {    return errh->error("RETRIES must be >= 0");    _retries = WIFI_MAX_RETRIES;  }  return 0;}Packet *SetRetry::simple_action(Packet *p_in){  struct click_wifi_extra *ceh = (struct click_wifi_extra *) p_in->all_user_anno();  if (_retries == 0) {    ceh->max_tries = 1;    ceh->max_tries1 = 0;    ceh->max_tries2 = 0;    ceh->max_tries3 = 0;  } else {    if (_retries <= WIFI_MAX_RETRIES)        ceh->max_tries = _retries + 1;  }  return p_in;}StringSetRetry::max_retries(Element *e, void *thunk){  SetRetry *setretry = (SetRetry *)e;  return String(setretry->_retries) + "\n";}intSetRetry::update_retries(const String &arg, Element *e,			 void *vparam, ErrorHandler *errh) {  SetRetry *f = (SetRetry *) e;  String s = cp_uncomment(arg);  unsigned m;  if (!cp_unsigned(s, &m))     return errh->error("retry parameter must be unsigned");  f->_retries = m;    if (m > WIFI_MAX_RETRIES)    click_chatter("Max number of retries is %d ; this new value %d will be ignored", WIFI_MAX_RETRIES, m);  return 0;}voidSetRetry::add_handlers(){  add_default_handlers(true);  add_read_handler("retries", max_retries, 0);  add_write_handler("retries", update_retries, 0);}CLICK_ENDDECLSEXPORT_ELEMENT(SetRetry)

⌨️ 快捷键说明

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