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

📄 fixipsrc.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
/* * fixipsrc.{cc,hh} -- element sets IP source if Fix IP Source annotation on * 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 "fixipsrc.hh"#include <click/glue.hh>#include <click/confparse.hh>#include <click/error.hh>#include <clicknet/ip.h>#include <click/packet_anno.hh>CLICK_DECLSFixIPSrc::FixIPSrc(){  add_input();  add_output();}FixIPSrc::~FixIPSrc(){}intFixIPSrc::configure(Vector<String> &conf, ErrorHandler *errh){  IPAddress a;  if (cp_va_parse(conf, this, errh,                  cpIPAddress, "local addr", &a,		  cpEnd) < 0)    return -1;  _my_ip = a.in_addr();  return 0;}WritablePacket *FixIPSrc::fix_it(Packet *p_in){  WritablePacket *p = p_in->uniqueify();  click_ip *ip = p->ip_header();  SET_FIX_IP_SRC_ANNO(p, 0);#if 0  click_chatter("FixIPSrc changed %x to %x",                ip->ip_src.s_addr,                _my_ip.s_addr);#endif  ip->ip_src = _my_ip;  int hlen = ip->ip_hl << 2;  ip->ip_sum = 0;  ip->ip_sum = click_in_cksum((unsigned char *)ip, hlen);  return p;}Packet *FixIPSrc::simple_action(Packet *p){  const click_ip *ip = p->ip_header();  if (FIX_IP_SRC_ANNO(p) && ip)    p = fix_it(p);  return p;}CLICK_ENDDECLSEXPORT_ELEMENT(FixIPSrc)ELEMENT_MT_SAFE(FixIPSrc)

⌨️ 快捷键说明

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