77#include "eth.h"
88
99#include <zephyr/kernel.h>
10- #include <zephyr/logging/log.h>
1110#include <zephyr/net/ethernet.h>
1211#include <zephyr/net/ethernet_mgmt.h>
12+ #include <zephyr/version.h>
13+
14+ #include <zephyr/logging/log.h>
1315LOG_MODULE_REGISTER (eth , CONFIG_APP_LOG_LEVEL ); // NOLINT
1416
1517/************************************************
@@ -30,8 +32,13 @@ static K_SEM_DEFINE(ipv4_address_obtained, 0, 1);
3032 * Callbacks declaration/definition *
3133 ***********************************************/
3234
35+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
36+ static void eth_mgmt_event_handler (
37+ struct net_mgmt_event_callback * event_cb , uint64_t mgmt_event , struct net_if * iface )
38+ #else
3339static void eth_mgmt_event_handler (
3440 struct net_mgmt_event_callback * event_cb , uint32_t mgmt_event , struct net_if * iface )
41+ #endif
3542{
3643 (void ) event_cb ;
3744 (void ) iface ;
@@ -55,14 +62,23 @@ static void eth_mgmt_event_handler(
5562 break ;
5663
5764 default :
65+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
66+ LOG_DBG ("Status network event: %lld." , mgmt_event ); // NOLINT
67+ #else
5868 LOG_DBG ("Status network event: %d." , mgmt_event ); // NOLINT
69+ #endif
5970 break ;
6071 }
6172 // NOLINTEND(hicpp-signed-bitwise)
6273}
6374
75+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
76+ static void status_mgmt_event_handler (
77+ struct net_mgmt_event_callback * event_cb , uint64_t mgmt_event , struct net_if * iface )
78+ #else
6479static void status_mgmt_event_handler (
6580 struct net_mgmt_event_callback * event_cb , uint32_t mgmt_event , struct net_if * iface )
81+ #endif
6682{
6783 (void ) event_cb ;
6884 (void ) iface ;
@@ -86,20 +102,30 @@ static void status_mgmt_event_handler(
86102 break ;
87103
88104 default :
105+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
106+ LOG_DBG ("Status network event: %lld." , mgmt_event ); // NOLINT
107+ #else
89108 LOG_DBG ("Status network event: %d." , mgmt_event ); // NOLINT
109+ #endif
90110 break ;
91111 }
92112 // NOLINTEND(hicpp-signed-bitwise)
93113}
94114
115+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
116+ static void ipv6_mgmt_event_handler (
117+ struct net_mgmt_event_callback * event_cb , uint64_t mgmt_event , struct net_if * iface )
118+ #else
95119static void ipv6_mgmt_event_handler (
96120 struct net_mgmt_event_callback * event_cb , uint32_t mgmt_event , struct net_if * iface )
121+ #endif
97122{
98123 (void ) event_cb ;
99124 (void ) iface ;
100125
101126 // NOLINTBEGIN(hicpp-signed-bitwise)
102127 switch (mgmt_event ) {
128+
103129 case NET_EVENT_IPV6_ADDR_ADD :
104130 LOG_DBG ("IPv6 network event: NET_EVENT_IPV6_ADDR_ADD." ); // NOLINT
105131 break ;
@@ -177,20 +203,30 @@ static void ipv6_mgmt_event_handler(
177203 break ;
178204
179205 default :
206+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
207+ LOG_DBG ("IPv6 network event: %lld." , mgmt_event ); // NOLINT
208+ #else
180209 LOG_DBG ("IPv6 network event: %d." , mgmt_event ); // NOLINT
210+ #endif
181211 break ;
182212 }
183213 // NOLINTEND(hicpp-signed-bitwise)
184214}
185215
216+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
217+ static void ipv4_mgmt_event_handler (
218+ struct net_mgmt_event_callback * event_cb , uint64_t mgmt_event , struct net_if * iface )
219+ #else
186220static void ipv4_mgmt_event_handler (
187221 struct net_mgmt_event_callback * event_cb , uint32_t mgmt_event , struct net_if * iface )
222+ #endif
188223{
189224 (void ) event_cb ;
190225 (void ) iface ;
191226
192227 // NOLINTBEGIN(hicpp-signed-bitwise)
193228 switch (mgmt_event ) {
229+
194230 case NET_EVENT_IPV4_ADDR_ADD :
195231 LOG_DBG ("Network event: NET_EVENT_IPV4_ADDR_ADD." ); // NOLINT
196232 k_sem_give (& ipv4_address_obtained );
@@ -238,20 +274,30 @@ static void ipv4_mgmt_event_handler(
238274 break ;
239275
240276 default :
277+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
278+ LOG_DBG ("Network event: %lld." , mgmt_event ); // NOLINT
279+ #else
241280 LOG_DBG ("Network event: %d." , mgmt_event ); // NOLINT
281+ #endif
242282 break ;
243283 }
244284 // NOLINTEND(hicpp-signed-bitwise)
245285}
246286
287+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
288+ static void l4_mgmt_event_handler (
289+ struct net_mgmt_event_callback * event_cb , uint64_t mgmt_event , struct net_if * iface )
290+ #else
247291static void l4_mgmt_event_handler (
248292 struct net_mgmt_event_callback * event_cb , uint32_t mgmt_event , struct net_if * iface )
293+ #endif
249294{
250295 (void ) event_cb ;
251296 (void ) iface ;
252297
253298 // NOLINTBEGIN(hicpp-signed-bitwise)
254299 switch (mgmt_event ) {
300+
255301 case NET_EVENT_L4_CONNECTED :
256302 LOG_DBG ("Network event: NET_EVENT_L4_CONNECTED." ); // NOLINT
257303 break ;
@@ -273,7 +319,11 @@ static void l4_mgmt_event_handler(
273319 break ;
274320
275321 default :
322+ #if (KERNEL_VERSION_MAJOR >= 4 ) && (KERNEL_VERSION_MINOR >= 2 )
323+ LOG_DBG ("Network event: %lld." , mgmt_event ); // NOLINT
324+ #else
276325 LOG_DBG ("Network event: %d." , mgmt_event ); // NOLINT
326+ #endif
277327 break ;
278328 }
279329 // NOLINTEND(hicpp-signed-bitwise)
0 commit comments