arpfaker.cc

来自「Click is a modular router toolkit. To us」· CC 代码 · 共 69 行

CC
69
字号
/* * arpfaker.{cc,hh} -- ARP response faker element * Robert Morris * * 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 "arpfaker.hh"#include "arpresponder.hh"#include <clicknet/ether.h>#include <click/etheraddress.hh>#include <click/ipaddress.hh>#include <click/confparse.hh>#include <click/error.hh>#include <click/glue.hh>CLICK_DECLSARPFaker::ARPFaker()  : _timer(this){}ARPFaker::~ARPFaker(){}intARPFaker::configure(Vector<String> &conf, ErrorHandler *errh){    return cp_va_kparse(conf, this, errh,			"DSTIP", cpkP+cpkM, cpIPAddress, &_ip1,			"DSTETH", cpkP+cpkM, cpEthernetAddress, &_eth1,			"SRCIP", cpkP+cpkM, cpIPAddress, &_ip2,			"SRCETH", cpkP+cpkM, cpEthernetAddress, &_eth2,			cpEnd);}intARPFaker::initialize(ErrorHandler *){    _timer.initialize(this);    _timer.schedule_after_msec(1 * 1000); // Send an ARP reply periodically.    return 0;}voidARPFaker::run_timer(Timer *){    if (Packet *p = ARPResponder::make_response(_eth1.data(), _ip1.data(),						_eth2.data(), _ip2.data()))	output(0).push(p);    _timer.schedule_after_msec(10 * 1000);}CLICK_ENDDECLSELEMENT_REQUIRES(ARPResponder)EXPORT_ELEMENT(ARPFaker)

⌨️ 快捷键说明

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