📄 fixdstloc.cc
字号:
/* * fixdstloc.{cc,hh} -- element sets Grid destination 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 "fixdstloc.hh"#include <click/glue.hh>#include <click/confparse.hh>#include <click/error.hh>#include "grid.hh"#include <click/router.hh>#include <clicknet/ether.h>CLICK_DECLSFixDstLoc::FixDstLoc() : Element(1, 1), _loctab(0){}FixDstLoc::~FixDstLoc(){}intFixDstLoc::configure(Vector<String> &conf, ErrorHandler *errh){ int res = cp_va_parse(conf, this, errh, cpElement, "LocationTable element", &_loctab, cpEnd); return res;}intFixDstLoc::initialize(ErrorHandler *errh){ if(_loctab && _loctab->cast("LocationTable") == 0){ errh->warning("%s: LocationTable argument %s has the wrong type", id().cc(), _loctab->id().cc()); _loctab = 0; } else if(_loctab == 0) { return errh->error("no LocationTable argument"); } return 0;}Packet *FixDstLoc::simple_action(Packet *xp){ assert(_loctab); grid_hdr *gh = (grid_hdr *) (xp->data() + sizeof(click_ether)); if (gh->type != grid_hdr::GRID_NBR_ENCAP) { click_chatter("FixDstLoc %s: not an encapsulated data packet; not modifying it\n", id().cc()); return xp; }#ifndef SMALL_GRID_HEADERS WritablePacket *p = xp->uniqueify(); grid_nbr_encap *nb = (grid_nbr_encap *) (p->data() + sizeof(click_ether) + sizeof(grid_hdr)); IPAddress dst(nb->dst_ip); grid_location loc; nb->dst_loc_good = _loctab.get_location(dst, nb->dst_loc, nb->dst_loc_err); return p;#else return xp;#endif}CLICK_ENDDECLSELEMENT_REQUIRES(LocationTable)EXPORT_ELEMENT(FixDstLoc)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -