wifiipmarker.cc

来自「COPE the first practical network coding 」· CC 代码 · 共 100 行

CC
100
字号
#include <click/config.h>#include "wifiipmarker.hh"#include "xorheader.hh"#include "../sr/srpacket.hh"#include <click/confparse.hh>#include <click/error.hh>#include <clicknet/ether.h>#include <click/etheraddress.hh>#include <click/ipaddress.hh>#include <click/timestamp.hh>#include <click/straccum.hh>#include <click/packet_anno.hh>WifiIPMarker::WifiIPMarker()  : Element(1, 1),    _enc_ethtype(0){}WifiIPMarker::~WifiIPMarker(){}intWifiIPMarker::configure(Vector<String> &conf, ErrorHandler *errh){  String s;  int res = cp_va_parse(conf, this, errh,			cpKeywords,			"ENCETHTYPE", cpUnsigned, "Ethernet encapsulation type for encoded", &_enc_ethtype,			cpEnd);  if (!_enc_ethtype) {    return errh->error("ENCETHTYPE not specified");  }  if (res < 0) {    return -1;  }  return res;}Packet *WifiIPMarker::drop(Packet *p){  /*  if (noutputs() == 2)    output(1).push(p);  else  */  p->kill();  return 0;}    Packet *WifiIPMarker::simple_action(Packet *p){  const click_ether *e = (const click_ether *)(p->data());  uint16_t et = ntohs(e->ether_type);    if (et == _enc_ethtype) {    return p;  }      /*  EtherAddress srcea = EtherAddress((const unsigned char *)e->ether_shost);  EtherAddress dstea = EtherAddress((const unsigned char *)e->ether_dhost);  StringAccum s2;  s2 << "src " << srcea << " dst " << dstea;  click_chatter("etherfilter saw a packet with type %#0x, %s", et, s2.c_str());  */    StringAccum sa;    WritablePacket *pw = p->uniqueify();    struct srpacket *pk = (struct srpacket *)(e+1);  int extra = pk->hlen_wo_data() + sizeof(click_ether);    const click_ip *i = reinterpret_cast<const click_ip *>(pw->data()+extra);  pw->set_ip_header(i, i->ip_hl << 2);    sa << EtherAddress(e->ether_shost) << " " << IPAddress(i->ip_src) << " " << ntohs(i->ip_id) << " " << IPAddress(i->ip_dst);  click_chatter("IPmarker %u %s", Timestamp::now().msec1(), sa.c_str());  return pw;}// ETHERSRC ETHERDST ENCODED/NOT IPSRCADDR TCPSRCPORT IPDSTADDR TCPDSTPORT IPID TCPSEQNO TCPACKNO#include <click/vector.cc>#if EXPLICIT_TEMPLATE_INSTANCEStemplate class typedef Vector<EtherAddress>;#endifEXPORT_ELEMENT(WifiIPMarker)

⌨️ 快捷键说明

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