📄 fromdevice.hh
字号:
#ifndef CLICK_FROMDEVICE_HH#define CLICK_FROMDEVICE_HH/*=title FromDevice.b=cFromDevice(DEVNAME [, PROMISC, BURST, I<KEYWORDS>])=s devicesreads packets from network device (BSD kernel)=dThis manual page describes the BSD kernel module version of the FromDeviceelement. For the user-level element, read the FromDevice.u manual page.Intercepts all packets received by the BSD 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 pulls packets from a per-interface queue in the context of theClick kernel thread. It emits at most BURST packets per scheduling;BURST is 8 by default. At interrupt time, the kernel queues packetsonto the per-interface queue if there is a FromDevice attached to thatinterface.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=nThe BSD network stack (above the device layer) won't see any packets fromthe device. If you want BSD to process packets, you should hand them toToBSD.FromDevice accesses packets the same way BSD does: through interrupts.Performance is system-dependent (FreeBSD has a native polling modewhich can be used for better performance and stability).=a ToDevice, FromHost, ToHost, FromDevice.u */#include <click/element.hh>#include "elements/bsdmodule/anydevice.hh"#include <click/standard/storage.hh>class FromDevice : public AnyDevice, public Storage { public: FromDevice(); ~FromDevice(); 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(struct if_net *); int get_inq_drops(); // get some performance stats bool run_task(); poll_handler_t *_poll_handler; int _npackets;#if CLICK_DEVICE_STATS int _perfcnt1_read, _perfcnt2_read; int _perfcnt1_push, _perfcnt2_push; long long _time_read, _time_push;#endif unsigned _readers; // how many readers registered for this? struct ifqueue *_inq; int _polling; int _poll_status_tick; uint64_t _tstamp; private: bool _promisc; unsigned _burst; static const int QSIZE = 511;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -