home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Networking / nmap-5.00-setup.exe / nselib / nmap.luadoc < prev    next >
Text File  |  2009-07-06  |  25KB  |  506 lines

  1. --- Interface with Nmap internals.
  2. --
  3. -- The <code>nmap</code> module is an interface with Nmap's internal functions
  4. -- and data structures. The API provides target host details such as port
  5. -- states and version detection results. It also offers an interface to the
  6. -- Nsock library for efficient network I/O. 
  7. -- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html
  8.  
  9. module "nmap"
  10.  
  11. --- Returns the debugging level as a non-negative integer.
  12. --
  13. -- The debugging level can be set with the <code>-d</code> option.
  14. -- @return The debugging level.
  15. -- @usage if nmap.debugging() > 0 then ... end
  16. function debugging()
  17.  
  18. --- Determines whether Nmap was compiled with SSL support.
  19. --
  20. -- This can be used to avoid sending SSL probes when SSL is not available. 
  21. -- @return True if Nmap was compiled with SSL support, false otherwise.
  22. function have_ssl()
  23.  
  24. --- Returns the verbosity level as a non-negative integer.
  25. --
  26. -- The verbosity level can be set with the <code>-v</code> option.
  27. -- @return The verbosity level.
  28. -- @usage if nmap.verbosity() > 0 then ... end
  29. function verbosity()
  30.  
  31. --- Searches for the specified file and returns a string containing its path if
  32. -- it is found and readable (to the process).
  33. --
  34. -- If the file is not found, not readable, or is a directory, <code>nil</code>
  35. -- is returned.
  36. -- @usage
  37. -- nmap.fetchfile("nmap-rpc") --> "/usr/local/share/nmap/nmap-rpc"
  38. -- @param filename Filename to search for.
  39. -- @return String representing the full path to the file or <code>nil</code>.
  40. function fetchfile(filename)
  41.  
  42. --- Returns the timing level as a non-negative integer.
  43. --
  44. -- Possible return values vary from <code>0</code> to <code>5</code>,
  45. -- corresponding to the six built-in Nmap timing templates. The timing level
  46. -- can be set with the <code>-T</code> option.
  47. -- @return The timing level.
  48. function timing_level()
  49.  
  50. --- Gets a port table for a port on a given host.
  51. --
  52. -- This function takes a host table and a port table and returns a port table
  53. -- for the queried port. The port table returned is similar in structure to the
  54. -- ones passed to the <code>hostrule</code>, <code>portrule</code>, and
  55. -- <code>action</code> functions.
  56. --
  57. -- You can of course reuse the host and port tables passed to a script's rule
  58. -- function. The purpose of this call is to be able to match scripts against
  59. -- more than one open port. For example if the target host has an open port 22
  60. -- and a running identd server, then you can write a script which will only fire
  61. -- if both ports are open and there is an identification server on port 113.
  62. -- While it is possible to specify IP addresses different to the currently
  63. -- scanned target, the result will only be correct if the target is in the
  64. -- currently scanned group of hosts.
  65. -- @param host Host table, containing an <code>ip</code> field.
  66. -- @param port Port table, containing <code>number</code> and
  67. -- <code>protocol</code> fields.
  68. -- @return A new port table holding the status and information for the port.
  69. -- @usage p = nmap.get_port_state({ip="127.0.0.1"}, {number="80", protocol="tcp"})
  70. function get_port_state(host, port)
  71.  
  72. --- Sets the state of a port on a given host.
  73. --
  74. -- Using this function, the final port state, reflected in Nmap's results, can
  75. -- be changed for a target. This is useful when Nmap detects a port as
  76. -- <code>open|filtered</code>, but the script successfully connects to that
  77. -- port. In this case, the script can set the port state to <code>open</code>.
  78. -- This function doesn't change the original port table passed a script's
  79. -- action function.
  80. -- @param host Host table, containing an <code>ip</code> field.
  81. -- @param port Port table, containing <code>number</code> and
  82. -- <code>protocol</code> fields.
  83. -- @param state Port state, like <code>"open"</code> or <code>"closed"</code>.
  84. function set_port_state(host, port, state)
  85.  
  86. --- Sets version information on a port.
  87. --
  88. -- NSE scripts are sometimes able to determine the service name and application
  89. -- version listening on a port. A whole script category (<code>version</code>)
  90. -- was designed for this purpose. This function is used to record version
  91. -- information when it is discovered.
  92. --
  93. -- The host and port arguments to this function should either be the tables
  94. -- passed to the action method or they should have the same structure. The port
  95. -- argument specifies the port to operate on through its <code>number</code>
  96. -- and <code>protocol</code> fields. and also contains the new version
  97. -- information to set. The version detection fields this function looks at are
  98. -- <code>name</code>, <code>product</code>, <code>version</code>,
  99. -- <code>extrainfo</code>, <code>hostname</code>, <code>ostype</code>,
  100. -- <code>devicetype</code>, and <code>service_tunnel</code>. All these keys are
  101. -- optional.
  102. --
  103. -- The <code>probestate</code> argument describes the state in which the script
  104. -- completed. It is a string, one of: <code>"hardmatched"</code>,
  105. -- <code>"softmatched"</code>, <code>"nomatch"</code>,
  106. -- <code>"tcpwrapped"</code>, or <code>"incomplete"</code>.
  107. -- <code>"hardmatched"</code> is almost always used (and is the default),
  108. -- as it signifies a
  109. -- successful match. The other possible states are generally only used for
  110. -- standard version detection rather than the NSE enhancement.
  111. -- @param host Host table, containing an <code>ip</code> field.
  112. -- @param port Port table, containing <code>number</code> and
  113. -- <code>protocol</code> fields, as well as any additional version information
  114. -- fields.
  115. -- @param probestate The state of the probe: <code>"hardmatched"</code>,
  116. -- <code>"softmatched"</code>, <code>"nomatch"</code>,
  117. -- <code>"tcpwrapped"</code>, or <code>"incomplete"</code>.
  118. function set_port_version(host, port, probestate)
  119.  
  120. --- Returns the current date and time in milliseconds.
  121. -- @return The number of milliseconds since the epoch (on most systems this is
  122. -- 01/01/1970).
  123. -- @usage local now = nmap.clock_ms()
  124. function clock_ms()
  125.  
  126. --- Gets the link-level hardware type of an interface.
  127. --
  128. -- This function takes a dnet-style interface name and returns a string
  129. -- representing the hardware type of the interface. Possible return values are
  130. -- <code>"ethernet"</code>, <code>"loopback"</code>, <code>"p2p"</code>, or
  131. -- <code>nil</code> if none of the other types apply.
  132. -- @param interface_name The name of the interface.
  133. -- @return <code>"ethernet"</code>, <code>"loopback"</code>,
  134. -- <code>"p2p"</code>, or <code>nil</code>.
  135. -- @usage iface_type = nmap.get_interface_list("eth0")
  136. function get_interface_link(interface_name)
  137.  
  138. --- Create a mutex on an object.
  139. --
  140. -- This function returns another function that works as a mutex on the object
  141. -- passed. This object can be any Lua data type except <code>nil</code>,
  142. -- Booleans, and numbers. The returned function allows you to lock, try to
  143. -- lock, and release the mutex. The returned function takes only one argument,
  144. -- which must be one of
  145. -- * <code>"lock"</code>: makes a blocking lock on the mutex. If the mutex is busy then the thread will yield and wait. The function returns with the mutex locked.
  146. -- * <code>"trylock"</code>: makes a non-blocking lock on the mutex. If the mutex is busy then it immediately returns with a return value of false. Otherwise, the mutex locks the mutex and returns true.
  147. -- * <code>"done"</code>: releases the mutex and allows another thread to lock it. If the thread does not have a lock on the mutex, an error will be raised.
  148. -- * <code>"running"</code>: returns the thread locked on the mutex or <code>nil</code> if no thread is locked. This should only be used for debugging as it interferes with finished threads from being collected.
  149. -- @param object Object to create a mutex for.
  150. -- @return Mutex function which takes one of the following arguments:
  151. -- <code>"lock"</code>, <code>"trylock"</code>, <code>"done"</code>, or
  152. -- <code>"running"</code>.
  153. -- @usage
  154. -- id = "My Script's Unique ID"
  155. --
  156. -- local mutex = nmap.mutex(id)
  157. -- function action(host, port)
  158. --   mutex "lock"
  159. --   -- do stuff
  160. --   mutex "done"
  161. --   return script_output
  162. -- end
  163. function mutex(object)
  164.  
  165. --- Creates a new exception handler.
  166. --
  167. -- This function returns an exception handler function. The exception handler is
  168. -- meant to be wrapped around other function calls that may raise an exception.
  169. -- A function raises an exception by making its first return value false and its
  170. -- second return value a message describing the error. When an exception occurs,
  171. -- the exception handler optionally calls a user-provided cleanup function, then
  172. -- terminates the script. When an exception does not occur (the wrapped
  173. -- function's first return value is true), the exception handler strips off the
  174. -- first return value and returns the rest.
  175. --
  176. -- The optional cleanup function is passed as the sole argument to
  177. -- <code>new_try</code>. It can be used to release sockets or other resources
  178. -- before the script terminates.
  179. --
  180. -- A function that may raise an exception must follow the return protocol
  181. -- understood by this function: on an exception its return values are false
  182. -- followed by an error message; on success its return values are true followed
  183. -- by any other results.
  184. -- @param handler User cleanup function (optional).
  185. -- @usage
  186. -- local result, socket, try, catch
  187. -- 
  188. -- result = ""
  189. -- socket = nmap.new_socket()
  190. -- catch = function()
  191. --   socket:close()
  192. -- end
  193. -- try = nmap.new_try(catch)
  194. -- try(socket:connect(host.ip, port.number))
  195. -- result = try(socket:receive_lines(1))
  196. -- try(socket:send(result))
  197. function new_try(handler)
  198.  
  199. --- Returns a new NSE socket object.
  200. --
  201. -- To allow for efficient and parallelizable network I/O, NSE provides an
  202. -- interface to Nsock, the Nmap socket library. The smart callback mechanism
  203. -- Nsock uses is fully transparent to NSE scripts. The main benefit of NSE's
  204. -- sockets is that they never block on I/O operations, allowing many scripts to
  205. -- be run in parallel. The I/O parallelism is fully transparent to authors of
  206. -- NSE scripts. In NSE you can either program as if you were using a single
  207. -- non-blocking socket or you can program as if your connection is blocking.
  208. -- Seemingly blocking I/O calls still return once a specified timeout has been
  209. -- exceeded.
  210. --
  211. -- NSE sockets are the recommended way to do network I/O. They support
  212. -- <code>connect</code>-style sending and receiving over TCP and UDP (and SSL),
  213. -- as well as raw socket receiving.
  214. -- @return A new NSE socket.
  215. -- @see pcap_open
  216. -- @usage local socket = nmap.new_socket()
  217. function new_socket()
  218.  
  219. --- Establishes a connection.
  220. --
  221. -- This method puts a socket in a state ready for communication. It takes as
  222. -- arguments a host descriptor (either an IP address or a hostname), a port
  223. -- number and optionally a protocol. The protocol must be one of
  224. -- <code>"tcp"</code>, <code>"udp"</code> or <code>"ssl"</code>; it is
  225. -- <code>"tcp"</code> if not specified.
  226. --
  227. -- On success the function returns true. On failure it returns false and an
  228. -- error string. Those strings are taken from the <code>gai_strerror</code> C
  229. -- function. They are (with the error code in parentheses):
  230. -- * <code>"Address family for hostname not supported"</code> (<code>EAI_ADDRFAMILY</code>)
  231. -- * <code>"Temporary failure in name resolution"</code> (<code>EAI_AGAIN</code>)
  232. -- * <code>"Bad value for ai_flags"</code> (<code>EAI_BADFLAGS</code>)
  233. -- * <code>"Non-recoverable failure in name resolution"</code> (<code>EAI_FAIL</code>)
  234. -- * <code>"ai_family not supported"</code> (<code>EAI_FAMILY</code>)
  235. -- * <code>"Memory allocation failure"</code> (<code>EAI_MEMORY</code>)
  236. -- * <code>"No address associated with hostname"</code> (<code>EAI_NODATA</code>)
  237. -- * <code>"Name or service not known"</code> (<code>EAI_NONAME</code>)
  238. -- * <code>"Servname not supported for ai_socktype"</code> (<code>EAI_SERVICE</code>)
  239. -- * <code>"ai_socktype not supported"</code> (<code>EAI_SOCKTYPE</code>)
  240. -- * <code>"System error"</code> (<code>EAI_SYSTEM</code>)
  241. -- In addition to these standard system error messages there are two
  242. -- NSE-specific errors:
  243. -- * <code>"Sorry, you don't have OpenSSL"</code>: The protocol is <code>"ssl"</code> but but Nmap was compiled without OpenSSL support.
  244. -- * <code>"invalid connection method"</code>: The second parameter is not one of <code>"tcp"</code>, <code>"udp"</code>, and <code>"ssl"</code>.
  245. -- @param hostid Hostname or IP address.
  246. -- @param port Port number.
  247. -- @param protocol <code>"tcp"</code>, <code>"udp"</code>, or
  248. -- <code>"ssl"</code> (default <code>"tcp"</code>).
  249. -- @return Status (true or false).
  250. -- @return Error code (if status is false).
  251. -- @see new_socket
  252. -- @usage local status, err = socket:connect(host.ip, port, "udp")
  253. function connect(hostid, port, protocol)
  254.  
  255. --- Sends data on an open socket.
  256. --
  257. -- This socket method sends the data contained in the data string through an
  258. -- open connection. On success the function returns true. If the send operation
  259. -- has failed, the function returns true along with an error string. The error
  260. -- strings are
  261. -- * <code>"Trying to send through a closed socket"</code>: There was no call to <code>socket:connect</code> before the send operation.
  262. -- * <code>"TIMEOUT"</code>: The operation took longer than the specified timeout for the socket.
  263. -- * <code>"ERROR"</code>: An error occurred inside the underlying Nsock library.
  264. -- * <code>"CANCELLED"</code>: The operation was cancelled.
  265. -- * <code>"KILL"</code>: For example the script scan is aborted due to a faulty script.
  266. -- * <code>"EOF"</code>: An EOF was read (probably will not occur for a send operation).
  267. -- @param data The data to send.
  268. -- @return Status (true or false).
  269. -- @return Error code (if status is false).
  270. -- @see new_socket
  271. -- @usage local status, err = socket:send(data)
  272. function send(data)
  273.  
  274. --- Receives data from an open socket.
  275. --
  276. -- The receive method does a non-blocking receive operation on an open socket.
  277. -- On success the function returns true along with the received data. On
  278. -- failure the function returns false along with an error string. A failure
  279. -- occurs for example if <code>receive</code> is called on a closed socket. The
  280. -- receive call returns to the NSE script all the data currently stored in the
  281. -- receive buffer of the socket. Error conditions are the same as for
  282. -- <code>send</code>.
  283. -- @return Status (true or false).
  284. -- @return Data (if status is true) or error string (if status is false).
  285. -- @see new_socket
  286. -- @usage local status, data = socket:receive()
  287. function receive()
  288.  
  289. --- Receives lines from an open connection.
  290. --
  291. -- Tries to receive at least <code>n</code> lines from an open connection. A
  292. -- line is a string delimited with <code>\n</code> characters.  If no data was
  293. -- was received before the operation times out a <code>"TIMEOUT"</code> error
  294. -- occurs. If even one character was received then it is returned with success.
  295. -- On the other hand, if more than <code>n</code> lines were received, all are
  296. -- returned, not just <code>n</code>. Use <code>stdnse.make_buffer</code> to
  297. -- guarantee only one line is returned per call.
  298. --
  299. -- On success the function returns true along with the received data. If
  300. -- receiving data has failed, the function returns false along with an error
  301. -- string. Error conditions are the same as for <code>send</code>.
  302. -- @param n Minimum number of lines to read.
  303. -- @return Status (true or false).
  304. -- @return Data (if status is true) or error string (if status is false).
  305. -- @see new_socket
  306. -- @usage local status, lines = socket:receive_lines(1)
  307. function receive_lines(n)
  308.  
  309. --- Receives bytes from an open connection.
  310. --
  311. -- Tries to receive at least <code>n</code> bytes from an open connection. Like
  312. -- in <code>receive_lines</code>, <code>n</code> is the minimum amount of
  313. -- characters we would like to receive. If more arrive, we get all of them. If
  314. -- even one is received then it is returned. If no characters arrive before the
  315. -- operation times out, a <code>"TIMEOUT"</code> error occurs.
  316. --
  317. -- On success the function returns true along with the received data. If
  318. -- receiving data has failed, the function returns false along with an error
  319. -- string. Error conditions are the same as for <code>send</code>.
  320. -- @param n Minimum number of bytes to read.
  321. -- @return Status (true or false).
  322. -- @return Data (if status is true) or error string (if status is false).
  323. -- @see new_socket
  324. -- @usage local status, bytes = socket:receive_bytes(1)
  325. function receive_bytes(n)
  326.  
  327. --- Reads from a socket using a buffer and an arbitrary delimiter.
  328. --
  329. -- This method reads data from the network until it encounters the given
  330. -- delimiter string (or matches the function passed in). This function
  331. -- continues to read from the network until the delimiter is found or the
  332. -- function times out.  If data is read beyond the delimiter, that data is
  333. -- saved in a buffer for the next call to <code>receive_buf</code>.  This
  334. -- buffer is cleared on subsequent calls to other Network I/O API functions.
  335. --
  336. -- The first argument may be either a pattern or a function. If a pattern, that
  337. -- pattern is used to separate the data. If a function, it must take exactly
  338. -- one parameter (the buffer) and its return values must be in the same format
  339. -- as those of <code>string.find</code> (offsets to the start and the end of
  340. -- the delimiter inside the buffer, or <code>nil</code> if the delimiter is not
  341. -- found).  The nselib <code>match.lua</code> module provides functions for
  342. -- matching against regular expressions or byte counts. These functions are
  343. -- suitable as arguments to <code>receive_buf</code>.
  344. --
  345. -- The second argument to <code>receive_buf</code> is a Boolean value
  346. -- controlling whether the delimiting string is returned along with the
  347. -- received data (true) or discarded (false).
  348. --
  349. -- On success the function returns true along with the received data. On failure
  350. -- the function returns false along with an error string. Possible error
  351. -- messages are the same as those that the other receive functions can return,
  352. -- with the addition of
  353. -- * <code>"Error inside splitting-function"</code>: The first argument was a function which caused an error while being called.
  354. -- * <code>"Error in string.find (nsockobj:receive_buf)!"</code>: A string was provided as the first argument, and string.find() yielded an error while being called.
  355. -- * <code>"Expected either a function or a string!"</code>: The first argument was neither a function nor a string.
  356. -- * <code>"Delimiter has negative size!"</code>: The returned start offset is greater than the end offset.
  357. -- @param delimiter A Lua pattern or a function with return values like those of
  358. -- <code>string.find</code>.
  359. -- @param keeppattern Whether to return the delimiter string with any returned
  360. -- data.
  361. -- @return Status (true or false).
  362. -- @return Data (if status is true) or error string (if status is false).
  363. -- @see new_socket
  364. -- @usage local status, line = socket:receive_buf("\r?\n", false)
  365. function receive_buf(delimiter, keeppattern)
  366.  
  367. --- Closes an open connection.
  368. --
  369. -- On success the function returns true. If the close fails, the function
  370. -- returns false and an error string. Currently the only error message is
  371. -- <code>"Trying to close a closed socket"</code>, which is issued if the
  372. -- socket has already been closed.
  373. --
  374. -- Sockets are subject to garbage collection. Should you forget to close a
  375. -- socket, it will get closed before it gets deleted (on the next occasion Lua's
  376. -- garbage collector is run). However since garbage collection cycles are
  377. -- difficult to predict, it is considered good practice to close opened sockets.
  378. -- @return Status (true or false).
  379. -- @return Error code (if status is false).
  380. -- @see new_socket
  381. -- @usage socket:close()
  382. function close()
  383.  
  384. --- Gets information about a socket.
  385. --
  386. -- This function returns information about a socket object. It returns five
  387. -- values. If an error occurred, the first value is <code>nil</code> and the
  388. -- second value is an error string. Otherwise the first value is true and the
  389. -- remaining 4 values describe both endpoints of the TCP connection. If you put
  390. -- the call inside an exception handler created by <code>new_try</code> the
  391. -- status value is consumed. The call can be used for example if you want to
  392. -- query an authentication server.
  393. -- @return Status (true or false).
  394. -- @return Local IP address (if status is true) or error string (if status is
  395. -- false).
  396. -- @return Local port number (if status is true).
  397. -- @return Remote IP address (if status is true).
  398. -- @return Remote port number (if status is true).
  399. -- @see new_socket
  400. -- @usage local status, lhost, lport, rhost, rport = socket:get_info()
  401. function get_info()
  402.  
  403. --- Sets a timeout for socket input and output operations.
  404. --
  405. -- After this time, given in milliseconds, socket operations will time out and
  406. -- return. The default value is 30,000 (30 seconds). The lowest allowed value is
  407. -- 10 ms, since this is the granularity of NSE network I/O.
  408. -- @param t Timeout in milliseconds.
  409. -- @see new_socket
  410. -- @usage socket:set_timeout(10000)
  411. function set_timeout(t)
  412.  
  413. --- Opens a socket for raw packet capture.
  414. --
  415. -- The callback function is a function that receives a packet with headers and
  416. -- computes a "packet hash", some value derived from the packet. For example,
  417. -- the callback function could extract the source IP address from a packet. The
  418. -- hash of each packet received is compared against all the strings registered
  419. -- with the <code>pcap_register</code> function.
  420. -- @param device The dnet-style interface name of the device you want to capture
  421. -- from.
  422. -- @param snaplen The length of each packet you want to capture (similar to the
  423. -- <code>-s</code> option to tcpdump)
  424. -- @param promisc Set to 1 if the interface should activate promiscuous mode,
  425. -- and 0 otherwise.
  426. -- @param test_function Callback function used to compute the packet hash.
  427. -- @param bpf A string describing a Berkeley Packet Filter expression (like
  428. -- those provided to tcpdump).
  429. -- @see new_socket, pcap_register, pcap_receive
  430. -- @usage
  431. -- local socket = nmap.new_socket()
  432. -- socket:pcap_open("eth0", 64, 0, callback, "tcp")
  433. function pcap_open(device, snaplen, promisc, test_function, bpf)
  434.  
  435. --- Starts listening for incoming packets.
  436. --
  437. -- The provided <code>packet_hash</code> is a binary string which has to match
  438. -- the hash returned by the <code>test_function</code> parameter provided to
  439. -- <code>pcap_open</code>. If you want to receive all packets, just provide
  440. -- the empty string (<code>""</code>). There has to be a call to
  441. -- <code>pcap_register</code> before a call to <code>pcap_receive</code>.
  442. -- @param packet_hash A binary string that is compared against packet hashes.
  443. -- @see pcap_open, pcap_receive
  444. -- @usage socket:pcap_register("")
  445. function pcap_register(packet_hash)
  446.  
  447. --- Receives a captured packet.
  448. --
  449. -- If an error or timeout occurs, the function returns false and an error
  450. -- message. Otherwise, the function returns true followed by the packet length,
  451. -- the layer two header, and the layer three header.
  452. -- @return Status (true or false).
  453. -- @return The length of the captured packet (this may be smaller than the
  454. -- actual packet length since packets are truncated when the Libpcap snaplen
  455. -- parameter is smaller than the total packet length).
  456. -- @return Data from the second OSI layer (e.g. ethernet headers).
  457. -- @return Data from the third OSI layer (e.g. IPv4 headers).
  458. -- @see pcap_open, pcap_register
  459. -- @usage status, plen, l2_data, l3_data = socket:pcap_receive()
  460. function pcap_receive()
  461.  
  462. --- Closes a pcap device.
  463. -- @see close, pcap_close
  464. -- @usage socket:pcap_close()
  465. function pcap_close()
  466.  
  467. --- Creates a new dnet object, used to send raw packets.
  468. -- @usage local dnet = nmap.new_dnet()
  469. function new_dnet()
  470.  
  471. --- Opens an ethernet interface for raw packet sending.
  472. --
  473. -- An error (<code>"device is not valid ethernet interface"</code>) is thrown
  474. -- in case the provided argument is not valid.
  475. -- @param interface_name The dnet-style name of the interface to open.
  476. -- @see new_dnet
  477. -- @usage dnet:ethernet_open("eth0")
  478. function ethernet_open(interface_name)
  479.  
  480. --- Sends a raw ethernet frame.
  481. --
  482. -- The dnet object must be associated with a previously opened interface. The
  483. -- packet must include the IP and ethernet headers. If there was no previous
  484. -- valid call to <code>ethernet_open</code> an error is thrown
  485. -- (<code>"dnet is not valid opened ethernet interface"</code>).
  486. -- @param packet An ethernet frame to send.
  487. -- @see new_dnet
  488. -- @usage dnet:ethernet_open(packet)
  489. function ethernet_send(packet)
  490.  
  491. --- Closes an ethernet interface.
  492. --
  493. -- An error (<code>"device is not valid ethernet interface"</code>) is thrown
  494. -- in case the provided argument is not valid.
  495. -- @see new_dnet, ethernet_open
  496. -- @usage dnet:ethernet_close()
  497. function ethernet_close()
  498.  
  499. --- Writes to a log file.
  500. --
  501. -- Writes <code>string</code> to <code>file</code> ("stdout" or "stderr").
  502. -- Use stdnse.print_debug to print debug information based on the
  503. -- debugging level.
  504. -- @see stdnse.print_debug
  505. function log_write(file, string)
  506.