diff options
author | Adriano Cordova <adrianox@gmail.com> | 2024-11-11 18:09:45 -0300 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2024-11-18 16:12:35 +0100 |
commit | 9063dba2d326e07682338cdb636787e99f1bf3f5 (patch) | |
tree | 2013532b61da4c9903fea97a89e1d406dd01efa9 /lib/net_utils.c | |
parent | 1327c2a8d6514d4abfa3642ce338fed50b811b21 (diff) |
net: net_utils: Move ip_to_string to lib/net_utils.c
The function string_to_ip is already in net_utils, which is
compiled unconditionally, but ip_to_string is currently only
accessible if the legacy network stack is selected. This
commit puts ip_to_string in net_utils.c and removes it from the
legacy network code.
Signed-off-by: Adriano Cordova <adrianox@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib/net_utils.c')
-rw-r--r-- | lib/net_utils.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/net_utils.c b/lib/net_utils.c index c70fef0d991..621f6512b62 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -152,6 +152,17 @@ out_err: } #endif +void ip_to_string(struct in_addr x, char *s) +{ + x.s_addr = ntohl(x.s_addr); + sprintf(s, "%d.%d.%d.%d", + (int) ((x.s_addr >> 24) & 0xff), + (int) ((x.s_addr >> 16) & 0xff), + (int) ((x.s_addr >> 8) & 0xff), + (int) ((x.s_addr >> 0) & 0xff) + ); +} + void string_to_enetaddr(const char *addr, uint8_t *enetaddr) { char *end; |