📄 todevice.hh
字号:
#ifndef CLICK_TODEVICE_HH#define CLICK_TODEVICE_HH/*=cToDevice(DEVNAME [, BURST, I<KEYWORDS>])=s devicessends packets to network device (Linux kernel)=dThis manual page describes the Linux kernel module version of the ToDeviceelement. For the user-level element, read the ToDevice.u manual page.Pulls packets from its single input and sends them out the Linux networkinterface named DEVNAME. DEVNAME may also be an Ethernet address, in whichcase ToDevice searches for a device with that address.Sends up to BURST packets each time it is scheduled. By default, BURST is 16.For good performance, you should set BURST to be 8 times the number ofelements that could generate packets for this device.Packets must have a link header. For Ethernet, ToDevice makes sure everypacket is at least 60 bytes long.Keyword arguments are:=over 8=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 ToDevice will report a warning (rather than anerror). Later, while the router is running, if a device named DEVNAME appears,ToDevice will seamlessly begin sending packets to it. Default is false.=item NO_PADBoolean. If true, don't force packets to be at least 60 bytes (theminimum Ethernet packet size). This is useful because some 802.11cards can send shorter Ethernet format packets. Defaults false.=back=nThe Linux networking code may also send packets out the device. If the deviceis in polling mode, Click will try to ensure that Linux eventually sends itspackets. Linux may cause the device to be busy when a ToDevice wants to send apacket. Click is not clever enough to re-queue such packets, and discardsthem.In Linux 2.2, whether or not the device is running in polling mode, ToDevicedepends on the device driver's send operation for synchronization (e.g. tulipsend operation uses a bit lock). In Linux 2.4, we use the device's "xmit_lock"to synchronize.Packets sent via ToDevice will not be received by any packet sniffers on themachine. Use Tee and ToHostSniffers to send packets to sniffers explicitly.=h count read-onlyReturns the number of packets ToDevice has pulled.=h calls read-onlyReturns a summary of ToDevice statistics.=h drops read-onlyReturns the number of packets ToDevice has dropped. ToDevice will droppackets because they are too short for the device, or because the deviceexplicitly rejected them.=h reset_counts write-onlyResets counters to zero when written.=a FromDevice, PollDevice, FromHost, ToHost, ToDevice.u, Tee, ToHostSniffers*/#include "elements/linuxmodule/anydevice.hh"#include <click/notifier.hh>class ToDevice : public AnyTaskDevice { public: ToDevice(); ~ToDevice(); static void static_initialize(); static void static_cleanup(); const char *class_name() const { return "ToDevice"; } const char *processing() const { return PULL; } int configure_phase() const { return CONFIGURE_PHASE_TODEVICE; } int configure(Vector<String> &, ErrorHandler *); int initialize(ErrorHandler *); void cleanup(CleanupStage); void add_handlers(); bool run_task(); void reset_counts(); void change_device(net_device *); void tx_wake_queue(net_device *); bool tx_intr();#if CLICK_DEVICE_STATS // Statistics. uint64_t _time_clean; uint64_t _time_freeskb; uint64_t _time_queue; uint64_t _perfcnt1_pull; uint64_t _perfcnt1_clean; uint64_t _perfcnt1_freeskb; uint64_t _perfcnt1_queue; uint64_t _perfcnt2_pull; uint64_t _perfcnt2_clean; uint64_t _perfcnt2_freeskb; uint64_t _perfcnt2_queue; uint32_t _activations; #endif uint32_t _runs; uint32_t _pulls; uint32_t _npackets;#if CLICK_DEVICE_THESIS_STATS || CLICK_DEVICE_STATS uint64_t _pull_cycles;#endif uint32_t _rejected; uint32_t _hard_start; uint32_t _busy_returns; uint32_t _too_short;#if HAVE_LINUX_POLLING bool polling() const { return _dev && _dev->polling > 0; }#else bool polling() const { return false; }#endif private: unsigned _burst; int _dev_idle; NotifierSignal _signal; bool _no_pad; int queue_packet(Packet *p); };#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -