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

📄 fromdevice.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
// -*- c-basic-offset: 4 -*-#ifndef CLICK_FROMDEVICE_HH#define CLICK_FROMDEVICE_HH/*=cFromDevice(DEVNAME [, PROMISC, BURST, I<KEYWORDS>])=s devicesreads packets from network device (Linux kernel)=dThis manual page describes the Linux kernel module version of the FromDeviceelement. For the user-level element, read the FromDevice.u manual page.Intercepts all packets received by the Linux network interface named DEVNAMEand pushes them out output 0. The packets include the link-level header.DEVNAME may also be an Ethernet address, in which case FromDevice searches fora device with that address.FromDevice receives packets at interrupt time. As this happens, FromDevicesimply stores the packets in an internal queue. Later, in the Click kernelthread -- that is, not at interrupt time -- FromDevice emits packets from thatqueue as it is scheduled by the driver. It emits at most BURST packets perscheduling; BURST is 8 by default.If PROMISC is set (by default, it is not), then the device is put intopromiscuous mode while FromDevice is active.Keyword arguments are:=over 8=item PROMISCBoolean. Same as the PROMISC argument.=item BURSTUnsigned integer. Same as the BURST argument.=item ALLOW_NONEXISTENTAllow nonexistent devices. If true, and no device named DEVNAME exists whenthe router is initialized, then FromDevice will report a warning (rather thanan error). Later, while the router is running, if a device named DEVNAMEappears, FromDevice will seamlessly begin outputing its packets. Default isfalse.=back=nLinux won't see any packets from the device. If you want Linux to processpackets, you should hand them to ToHost.FromDevice accesses packets the same way Linux does: through interrupts.This is bad for performance. If you care about performance and have apolling-capable device, use PollDevice instead.Linux device drivers, and thus FromDevice, should set packets' timestamp,packet-type, and device annotations.=a PollDevice, ToDevice, FromHost, ToHost, FromDevice.u */#include "elements/linuxmodule/anydevice.hh"#include <click/standard/storage.hh>class FromDevice : public AnyTaskDevice, public Storage { public:        FromDevice();    ~FromDevice();    static void static_initialize();    static void static_cleanup();    const char *class_name() const	{ return "FromDevice"; }    const char *processing() const	{ return PUSH; }    void *cast(const char *);    int configure(Vector<String> &, ErrorHandler *);    int initialize(ErrorHandler *);    void cleanup(CleanupStage);    void add_handlers();    void take_state(Element *, ErrorHandler *);    void change_device(net_device *);        /* process a packet. return 0 if not wanted after all. */    int got_skb(struct sk_buff *);    bool run_task();    void reset_counts();    unsigned drops()                   { return _drops; }    unsigned runs()                    { return _runs; }    unsigned empty_runs()              { return _empty_runs; }    unsigned pushes()                  { return _pushes; }  private:    unsigned _burst;    unsigned _drops;    unsigned _runs;    unsigned _empty_runs;    unsigned _pushes;    enum { QSIZE = 511 };    Packet *_queue[QSIZE+1];#if CLICK_DEBUG_SCHEDULING    struct Schinfo {	struct timeval enq_time;	char enq_state;	char enq_woke_process;	char enq_task_scheduled;	uint32_t enq_epoch;	uint32_t enq_task_epoch;    };    Schinfo _schinfo[QSIZE+1];    void emission_report(int);#endif};#endif

⌨️ 快捷键说明

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