Library nbd
An implementation of the Network Block Device protocol. https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md
Author:
Copyright © Same as Nmap--See https://nmap.org/book/man-legal.html
Source: https://svn.nmap.org/nmap/nselib/nbd.lua
Functions
- Comm.attach (self, name)
Attaches to an named share on the server.
- Comm.build_opt_req (self, name, options)
Builds an option request.
- Comm.close (self)
Disconnects from the server.
- Comm.connect (self)
Connects to the NBD server.
- Comm.connect_new (self, len)
Continue in-progress newstyle handshake with server.
- Comm.connect_old (self)
Continue in-progress oldstyle handshake with server.
- Comm.new (self, host, port)
Creates a new client instance.
- Comm.parse_opt_rep (self, buf, rep)
Parses an option reply.
- Comm.parse_transmission_flags (self, flags)
Parses the transmission flags describing an export.
- Comm.receive (self, len)
Receives data from the server.
- Comm.receive_opt_rep (self)
Receives an option reply.
- Comm.reconnect (self)
Cycles the connection to the server.
- Comm.send (self, data, pkt)
Sends data to the server
- find_key (tbl, val)
Finds a key corresponding with a value.
Functions
- Comm.attach (self, name)
-
Attaches to an named share on the server.
Parameters
- self
- name
Return value:
status true on success, false on failure. - Comm.build_opt_req (self, name, options)
-
Builds an option request.
Parameters
- self
- name
- String naming the option type.
- options
- Table containing options.
Return value:
req String representing the option request. - Comm.close (self)
-
Disconnects from the server.
Parameters
- self
- Comm.connect (self)
-
Connects to the NBD server.
Parameters
- self
Return value:
status true on success, false on failure. - Comm.connect_new (self, len)
-
Continue in-progress newstyle handshake with server.
Parameters
- self
- len
- Number of bytes to receive.
Return values:
- status True on success, false on failure.
- response String representing bytes received on success, string containing the error message on failure.
- Comm.connect_old (self)
-
Continue in-progress oldstyle handshake with server.
Parameters
- self
Return value:
response String representing bytes received on success, string containing the error message on failure. - Comm.new (self, host, port)
-
Creates a new client instance.
Parameters
- self
- host
- Table as received by the action method.
- port
- Table as received by the action method.
Return value:
o Instance of Client. - Comm.parse_opt_rep (self, buf, rep)
-
Parses an option reply.
Parameters
- self
- buf
- String to be parsed.
- rep
- Table representing the fields of the reply that have already been parsed by the caller.
Return value:
reply Table representing option reply on success, false on failure. - Comm.parse_transmission_flags (self, flags)
-
Parses the transmission flags describing an export.
Parameters
- self
- flags
- Transmission flags sent by server.
Return value:
Table of parsed flags as keys. - Comm.receive (self, len)
-
Receives data from the server.
Parameters
- self
- len
- Number of bytes to receive.
Return values:
- status True on success, false on failure.
- response String representing bytes received on success, string containing the error message on failure.
- Comm.receive_opt_rep (self)
-
Receives an option reply.
Parameters
- self
Return value:
reply Table representing option reply on success, false on failure. - Comm.reconnect (self)
-
Cycles the connection to the server.
Parameters
- self
Return value:
status true on success, false on failure. - Comm.send (self, data, pkt)
-
Sends data to the server
Parameters
- self
- data
- pkt
- String containing the bytes to send.
Return values:
- status true on success, false on failure.
- err string containing the error message on failure.
- find_key (tbl, val)
-
Finds a key corresponding with a value.
Parameters
- tbl
- Table in which to search.
- val
- Value to search for.
Return value:
key String on success, nil on failure