diff options
| author | Roy Marples <roy@marples.name> | 2019-04-16 18:12:16 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-04-16 18:12:16 +0000 |
| commit | 504b658e5bb3f5c96c57c80d1edb0c107b62e559 (patch) | |
| tree | ce8636e5f4904d6d5fb25a7777889aa9c1e798ad /src/if.c | |
| parent | c1209152039f7fa4fa84958f521948f187e78eae (diff) | |
| download | dhcpcd-504b658e5bb3f5c96c57c80d1edb0c107b62e559.tar.xz | |
if: Add a generic function to create an aliased address name
Reduces complexity between IPv4 and IPv6 and silences a warning
about potential string trunctaion if the LUN makes too big an
interface name.
Diffstat (limited to 'src/if.c')
| -rw-r--r-- | src/if.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -784,6 +784,17 @@ if_cmp(const struct interface *si, const struct interface *ti) return 0; } +#ifdef ALIAS_ADDR +int +if_makealias(char *alias, size_t alias_len, const char *ifname, int lun) +{ + + if (lun == 0) + return strlcpy(alias, ifname, alias_len); + return snprintf(alias, alias_len, "%s:%u", ifname, lun); +} +#endif + /* Sort the interfaces into a preferred order - best first, worst last. */ void if_sortinterfaces(struct dhcpcd_ctx *ctx) |
