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

📄 fromdevice.hh

📁 Click is a modular router toolkit. To use it you ll need to know how to compile and install the sof
💻 HH
字号:
// -*- c-basic-offset: 4 -*-#ifndef CLICK_FROMDEVICE_HH#define CLICK_FROMDEVICE_HH/*=cFromDevice(DEVNAME [, I<keywords> PROMISC, BURST, TIMESTAMP...])=s netdevicesreads 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.Keyword arguments are:=over 8=item PROMISCBoolean.  If true, the device is put into promiscuous mode while FromDevice isactive.  Default is false.=item BURSTUnsigned integer.  Sets the BURST parameter.=item TIMESTAMPBoolean.  If true, then ensure that received packets have correctly-settimestamp annotations.  Default is true.=item QUIETBoolean.  If true, then suppress device up/down messages.  Default is false.=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.=item UP_CALLWrite handler.  If supplied, this handler is called when the device or linkcomes up.=item DOWN_CALLWrite handler.  If supplied, this handler is called when the device or linkgoes down.=item ACTIVEBoolean.  If false, then FromDevice will not accept packets from the attacheddevice; instead, packets from the device are processed by Linux as usual.Default is true.=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.=h active read/writeThe write handler sets the ACTIVE parameter.  The read handler returns theACTIVE parameter if the device is up, or "false" if the device is down.=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 *port_count() const	{ return PORTS_0_1; }    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 *);    /* process a packet. return 0 if not wanted after all. */    int got_skb(struct sk_buff *);    bool run_task(Task *);    void reset_counts() {	_runs = _empty_runs = _pushes = _drops = 0;    }  private:    bool _active;    unsigned _burst;    unsigned _drops;    unsigned _runs;    unsigned _empty_runs;    unsigned _pushes;    enum { QSIZE = 511 };    Packet *_queue[QSIZE+1];#if CLICK_DEBUG_SCHEDULING    struct Schinfo {	Timestamp 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    static String read_handler(Element *, void *);    static int write_handler(const String &, Element *, void *, ErrorHandler *);};#endif

⌨️ 快捷键说明

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