libdsm 0.4.3
Minimalist and read-only SMB client lib
Loading...
Searching...
No Matches
Functions
netbios_ns.h File Reference

Netbios name service. More...

#include <stdint.h>
#include "bdsm/export.h"

Functions

BDSM_EXPORT const char * netbios_ns_entry_name (netbios_ns_entry *entry)
 Get the name of the entry referenced by the iterator iter. More...
 
BDSM_EXPORT const char * netbios_ns_entry_group (netbios_ns_entry *entry)
 Get the name of the entry referenced by the iterator iter. More...
 
BDSM_EXPORT uint32_t netbios_ns_entry_ip (netbios_ns_entry *entry)
 Return the IP address of the correspondance referenced by the iterator. More...
 
BDSM_EXPORT char netbios_ns_entry_type (netbios_ns_entry *entry)
 Return the type of record. More...
 
BDSM_EXPORT netbios_ns * netbios_ns_new ()
 Allocate and initialize the Netbios name service client object. More...
 
BDSM_EXPORT void netbios_ns_destroy (netbios_ns *ns)
 Destroy the netbios name service object. More...
 
BDSM_EXPORT void netbios_ns_abort (netbios_ns *ns)
 Interrupt any I/O netbios_ns functions (netbios_ns_resolve, netbios_ns_inverse...) More...
 
BDSM_EXPORT int netbios_ns_resolve (netbios_ns *ns, const char *name, char type, uint32_t *addr)
 Resolve a Netbios name. More...
 
BDSM_EXPORT const char * netbios_ns_inverse (netbios_ns *ns, uint32_t ip)
 Perform an inverse netbios lookup (get name from ip) More...
 
BDSM_EXPORT 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...
 
BDSM_EXPORT int netbios_ns_discover_stop (netbios_ns *ns)
 Stop the NETBIOS discovery. More...
 

Detailed Description

Netbios name service.

Function Documentation

◆ netbios_ns_abort()

BDSM_EXPORT void netbios_ns_abort ( netbios_ns *  ns)

Interrupt any I/O netbios_ns functions (netbios_ns_resolve, netbios_ns_inverse...)

This function can be called from any threads. The ns object is unusable after this call, only netbios_ns_destroy() should be called after.

Parameters
nsthe netbios name service object to abort

◆ netbios_ns_destroy()

BDSM_EXPORT 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

◆ netbios_ns_discover_start()

BDSM_EXPORT 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
0 on success or -1 on failure

◆ netbios_ns_discover_stop()

BDSM_EXPORT int netbios_ns_discover_stop ( netbios_ns *  ns)

Stop the NETBIOS discovery.

Parameters
nsThe name service object.
Returns
0 on success or -1 on failure

◆ netbios_ns_entry_group()

BDSM_EXPORT 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.

◆ netbios_ns_entry_ip()

BDSM_EXPORT 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.

◆ netbios_ns_entry_name()

BDSM_EXPORT 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.

◆ netbios_ns_entry_type()

BDSM_EXPORT 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.

◆ netbios_ns_inverse()

BDSM_EXPORT 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_new()

BDSM_EXPORT 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().

◆ netbios_ns_resolve()

BDSM_EXPORT 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
0 on success or -1 on failure