📄 ip6fragmenter.cc
字号:
/* * ip6fragmenter.{cc,hh} -- element fragments IP6 packets * Robert Morris * * Copyright (c) 1999 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 "ip6fragmenter.hh"#include <clicknet/ip6.h>#include <click/confparse.hh>#include <click/error.hh>#include <click/glue.hh>CLICK_DECLSIP6Fragmenter::IP6Fragmenter() : _drops(0){ _fragments = 0; _mtu = 0; add_input(); add_output();}IP6Fragmenter::~IP6Fragmenter(){}voidIP6Fragmenter::notify_noutputs(int n){ // allow 2 outputs -- then packet is pushed onto 2d output instead of // dropped set_noutputs(n < 2 ? 1 : 2);}intIP6Fragmenter::configure(Vector<String> &conf, ErrorHandler *errh){ if (cp_va_parse(conf, this, errh, cpUnsigned, "MTU", &_mtu, cpEnd) < 0) return -1; return 0;} /*intIP6Fragmenter::optcopy(click_ip6 *ip1, click_ip6 *ip2){ int opts = (ip1->ip_hl << 2) - sizeof(click_ip6); u_char *base1 = (u_char *) (ip1 + 1); int i1, optlen; int i2 = 0; u_char *base2 = (u_char *) (ip2 + 1); for(i1 = 0; i1 < opts; i1 += optlen){ int opt = base1[i1]; if(opt == IPOPT_EOL) break; if(opt == IPOPT_NOP){ optlen = 1; } else { optlen = base1[i1+1]; } if(opt & 0x80){ // copy it if(ip2){ memcpy(base2 + i2, base1 + i1, optlen); } i2 += optlen; } } for( ; i2 & 3; i2++) if(ip2) base2[i2] = IPOPT_EOL; return(i2);}*/voidIP6Fragmenter::fragment(Packet *){ }/*inline Packet *IP6Fragmenter::smaction(Packet *p){ if (p->length() <= _mtu) { //click_chatter("IP6Fragmenter: length is OK, <= %x \n", _mtu); return(p); } else { click_chatter("IP6Fragmenter: length is not OK, > %x \n", _mtu); if (noutputs() == 2) output(1).push(p); else p->kill(); return 0; }}*/static StringIP6Fragmenter_read_drops(Element *xf, void *){ IP6Fragmenter *f = (IP6Fragmenter *)xf; return String(f->drops()) + "\n";}static StringIP6Fragmenter_read_fragments(Element *xf, void *){ IP6Fragmenter *f = (IP6Fragmenter *)xf; return String(f->fragments()) + "\n";}voidIP6Fragmenter::add_handlers(){ add_read_handler("drops", IP6Fragmenter_read_drops, 0); add_read_handler("fragments", IP6Fragmenter_read_fragments, 0);}voidIP6Fragmenter::push(int, Packet *p){ // click_chatter("IP6Fragmenter::push, packet length is %x \n", p->length()); if (p->length() <= _mtu) { // click_chatter("**********************1"); output(0).push(p); } else { // click_chatter("**********************2"); // output(0).push(p); }}CLICK_ENDDECLSEXPORT_ELEMENT(IP6Fragmenter)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -