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

📄 xokwriter.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
#include <click/config.h>#include "xokwriter.hh"#include <click/error.hh>#include <click/confparse.hh>#include <stdio.h>#include <unistd.h>extern "C" {#include <vos/net/fast_eth.h>#include <vos/net/ae_ether.h>extern int iptable_find_if_name(const char *);}#define dprintf if (0) printfxokWriter::xokWriter(int c)  : Element(1, 0), cardno(c){}xokWriter::xokWriter(const String &ifname)  : Element(1, 0){  const char *name = ifname.data();  cardno = iptable_find_if_name(name);  if (cardno < 0)    fprintf(stderr,"interface %s not found\n",name);}intxokWriter::configure(Vector<String> &conf, ErrorHandler *errh){  String _ifname;  int r = cp_va_parse(conf, this, errh, cpString, 	              "interface name", &_ifname, cpEnd);  if (r < 0) return r;  const char *name = _ifname.data();  dprintf("xokWriter: looking for interface .%s.\n", name);  cardno = iptable_find_if_name(name);  dprintf("it is at %d\n",cardno);  if (cardno < 0)  {    errh->error("interface not found");    return -1;  }  return 0;}voidxokWriter::push(int port, Packet *p){  assert(p->length() >= 14);  assert(cardno >= 0);  int r = ae_eth_send(p->data(), p->length(), cardno);  if (r < 0)    fprintf(stderr, "xokWriter: write to card %d failed, packet dropped\n", 	    cardno);    p->kill();}voidxokWriter::run_scheduled(){  while (Packet *p = input(0).pull())    push(0, p);}EXPORT_ELEMENT(xokWriter)

⌨️ 快捷键说明

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