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

📄 settimestamp.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
// -*- c-basic-offset: 4 -*-/* * settimestamp.{cc,hh} -- set timestamp annotations * Douglas S. J. De Couto, Eddie Kohler * based on setperfcount.{cc,hh} * * Copyright (c) 1999-2000 Massachusetts Institute of Technology * Copyright (c) 2005 Regents of the University of California * * 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 "settimestamp.hh"#include <click/confparse.hh>#include <click/packet_anno.hh>#include <click/error.hh>CLICK_DECLSSetTimestamp::SetTimestamp()    : Element(1, 1){}SetTimestamp::~SetTimestamp(){}intSetTimestamp::configure(Vector<String> &conf, ErrorHandler *errh){    bool first = false, delta = false;    _tv._sec = -1;    _action = ACT_NOW;    if (cp_va_parse(conf, this, errh,		    cpOptional,		    cpTimestamp, "timestamp", &_tv,		    cpKeywords,		    "FIRST", cpBool, "set first timestamp?", &first,		    "DELTA", cpBool, "set timestamp delta?", &delta,		    cpEnd) < 0)	return -1;    if ((first && delta) || (_tv._sec >= 0 && delta))	return errh->error("must specify at most one of 'FIRST' and 'DELTA'");    _action = (delta ? ACT_DELTA : (_tv._sec < 0 ? ACT_NOW : ACT_TIME) + (first ? ACT_FIRST_NOW : ACT_NOW));    return 0;}Packet *SetTimestamp::simple_action(Packet *p){    if (_action == ACT_NOW)	p->timestamp_anno().set_now();    else if (_action == ACT_TIME)	p->timestamp_anno() = _tv;    else if (_action == ACT_FIRST_NOW)	FIRST_TIMESTAMP_ANNO(p).set_now();    else if (_action == ACT_FIRST_TIME)	FIRST_TIMESTAMP_ANNO(p) = _tv;    else	p->timestamp_anno() -= FIRST_TIMESTAMP_ANNO(p);    return p;}CLICK_ENDDECLSEXPORT_ELEMENT(SetTimestamp)

⌨️ 快捷键说明

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