Library srvloc

A relatively small implementation of the Service Location Protocol. It was initially designed to support requests for discovering Novell NCP servers, but should work for any other service as well.

The implementation is based on the following classes:

  • Request.Service - Contains necessary code to produce a service request

  • Request.Attributes - Contains necessary code to produce a attribute request

  • Reply.Service - Contains necessary code to process and parse the response to the service request

  • Reply.Attributes - Contains necessary code to process and parse the response to the attribute request

The following code illustrates intended use of the library:

   local helper = srvloc.Helper:new()
   local status, tree = helper:ServiceRequest("ndap.novell", "DEFAULT")
   if ( status ) then tree = tree:match("%/%/%/(.*)%.$") end
 

Source: https://svn.nmap.org/nmap/nselib/srvloc.lua

Functions

__tostring (self)

"Serializes" the request to a string

__tostring (self)

"Serializes" the request to a string

AttributeRequest (self, url, scope, taglist)

Requests an attribute from the server

fromSocket (socket)

Attempts to create an instance by reading data off the socket

fromSocket (socket)

Attempts to create an instance by reading data off the socket

getAttribList (self)

Gets the attribute list

getUrl (self)

Gets the url value from the reply

new (self)

Creates a new instance of the Service request

new (self)

Creates a new instance of the Service request

new (self)

Creates a new instance of the Service request

new (self)

Creates a new instance of the Service request

parse (self, data)

Parses the service reply raw packet data

parse (self, data)

Parses the service reply raw packet data

ServiceRequest (self, srvtype, scope)

Sends a service request and waits for the response

setFlags (self, flags)

Sets the request flags

setFlags (self, flags)

Sets the request flags

setFunction (self, func)

Sets the request function

setFunction (self, func)

Sets the request function

setLangTag (self, lang)

Sets the language tag

setLangTag (self, lang)

Sets the language tag

setScope (self, scope)

Sets the request scope

setScope (self, scope)

Sets the request scope

setServiceType (self, t)

Sets the service type of the request

setTagList (self, tl)

Sets the request taglist

setUrl (self, u)

Sets the request url

setXID (self, xid)

Sets the request XID

setXID (self, xid)

Sets the request XID

Functions

__tostring (self)

"Serializes" the request to a string

Parameters

self
 

Return value:

data string containing a string representation of the request
__tostring (self)

"Serializes" the request to a string

Parameters

self
 

Return value:

data string containing a string representation of the request
AttributeRequest (self, url, scope, taglist)

Requests an attribute from the server

Parameters

self
 
url
as retrieved by the Service request
scope
string containing the request scope
taglist
string containing the request tag list
fromSocket (socket)

Attempts to create an instance by reading data off the socket

Parameters

socket
socket connected to the SRVLOC service

Return value:

new instance of the Reply.Attribute class
fromSocket (socket)

Attempts to create an instance by reading data off the socket

Parameters

socket
socket connected to the SRVLOC service

Return value:

new instance of the Reply.Attribute class
getAttribList (self)

Gets the attribute list

Parameters

self
 

Return value:

attrib_list
getUrl (self)

Gets the url value from the reply

Parameters

self
 

Return value:

uri string containing the reply url
new (self)

Creates a new instance of the Service request

Parameters

self
 

Return value:

o instance of Service
new (self)

Creates a new instance of the Service request

Parameters

self
 

Return value:

o instance of Service
new (self)

Creates a new instance of the Service request

Parameters

self
 

Return value:

o instance of Service
new (self)

Creates a new instance of the Service request

Parameters

self
 

Return value:

o instance of Service
parse (self, data)

Parses the service reply raw packet data

Parameters

self
 
data
string containing the raw reply as read from the socket
parse (self, data)

Parses the service reply raw packet data

Parameters

self
 
data
string containing the raw reply as read from the socket
ServiceRequest (self, srvtype, scope)

Sends a service request and waits for the response

Parameters

self
 
srvtype
string containing the service type to query
scope
string containing the scope of the request

Return values:

  1. true on success, false on failure
  2. url string (on success) containing the url of the ServiceReply
  3. err string (on failure) containing the error message
setFlags (self, flags)

Sets the request flags

Parameters

self
 
flags
number containing the numeric flag representation
setFlags (self, flags)

Sets the request flags

Parameters

self
 
flags
number containing the numeric flag representation
setFunction (self, func)

Sets the request function

Parameters

self
 
func
number containing the request function number
setFunction (self, func)

Sets the request function

Parameters

self
 
func
number containing the request function number
setLangTag (self, lang)

Sets the language tag

Parameters

self
 
lang
string containing the language
setLangTag (self, lang)

Sets the language tag

Parameters

self
 
lang
string containing the language
setScope (self, scope)

Sets the request scope

Parameters

self
 
scope
string containing the request scope
setScope (self, scope)

Sets the request scope

Parameters

self
 
scope
string containing the request scope
setServiceType (self, t)

Sets the service type of the request

Parameters

self
 
t
string containing the type of the request
setTagList (self, tl)

Sets the request taglist

Parameters

self
 
tl
string containing the taglist
setUrl (self, u)

Sets the request url

Parameters

self
 
u
string containing the url
setXID (self, xid)

Sets the request XID

Parameters

self
 
xid
number containing the request XID
setXID (self, xid)

Sets the request XID

Parameters

self
 
xid
number containing the request XID