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

📄 setip6dscp.cc

📁 Click is a modular router toolkit. To use it you ll need to know how to compile and install the sof
💻 CC
字号:
/* * setip6dscp.{cc,hh} -- element sets IP6 header DSCP field * Frederik Scholaert * * Copyright (c) 2002 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 "setip6dscp.hh"#include <clicknet/ip6.h>#include <click/confparse.hh>#include <click/error.hh>CLICK_DECLSSetIP6DSCP::SetIP6DSCP(){}SetIP6DSCP::~SetIP6DSCP(){}intSetIP6DSCP::configure(const Vector<String> &conf, ErrorHandler *errh){  unsigned dscp_val;  if (cp_va_kparse(conf, this, errh,		   "DSCP", cpkP+cpkM, cpUnsigned, &dscp_val,		   cpEnd) < 0)    return -1;  if (dscp_val > 0x3F)    return errh->error("diffserv code point out of range");  // OK: set values  _dscp = (dscp_val << IP6_DSCP_SHIFT);  return 0;}inline Packet *SetIP6DSCP::smaction(Packet *p_in){  WritablePacket *p = p_in->uniqueify();  assert(p->has_network_header());  click_ip6 *ip6 = p->ip6_header();  uint32_t flow = ntohl(ip6->ip6_flow);  ip6->ip6_flow = htonl((flow & ~IP6_DSCP_MASK) | _dscp);  return p;}voidSetIP6DSCP::push(int, Packet *p){  if ((p = smaction(p)) != 0)    output(0).push(p);}Packet *SetIP6DSCP::pull(int){  Packet *p = input(0).pull();  if (p)    p = smaction(p);  return p;}voidSetIP6DSCP::add_handlers(){    add_read_handler("dscp", read_keyword_handler, "0 DSCP", Handler::CALM);    add_write_handler("dscp", reconfigure_keyword_handler, "0 DSCP");}CLICK_ENDDECLSEXPORT_ELEMENT(SetIP6DSCP)ELEMENT_MT_SAFE(SetIP6DSCP)

⌨️ 快捷键说明

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