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

📄 fixsrcloc.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
/* * fixsrcloc.{cc,hh} -- element sets Grid source location. * Douglas S. J. De Couto * * 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 "fixsrcloc.hh"#include <click/glue.hh>#include <click/confparse.hh>#include <click/error.hh>#include "grid.hh"#include <click/router.hh>#include <clicknet/ether.h>#include "gridgenericlocinfo.hh"CLICK_DECLSFixSrcLoc::FixSrcLoc() : Element(1, 1), _locinfo(0){}FixSrcLoc::~FixSrcLoc(){}intFixSrcLoc::configure(Vector<String> &conf, ErrorHandler *errh){  int res = cp_va_parse(conf, this, errh,                        cpElement, "GridGenericLocInfo element", &_locinfo,			cpEnd);  return res;}intFixSrcLoc::initialize(ErrorHandler *errh){  if(_locinfo && _locinfo->cast("GridGenericLocInfo") == 0){    errh->warning("%s: GridGenericLocInfo argument %s has the wrong type",                  id().cc(),                  _locinfo->id().cc());    _locinfo = 0;  } else if(_locinfo == 0){    return errh->error("no GridGenericLocInfo argument");  }  return 0;}Packet *FixSrcLoc::simple_action(Packet *xp){  assert(_locinfo);  WritablePacket *p = xp->uniqueify();  grid_hdr *gh = (grid_hdr *) (p->data() + sizeof(click_ether));  gh->tx_loc = _locinfo->get_current_location(&gh->loc_seq_no);  gh->tx_loc_seq_no = htonl(_locinfo->seq_no());  gh->tx_loc_err = htons(_locinfo->loc_err());  gh->tx_loc_good = _locinfo->loc_good();  // only fill in packet originator info if we are originating...  if (gh->ip == gh->tx_ip) {    gh->loc = gh->tx_loc;    gh->loc_seq_no = gh->tx_loc_seq_no;    gh->loc_err = gh->tx_loc_err;    gh->loc_good = gh->tx_loc_good;  }  return p;}CLICK_ENDDECLSELEMENT_REQUIRES(GridGenericLocInfo)EXPORT_ELEMENT(FixSrcLoc)

⌨️ 快捷键说明

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