📄 unique_id.cc
字号:
/******************************************************************* Copyright (C) 2004 Thomas Kunz, CRC Canada, BCAST for IPv4. DISTRIBUTED WITH NO WARRANTY, EXPRESS OR IMPLIED. See the GNU Library General Public License (file COPYING in the MANET_multicast directory) for conditions of use and redistribution.*********************************************************************//* * Functions to manage unique message IDs. These are saved in a list * which gets temporarily cleaned out (each entry has a timer). */#include "MANET_multicast/unique_id.h"#define CURRENT_TIME Scheduler::instance().clock() voidUniqueIDHandler::handle(Event*) { id_purge(); Scheduler::instance().schedule(this, &intr, 1.0);}/* Unique ID Management Functions*/voidUniqueIDHandler::id_insert(nsaddr_t id, u_int32_t bid) {UniqueID *b = new UniqueID(id, bid); assert(b); b->expire = CURRENT_TIME + UNIQUE_ID_SAVE; LIST_INSERT_HEAD(&uids, b, link);}boolUniqueIDHandler::id_lookup(nsaddr_t id, u_int32_t bid) {UniqueID *b = uids.lh_first; // Search the list for a match of source and bid for( ; b; b = b->link.le_next) { if ((b->src == id) && (b->id == bid)) return true; } return false;}voidUniqueIDHandler::id_purge() {UniqueID *b = uids.lh_first;UniqueID *bn;double now = CURRENT_TIME; for(; b; b = bn) { bn = b->link.le_next; if(b->expire <= now) { LIST_REMOVE(b,link); delete b; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -