Line data Source code
1 1 : /*
2 : * Copyright (c) 2023 David Corbeil
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @brief Header file for the network log backend API
10 : * @ingroup log_backend_net
11 : */
12 :
13 : #ifndef ZEPHYR_LOG_BACKEND_NET_H_
14 : #define ZEPHYR_LOG_BACKEND_NET_H_
15 :
16 : /**
17 : * @brief Network log backend API
18 : * @defgroup log_backend_net Network log backend API
19 : * @ingroup log_backend
20 : * @{
21 : */
22 :
23 : #include <stdbool.h>
24 : #include <zephyr/net/net_ip.h>
25 :
26 : #ifdef __cplusplus
27 : extern "C" {
28 : #endif
29 :
30 : /**
31 : * @brief Allows user to set a server IP address, provided as string, at runtime
32 : *
33 : * @details This function allows the user to set an IPv4 or IPv6 address at runtime. It can be
34 : * called either before or after the backend has been initialized. If it gets called when
35 : * the net logger backend context is running, it'll release it and create another one with
36 : * the new address next time process() gets called.
37 : *
38 : * @param addr String that contains the IP address.
39 : *
40 : * @return True if parsing could be done, false otherwise.
41 : */
42 1 : bool log_backend_net_set_addr(const char *addr);
43 :
44 : /**
45 : * @brief Allows user to set a server IP address, provided as sockaddr structure, at runtime
46 : *
47 : * @details This function allows the user to set an IPv4 or IPv6 address at runtime. It can be
48 : * called either before or after the backend has been initialized. If it gets called when
49 : * the net logger backend context is running, it'll release it and create another one with
50 : * the new address next time process() gets called.
51 : *
52 : * @param addr Pointer to the sockaddr structure that contains the IP address.
53 : *
54 : * @return True if address could be set, false otherwise.
55 : */
56 1 : bool log_backend_net_set_ip(const struct sockaddr *addr);
57 :
58 : /**
59 : * @brief update the hostname
60 : *
61 : * @details This function allows to update the hostname displayed by the logging backend. It will be
62 : * called by the network stack if the hostname is set with net_hostname_set().
63 : *
64 : * @param hostname new hostname as char array.
65 : * @param len Length of the hostname array.
66 : */
67 : #if defined(CONFIG_NET_HOSTNAME_ENABLE)
68 : void log_backend_net_hostname_set(const char *hostname, size_t len);
69 : #else
70 1 : static inline void log_backend_net_hostname_set(const char *hostname, size_t len)
71 : {
72 : ARG_UNUSED(hostname);
73 : ARG_UNUSED(len);
74 : }
75 : #endif
76 :
77 : /**
78 : * @brief Get the net logger backend
79 : *
80 : * @details This function returns the net logger backend.
81 : *
82 : * @return Pointer to the net logger backend.
83 : */
84 1 : const struct log_backend *log_backend_net_get(void);
85 :
86 : /**
87 : * @brief Start the net logger backend
88 : *
89 : * @details This function starts the net logger backend.
90 : */
91 1 : void log_backend_net_start(void);
92 :
93 : #ifdef __cplusplus
94 : }
95 : #endif
96 :
97 : /** @} */
98 :
99 : #endif /* ZEPHYR_LOG_BACKEND_NET_H_ */
|