Library drda
DRDA Library supporting a very limited subset of operations.
Summary
- The library currently provides functionality to: (1) Query the server for
getServerInfo function of the helper
class. (2) Authenticate to a DB2 server using a plain-text username and
password.
The library contains the following classes:
DRDA
DRDAParameter
DDM
Command
Helper
DB2Socket
StringUtil
Comm
DRDAPacket
The following sample code illustrates how scripts can use the Helper class to interface with the library:
db2helper = drda.Helper:new() status, err = db2helper:connect(host, port) status, res = db2helper:getServerInfo() status, err = db2helper:close()
The implementation is based on packet dumps and the excellent decoding provided by Wireshark.
There is some documentation at http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db29.doc.drda/db2z_drda.htm.
Author:
| "Patrik Karlsson <patrik@cqure.net>" |
Copyright© Same as Nmap--See http://nmap.org/book/man-legal.html
Source: http://nmap.org/svn/nselib/drda.lua
Functions
| __tostring (self) |
Converts the DDM object to a string |
| __tostring (self) |
Converts the DDM object to a string |
| __tostring (self) |
Converts the DDM object to a string |
| ACCRDB (database, rdbaccl, prdid, prddata, typdefnam, crrtkn, typdefovr) |
Builds an ACCRDB DRDA packet |
| ACCSEC (secmec, database) |
Builds an ACCSEC DRDA packet |
| addParameter (self, param) |
Adds a DRDA parameter to the table |
| close (self) |
Closes an open connection. |
| connect (self, host, port) |
Connect to the DB2 host |
| exchDRDAPacket (self, packet) |
Sends a packet to the server and receives the response |
| EXCSAT (extname, srvname, rellev, mgrlvlls, srvclass) |
Builds an EXCSAT DRDA packet |
| fromString (self, str) |
Constructs a DDM object from a string |
| fromString (self, str) |
Constructs a DDM object from a string |
| getData (self) |
Returns the data in EBCDIC format |
| getDataAsASCII (self) |
Returns the data portion of the parameter as an ASCII string |
| getParameter (self, codepoint) |
Gets a parameter from the DRDA parameter table |
| getServerInfo (self) |
Returns Server Information (name, platform, version) |
| isChained (self) |
Verifiers if there are additional DRDA's following |
| login (self, database, username, password) |
Login to DB2 database server |
| new (self, codepoint, format, corelid) |
Creates a new DDM packet |
| new (self, codepoint, format, corelid) |
Creates a new DDM packet |
| padWithChar (str, chr, len) |
Pads a string with a character |
| receive (self, db2socket) |
Receives data from the db2socket and builds a DRDA object |
| SECCHK (secmec, database, username, password) |
Builds a SECCHK DRDA packet |
| send (self, db2socket) |
Sends the DRDA over the db2socket |
| setChained (self, chained) |
Set the DRDA as chained (more following) |
| setDDM (self, ddm) |
Sets the DDM |
| toASCII (ebcdic) |
Converts an EBCDIC string to ASCII |
| toEBCDIC (ascii) |
Converts an ASCII string to EBCDIC |
Functions
- __tostring (self)
-
Converts the DDM object to a string
Parameters
- self:
- __tostring (self)
-
Converts the DDM object to a string
Parameters
- self:
- __tostring (self)
-
Converts the DDM object to a string
Parameters
- self:
- ACCRDB (database, rdbaccl, prdid, prddata, typdefnam, crrtkn, typdefovr)
-
Builds an ACCRDB DRDA packet
Parameters
- database: string containing the database name
- rdbaccl: string containing the RDB access manager class
- prdid: string containing the product id
- prddata:
- typdefnam: string containing the data type definition name
- crrtkn:
- typdefovr: string containing the data type definition override
Return value:
drda DRDA instance - ACCSEC (secmec, database)
-
Builds an ACCSEC DRDA packet
Parameters
- secmec: number containing the security mechanism ID
- database: string containing the database name
Return value:
drda DRDA instance - addParameter (self, param)
-
Adds a DRDA parameter to the table
Parameters
- self:
- param: DRDAParam containing the parameter to add to the table
Return values:
- status bool true on success, false on failure
- err string containing the error message if status is false
- close (self)
-
Closes an open connection.
Parameters
- self:
Return values:
- Status (true or false).
- Error code (if status is false).
- connect (self, host, port)
-
Connect to the DB2 host
Parameters
- self:
- host: table
- port: table
Return values:
- Status (true or false).
- Error code (if status is false).
- exchDRDAPacket (self, packet)
-
Sends a packet to the server and receives the response
Parameters
- self:
- packet:
Return values:
- status true on success, false on failure
- packet an instance of DRDAPacket
- EXCSAT (extname, srvname, rellev, mgrlvlls, srvclass)
-
Builds an EXCSAT DRDA packet
Parameters
- extname: string containing the external name
- srvname: string containing the server name
- rellev: string containing the server product release level
- mgrlvlls: string containing the manager level list
- srvclass: string containing the server class name
Return value:
drda DRDA instance - fromString (self, str)
-
Constructs a DDM object from a string
Parameters
- self:
- str: containing the data from which to construct the object
- fromString (self, str)
-
Constructs a DDM object from a string
Parameters
- self:
- str: containing the data from which to construct the object
- getData (self)
-
Returns the data in EBCDIC format
Parameters
- self:
Return value:
str containing the data portion of the DRDA parameter in EBCDIC - getDataAsASCII (self)
-
Returns the data portion of the parameter as an ASCII string
Parameters
- self:
Return value:
str containing the data portion of the DRDA parameter as ASCII - getParameter (self, codepoint)
-
Gets a parameter from the DRDA parameter table
Parameters
- self:
- codepoint: number containing the parameter type ro retrieve
Return value:
param DRDAParameter containing the requested parameter - getServerInfo (self)
-
Returns Server Information (name, platform, version)
Parameters
- self:
Return value:
table containingextname,srvclass,srvnameandprodrel - isChained (self)
-
Verifiers if there are additional DRDA's following
Parameters
- self:
Return value:
true if the DRDA is to be chained, false if it's the last one - login (self, database, username, password)
-
Login to DB2 database server
Parameters
- self:
- database: containing the name of the database
- username: containing the authentication username
- password: containing the authentication password
Return values:
- Status (true or false)
- err message (if status if false)
- new (self, codepoint, format, corelid)
-
Creates a new DDM packet
Parameters
- self:
- codepoint:
- format:
- corelid:
Return value:
DDM object - new (self, codepoint, format, corelid)
-
Creates a new DDM packet
Parameters
- self:
- codepoint:
- format:
- corelid:
Return value:
DDM object - padWithChar (str, chr, len)
-
Pads a string with a character
Parameters
- str: string to pad
- chr: char to pad with
- len: the total length of the finnished string
Return value:
str string containing the padded string - receive (self, db2socket)
-
Receives data from the db2socket and builds a DRDA object
Parameters
- self:
- db2socket: from which to read data
Return values:
- Status (true or false).
- Data (if status is true) or error string (if status is false).
- SECCHK (secmec, database, username, password)
-
Builds a SECCHK DRDA packet
Parameters
- secmec: number containing the security mechanism ID
- database: string containing the database name
- username: string
- password: string
Return value:
drda DRDA instance - send (self, db2socket)
-
Sends the DRDA over the db2socket
Parameters
- self:
- db2socket: DB2Socket over which to send the data
Return values:
- Status (true or false).
- Error code (if status is false).
- setChained (self, chained)
-
Set the DRDA as chained (more following)
Parameters
- self:
- chained: boolean true if more DRDA's are following
- setDDM (self, ddm)
-
Sets the DDM
Parameters
- self:
- ddm: DDM to assign to the DRDA
Return value:
status boolean true on success, false on failure - toASCII (ebcdic)
-
Converts an EBCDIC string to ASCII
Parameters
- ebcdic: string containing EBCDIC value
Return value:
string containing ASCII value - toEBCDIC (ascii)
-
Converts an ASCII string to EBCDIC
Parameters
- ascii: string containing the ASCII value
Return value:
string containing the EBCDIC value


