]>
git.proxmox.com Git - mirror_iproute2.git/blob - tipc/misc.c
2 * misc.c Miscellaneous TIPC helper functions.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Richard Alpe <richard.alpe@ericsson.com>
14 #include <linux/tipc.h>
18 #define IN_RANGE(val, low, high) ((val) <= (high) && (val) >= (low))
20 uint32_t str2addr(char *str
)
25 if (sscanf(str
, "%u.%u.%u%c", &z
, &c
, &n
, &dummy
) != 3) {
26 fprintf(stderr
, "invalid network address, syntax: Z.C.N\n");
30 if (IN_RANGE(z
, 0, 255) && IN_RANGE(c
, 0, 4095) && IN_RANGE(n
, 0, 4095))
31 return tipc_addr(z
, c
, n
);
33 fprintf(stderr
, "invalid network address \"%s\"\n", str
);