libdsm  0.0.4-11-g223c1ba
Minimalist and read-only SMB client lib
 All Data Structures Files Functions Typedefs Enumerator Macros
Functions
netbios_ns.h File Reference

Netbios name service. More...

#include <stdint.h>

Functions

const char * netbios_ns_entry_name (netbios_ns_entry *entry)
 Get the name of the entry referenced by the iterator iter. More...
 
const char * netbios_ns_entry_group (netbios_ns_entry *entry)
 Get the name of the entry referenced by the iterator iter. More...
 
uint32_t netbios_ns_entry_ip (netbios_ns_entry *entry)
 Return the IP address of the correspondance referenced by the iterator. More...
 
char netbios_ns_entry_type (netbios_ns_entry *entry)
 Return the type of record. More...
 
netbios_ns * netbios_ns_new ()
 Allocate and initialize the Netbios name service client object. More...
 
void netbios_ns_destroy (netbios_ns *ns)
 Destroy the netbios name service object. More...
 
int netbios_ns_resolve (netbios_ns *ns, const char *name, char type, uint32_t *addr)
 Resolve a Netbios name. More...
 
const char * netbios_ns_inverse (netbios_ns *ns, uint32_t ip)
 Perform an inverse netbios lookup (get name from ip) More...
 
int netbios_ns_discover_start (netbios_ns *ns, unsigned int broadcast_timeout, netbios_ns_discover_callbacks *callbacks)
 Perform a NETBIOS discovery in a separate thread. More...
 
int netbios_ns_discover_stop (netbios_ns *ns)
 Stop the NETBIOS discovery. More...
 

Detailed Description

Netbios name service.

Function Documentation

void netbios_ns_destroy ( netbios_ns *  ns)

Destroy the netbios name service object.

Parameters
[in]nsA pointer on the netbios_ns to destroy and deallocate
int netbios_ns_discover_start ( netbios_ns *  ns,
unsigned int  broadcast_timeout,
netbios_ns_discover_callbacks *  callbacks 
)

Perform a NETBIOS discovery in a separate thread.

This functions starts a new thread that will send a message to '*' Netbios name (broadcast NB query on 255.255.255.255). It'll wait for the machine on the LAN to answer. It'll then perform a reverse lookup on all the ip he received packet from. Once a name and an ip is found, this function will notify the caller by a callback.

Parameters
nsThe name service object.
broadcast_timeoutDo a broadcast every timeout seconds
callbacksThe callbacks previously setup by the caller
Returns
a value > 0 if successfull, or 0 otherwise
int netbios_ns_discover_stop ( netbios_ns *  ns)

Stop the NETBIOS discovery.

Parameters
nsThe name service object.
const char* netbios_ns_entry_group ( netbios_ns_entry *  entry)

Get the name of the entry referenced by the iterator iter.

The pointer points to an area of memory owned by the netbios name service

Returns
A null-terminated ASCII string representing the group of a netbios machine.
uint32_t netbios_ns_entry_ip ( netbios_ns_entry *  entry)

Return the IP address of the correspondance referenced by the iterator.

Returns
The ip address of this entry, in network byte order.
const char* netbios_ns_entry_name ( netbios_ns_entry *  entry)

Get the name of the entry referenced by the iterator iter.

The pointer points to an area of memory owned by the netbios name service

Returns
A null-terminated ASCII string representing the name of a netbios machine.
char netbios_ns_entry_type ( netbios_ns_entry *  entry)

Return the type of record.

Returns
The type of netbios record (.ie 0x20 for FileServer, 0 for workstation, etc.) or a value < 0 if the iterator is invalid or an error occured.
const char* netbios_ns_inverse ( netbios_ns *  ns,
uint32_t  ip 
)

Perform an inverse netbios lookup (get name from ip)

This function does a NBSTAT and stores all the returned entry in the internal list of entries. It returns one of the name found. (Normally the <20> or <0> name)

Parameters
nsThe name service object.
ipThe ip address in network byte order.
Returns
A null-terminated ASCII string containing the NETBIOS name. You don't own the it (it'll be freed when destroying/clearing the name service)
netbios_ns* netbios_ns_new ( )

Allocate and initialize the Netbios name service client object.

Returns
A newly allocated netbios_ns ready for querying. Deallocate with netbios_ns_destroy().
int netbios_ns_resolve ( netbios_ns *  ns,
const char *  name,
char  type,
uint32_t *  addr 
)

Resolve a Netbios name.

This function tries to resolves the given NetBIOS name with the given type on the LAN, using broadcast queries. No WINS server is called.

Parameters
nsthe netbios name service object.
namethe null-terminated ASCII netbios name to resolve. If it's longer than 15 chars, it'll be truncated.
typeThe type of the name to look for.
See also
netbios_defs.h
Parameters
[out]addrThe IP address in network byte order of the machine if found.
Returns
a value > 0 if successfull, or 0 otherwise