Dumper
用戶指南的此部分描述了嵌入式Lua中Wireshark的特定功能。
類對某些功能進行分組,使用以下符號約定:
- Class.function()表示類* Class上的類方法(名為 function*) ,不帶任何參數。
- Class.function(a)表示一個帶有一個參數的類方法。
- Class.function(…)代表一個帶有可變數量參數的類方法。
- class:method()表示類* Class的實例上的實例方法(名為 method*),不帶任何參數。請注意文檔中的小寫字母表示法以闡明實例。
- class.prop表示類* Class的實例的屬性 prop*。
當前嘗試訪問不存在的屬性,函數或方法會產生錯誤,但不要依賴它,因為將來的行為可能會更改。
保存捕獲文件
該模塊中定義的類/函數用于使用Dumper對象使Wireshark將捕獲文件保存到磁盤。Dumper表示Wireshark的內置文件格式編寫器(請參閱中的wtap_filetypes表init.lua)。
要讓Lua腳本創建自己的文件格式編寫器,請參閱標題為“自定義文件格式讀/寫”的章節。
Dumper
Dumper.new(filename, [filetype], [encap])
創建一個文件來寫數據包: Dumper:new_for_current()
Arguments
filename
要創建的捕獲文件的名稱。
filetype (optional)
要創建的文件的類型- wtap_filetypes中表中的數字條目init.lua。
encap (optional)
要創建的文件中使用的封裝-中的wtap_encaps表中的數字條目init.lua。
Returns
新創建的Dumper對象
dumper:close()
Closes a dumper.
Errors
- Cannot operate on a closed dumper
dumper:flush()
Writes all unsaved data of a dumper to the disk.
dumper:dump(timestamp, pseudoheader, bytearray)
Dumps an arbitrary packet. Note: Dumper:dump_current() will fit best in most cases.
Arguments
timestamp
The absolute timestamp the packet will have.
pseudoheader
The PseudoHeader to use.
bytearray
The data to be saved
dumper:new_for_current([filetype])
Creates a capture file using the same encapsulation as the one of the current packet.
Arguments
filetype (optional)
The file type. Defaults to pcap.
Returns
The newly created Dumper Object
Errors
- Cannot be used outside a tap or a dissector
dumper:dump_current()
Dumps the current packet as it is.
Errors
- Cannot be used outside a tap or a dissector
PseudoHeader
A pseudoheader to be used to save captured frames.
PseudoHeader.none()
Creates a “no” pseudoheader.
Returns
A null pseudoheader
PseudoHeader.eth([fcslen])
Creates an ethernet pseudoheader.
Arguments
fcslen (optional)
The fcs length
Returns
The ethernet pseudoheader
PseudoHeader.atm([aal], [vpi], [vci], [channel], [cells], [aal5u2u], [aal5len])
Creates an ATM pseudoheader.
Arguments
aal (optional)
AAL number
vpi (optional)
VPI
vci (optional)
VCI
channel (optional)
Channel
cells (optional)
Number of cells in the PDU
aal5u2u (optional)
AAL5 User to User indicator
aal5len (optional)
AAL5 Len
Returns
The ATM pseudoheader
PseudoHeader.mtp2([sent], [annexa], [linknum])
Creates an MTP2 PseudoHeader.
Arguments
sent (optional)
True if the packet is sent, False if received.
annexa (optional)
True if annex A is used.
linknum (optional)
Link Number.
Returns
The MTP2 pseudoheader
Wireshark中文使用教程(開發版)