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

📄 simplelocquerier.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
/* * simplelocquerier.{cc,hh} -- Simple Grid location query element * Douglas S. J. De Couto * * 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 "simplelocquerier.hh"#include <clicknet/ether.h>#include <click/etheraddress.hh>#include <click/ipaddress.hh>#include <click/confparse.hh>#include <click/bitvector.hh>#include <click/error.hh>#include <click/glue.hh>CLICK_DECLSSimpleLocQuerier::SimpleLocQuerier()  : Element(1, 1){}SimpleLocQuerier::~SimpleLocQuerier(){}intSimpleLocQuerier::configure(Vector<String> &conf, ErrorHandler *errh){  for (int i = 0; i < conf.size(); i++) {    IPAddress ip;    int ilat, ilon;    if (cp_va_space_parse(conf[i], this, errh,			  cpIPAddress, "IP address", &ip,			  cpReal10, "latitude", 7, &ilat,			  cpReal10, "longitude", 7, &ilon,			  cpEnd) < 0)      return -1;    grid_location loc((double) ilat /  1.0e7, (double) ilon /  1.0e7);    _locs.insert(ip, loc);  }  return 0;}intSimpleLocQuerier::initialize(ErrorHandler *){  return 0;}voidSimpleLocQuerier::push(int, Packet *p){  WritablePacket *wp = p->uniqueify();  grid_nbr_encap *nb = (grid_nbr_encap *) (p->data() + sizeof(grid_hdr) + sizeof(click_ether));  IPAddress dst_ip(nb->dst_ip);  grid_location *l = _locs.findp(dst_ip);  if (l == 0) {    click_chatter("SimpleLocQuerier %s: dropping packet for %s; there is no location information",		  id().cc(), dst_ip.s().cc());    wp->kill();  }  else {#ifndef SMALL_GRID_HEADERS    nb->dst_loc = *l;#endif    output(0).push(wp);  }}StringSimpleLocQuerier::read_table(Element *e, void *){  SimpleLocQuerier *slq = (SimpleLocQuerier *) e;  String s;  for (locmap::iterator i = slq->_locs.begin(); i; i++)    s += i.key().s() + " " + i.value().s() + "\n";  return s;}intSimpleLocQuerier::add_entry(const String &arg, Element *element,			    void *, ErrorHandler *errh){  SimpleLocQuerier *l = (SimpleLocQuerier *) element;    IPAddress ip;  int ilat, ilon;  if (cp_va_space_parse(arg, l, errh,			cpIPAddress, "IP address", &ip,			cpReal10, "latitude", 7, &ilat,			cpReal10, "longitude", 7, &ilon,			cpEnd) < 0)    return -1;  grid_location loc((double) ilat /  1.0e7, (double) ilon /  1.0e7);  l->_locs.insert(ip, loc);  return 0;}voidSimpleLocQuerier::add_handlers(){  add_read_handler("table", read_table, (void *)0);  add_write_handler("add", add_entry, (void *)0);}ELEMENT_REQUIRES(userlevel)EXPORT_ELEMENT(SimpleLocQuerier)#include <click/bighashmap.cc>template class HashMap<IPAddress, grid_location>;CLICK_ENDDECLS

⌨️ 快捷键说明

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