NUTSCAN_ADD_IP_RANGE(3)

πŸ’– NUTSCAN_ADD_IP_RANGE β€” bestie's guide to adding an IP range ✨

okay so this one's from the NUT Manual (Network UPS Tools, yes that stands for something, no I will not be normal about it) and it's genuinely so useful. it's nutscan_add_ip_range, a function that takes your IP range and yeets it into a list. slay. let's go 🫢


✨ NAME ✨

nutscan_add_ip_range β€” adds an entry to a nutscan_ip_range_list_t structure, and that entry is an IP address range (so like, a starting address AND an ending address, both of them, together, iconic) πŸ’…


🌸 SYNOPSIS 🌸

#include <nut-scan.h>

/* One IP address range: */
typedef struct nutscan_ip_range_s {
        char * start_ip;
        char * end_ip;
        struct nutscan_ip_range_s * next;
} nutscan_ip_range_t;

/* List of IP address ranges and helper data: */
typedef struct nutscan_ip_range_list_s {
        nutscan_ip_range_t * ip_ranges;         /* Actual linked list of entries, first entry */
        nutscan_ip_range_t * ip_ranges_last;    /* Pointer to end of list for quicker additions */
        size_t ip_ranges_count;                 /* Counter of added entries */
} nutscan_ip_range_list_t;

size_t nutscan_add_ip_range(
        nutscan_ip_range_list_t *irl,
        char * start_ip,
        char * end_ip);

like look at that struct. ip_ranges_last is there so additions stay speedy, and ip_ranges_count is literally just keeping score. main character bookkeeping fr fr πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so nutscan_add_ip_range() can create and add a nutscan_ip_range_t entry, built from the inputs you give it, into the nutscan_ip_range_list_t structure you point it at. the function returns how many entries the structure ends up with β€” or 0 if something non-fatal went sideways 😭

the function skips work (like, just doesn't do the thing) if:

  • the structure pointer is NULL (0 is returned);
  • neither start_ip nor end_ip were provided, i.e. they both have NULL values (the current list length from the structure is returned);
  • it failed to allocate the entry (fatal πŸ’€).

if only one of start_ip or end_ip was provided (i.e. not NULL), then a single-address range gets created with both addresses set to the same pointer value. one address living both lives, we love a versatile icon ✨

the structure should be initialized before use by nutscan_init_ip_ranges().

and β€” this part matters, don't skip it β€” the caller must free the contents of the structure after finishing up, by calling nutscan_free_ip_ranges(). after that the structure can be re-used for a new list πŸŽ€ and if the structure object itself was allocated dynamically (e.g. by calling nutscan_init_ip_ranges(NULL)), you need to explicitly free() that object too. no leaks bestie, we're better than that πŸ™ˆ


🌈 NOTES 🌈

technically, the function is currently defined in nutscan-ip.h file. iykyk πŸ“

currently there are no checks for duplicate or overlapping entries, so the same IP addresses and whole IP address ranges can be added to the list (and would eventually be scanned) many times. not me adding the same range four times and then wondering why the scan takes forever πŸ’€ it's giving "oops". just know that's a real thing that can happen.


πŸ”₯ SEE ALSO πŸ”₯

the whole squad, go read them all, they're cute 🫢


and that's the whole page!! brought to you by Network UPS Tools 2.8.5, dated 06/21/2026 β€” she's serving documentation realness, periodt. go scan responsibly, mwah πŸ’‹β­

πŸ“¦ where this page comes from
  • arch rolling: nut 2.8.5-2 Β· GPL-2.0-or-later AND GPL-3.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms