📄 todump.hh
字号:
// -*- mode: c++; c-basic-offset: 4 -*-#ifndef CLICK_TODUMP_HH#define CLICK_TODUMP_HH#include <click/timer.hh>#include <click/element.hh>#include <click/task.hh>#include <click/notifier.hh>#include <stdio.h>CLICK_DECLS/*=cToDump(FILENAME [, I<keywords> SNAPLEN, ENCAP, USE_ENCAP_FROM, EXTRA_LENGTH])=s analysiswrites packets to a tcpdump(1) file=dWrites incoming packets to FILENAME in `tcpdump -w' format. This file can beread by `tcpdump -r', or by FromDump on a later run. FILENAME can be `-', inwhich case ToDump writes to the standard output.Writes at most SNAPLEN bytes of each packet to the file. The default SNAPLENis 2000. If SNAPLEN is 0, the whole packet will be written to the file. ENCAPspecifies the first header each packet is expected to have. This informationis stored in the file header, and must be correct or tcpdump won't be able toread the file correctly. It can be C<ETHER> (Ethernet encapsulation),C<IP> (raw IP packets), C<FDDI>, C<ATM>, C<802_11>, C<SLL>, C<AIRONET>, C<HDLC>,C<PPP_HDLC>, C<PPP>, C<SUNATM>, C<PRISM>, or C<NULL>; the default is C<ETHER>.ToDump may have zero or one output. If it has an output, then it emits allreceived packets on that output. ToDump will schedule itself on the task listif it is used as a pull element with no outputs.Keyword arguments are:=over 8=item SNAPLENInteger. See above.=item ENCAPThe encapsulation type to store in the dump. See above.=item USE_ENCAP_FROMArgument is a space-separated list of element names. At initialization time,ToDump will check these elements' `encap' handlers, and parse them as ENCAParguments. If all the handlers agree, ToDump will use that encapsulation type;otherwise, it will report an error. You can specify at most one of ENCAP andUSE_ENCAP_FROM. FromDump and FromDevice.u have `encap' handlers.=item EXTRA_LENGTHBoolean. Set to true if you want ToDump to store any extra length as recordedin packets' extra length annotations. Default is true.=backThis element is only available at user level.=nToDump stores packets' true length annotations when available.=h filename read-onlyReturns the filename.=aFromDump, FromDevice.u, ToDevice.u, tcpdump(1) */class ToDump : public Element { public: ToDump(); ~ToDump(); const char *class_name() const { return "ToDump"; } const char *processing() const { return AGNOSTIC; } const char *flags() const { return "S2"; } // configure after FromDevice and FromDump void notify_noutputs(int); int configure_phase() const { return CONFIGURE_PHASE_DEFAULT+100; } int configure(Vector<String> &, ErrorHandler *); int initialize(ErrorHandler *); void cleanup(CleanupStage); void add_handlers(); ToDump *hotswap_element() const; void take_state(Element *, ErrorHandler *); void push(int, Packet *); Packet *pull(int); bool run_task(); private: String _filename; FILE *_fp; unsigned _snaplen; int _linktype; bool _active; bool _extra_length; Task _task; NotifierSignal _signal; Element **_use_encap_from; static String read_handler(Element *, void *); void write_packet(Packet *);};CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -