NAME

nutscan_scan_nut - Scan network for available NUT services.

SYNOPSIS

        #include <nut-scan.h>
        #include <unistd.h> /* useconds_t */

        nutscan_device_t * nutscan_scan_nut(
                const char * startIP,
                const char * stopIP,
                const char * port,
                useconds_t usec_timeout);

        nutscan_device_t * nutscan_scan_ip_range_nut(
                nutscan_ip_range_list_t * irl,
                const char * port,
                useconds_t usec_timeout);

        /* Newer API */
        typedef struct nutscan_nut_authconf {
                const char * authconf_file;     /* where to load authconf data from; "none" means to ignore auth config even if it exists */
                useconds_t usec_timeout;        /* Wait this long for a response */
                const char * port_string;       /* We can pass a port name like "nut" and resolve it inside */

                /* Added for consistency with other structs; not used at the moment;
                 * practically see also `struct nut_scan_arg` in `scan_nut.c`: */
                const char * peername;
                uint16_t port_number;
        } nutscan_nut_authconf_t;

        nutscan_device_t * nutscan_scan_nut_authconf(
                const char * startIP,
                const char * stopIP,
                nutscan_nut_authconf_t *sec);

        nutscan_device_t * nutscan_scan_ip_range_nut_authconf(
                nutscan_ip_range_list_t * irl,
                nutscan_nut_authconf_t *sec);

DESCRIPTION

The nutscan_scan_nut() and nutscan_scan_ip_range_nut() functions try to detect available NUT services and their associated devices. The former issues a NUT request on every IP ranging from startIP to stopIP, where startIP is mandatory and stopIP is optional (one startIP address is scanned if stopIP is NULL); while the latter can walk several IP address ranges represented by a nutscan_ip_range_list_t structure.

Those IP arguments may be either IPv4 or IPv6 addresses or host names.

You MUST call nutscan_init(3) before using this function.

A specific port number may be passed, or NULL to use the default NUT port.

This function waits up to usec_timeout microseconds before considering an IP address does not respond to NUT queries.

RETURN VALUE

The nutscan_scan_nut() function returns a pointer to a nutscan_device_t structure containing all found devices or NULL if an error occurs or no device is found.

SEE ALSO