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

📄 iprwpatterns.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
/* * iprwpatterns.{cc,hh} -- stores shared IPRewriter patterns * Eddie Kohler * * Copyright (c) 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 "iprwpatterns.hh"#include <click/confparse.hh>#include <click/router.hh>#include <click/error.hh>CLICK_DECLSIPRewriterPatterns::IPRewriterPatterns()  : _name_map(-1){}IPRewriterPatterns::~IPRewriterPatterns(){}intIPRewriterPatterns::configure(Vector<String> &conf, ErrorHandler *errh){  // check for an earlier IPRewriterPatterns  const Vector<Element *> &ev = router()->elements();  for (int i = 0; i < eindex(); i++)    if (IPRewriterPatterns *rwp = (IPRewriterPatterns *)ev[i]->cast("IPRewriterPatterns"))      return rwp->configure(conf, errh);  for (int i = 0; i < conf.size(); i++) {    String word, rest;    // allow empty patterns for convenience    if (!cp_word(conf[i], &word, &rest))      continue;    cp_eat_space(rest);    if (_name_map[word] >= 0) {      errh->error("pattern name `%s' has already been defined", word.cc());      continue;    }    IPRw::Pattern *p;    if (IPRw::Pattern::parse(rest, &p, this, errh) >= 0) {      p->use();      _name_map.insert(word, _patterns.size());      _patterns.push_back(p);    }  }  return 0;}voidIPRewriterPatterns::cleanup(CleanupStage){  for (int i = 0; i < _patterns.size(); i++)    _patterns[i]->unuse();}IPRw::Pattern *IPRewriterPatterns::find(Element *e, const String &name, ErrorHandler *errh){  const Vector<Element *> &ev = e->router()->elements();  for (int i = 0; i < ev.size(); i++)    if (IPRewriterPatterns *rwp = (IPRewriterPatterns *)ev[i]->cast("IPRewriterPatterns")) {      int x = rwp->_name_map[name];      if (x >= 0)	return rwp->_patterns[x];      break;    }  errh->error("no pattern named `%s'", name.c_str());  return 0;}CLICK_ENDDECLSELEMENT_REQUIRES(IPRw)EXPORT_ELEMENT(IPRewriterPatterns)

⌨️ 快捷键说明

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