1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

sys/net/network_layer/ipv4/addr: add ipv4_addr_print function

This commit is contained in:
Hendrik van Essen 2022-03-13 13:51:12 +01:00 committed by Hendrik van Essen
parent f02bc5791a
commit 6c98a5b3b7
2 changed files with 48 additions and 0 deletions

View File

@ -101,6 +101,13 @@ ipv4_addr_t *ipv4_addr_from_str(ipv4_addr_t *result, const char *addr);
ipv4_addr_t *ipv4_addr_from_buf(ipv4_addr_t *result, const char *addr,
size_t addr_len);
/**
* @brief Print IPv4 address to stdout
*
* @param[in] addr Pointer to ipv6_addr_t to print
*/
void ipv4_addr_print(const ipv4_addr_t *addr);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2022 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for
* more details.
*/
/**
* @{
*
* @file
*
* @author Hendrik van Essen <hendrik.ve@fu-berlin.de>
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "fmt.h"
#include "kernel_defines.h"
#include "net/ipv4/addr.h"
void ipv4_addr_print(const ipv4_addr_t *addr)
{
assert(addr);
char addr_str[IPV4_ADDR_MAX_STR_LEN];
ipv4_addr_to_str(addr_str, addr, sizeof(addr_str));
if (IS_USED(MODULE_FMT)) {
print_str(addr_str);
} else {
printf("%s", addr_str);
}
}
/**
* @}
*/