Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
net_if.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
11
12#ifndef ZEPHYR_INCLUDE_NET_NET_IF_H_
13#define ZEPHYR_INCLUDE_NET_NET_IF_H_
14
23
24#include <zephyr/device.h>
25#include <zephyr/sys/slist.h>
27#include <zephyr/net/net_core.h>
28#include <zephyr/net/hostname.h>
30#include <zephyr/net/net_ip.h>
31#include <zephyr/net/net_l2.h>
34
35#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
36#include <zephyr/net/dhcpv4.h>
37#endif
38#if defined(CONFIG_NET_DHCPV6) && defined(CONFIG_NET_NATIVE_IPV6)
39#include <zephyr/net/dhcpv6.h>
40#endif
41#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
43#endif
44
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
58 struct net_addr address;
59
64
65#if defined(CONFIG_NET_NATIVE_IPV6)
66 struct net_timeout lifetime;
67#endif
68
71
74
75#if defined(CONFIG_NET_NATIVE_IPV6)
76#if defined(CONFIG_NET_IPV6_PE)
80 uint32_t addr_create_time;
81
84 uint32_t addr_preferred_lifetime;
85
90 int32_t addr_timeout;
91#endif
92#endif /* CONFIG_NET_NATIVE_IPV6 */
93
94 union {
95#if defined(CONFIG_NET_IPV6_DAD)
96 struct {
98 sys_snode_t dad_node;
99
101 sys_snode_t dad_need_node;
102
104 uint32_t dad_start;
105
107 uint8_t dad_count;
108 };
109#endif /* CONFIG_NET_IPV6_DAD */
110#if defined(CONFIG_NET_IPV4_ACD)
111 struct {
113 sys_snode_t acd_node;
114
116 sys_snode_t acd_need_node;
117
119 k_timepoint_t acd_timeout;
120
122 uint8_t acd_count;
123
125 uint8_t acd_state;
126 };
127#endif /* CONFIG_NET_IPV4_ACD */
128 uint8_t _dummy;
129 };
130
131#if defined(CONFIG_NET_IPV6_DAD) || defined(CONFIG_NET_IPV4_ACD)
133 uint8_t ifindex;
134#endif
135
138
141
144
149
152
153 uint8_t _unused : 3;
154};
155
163 struct net_addr address;
164
169
172
173#if defined(CONFIG_NET_IPV4_IGMPV3)
175 struct net_addr sources[CONFIG_NET_IF_MCAST_IPV4_SOURCE_COUNT];
176
178 uint16_t sources_len;
179
181 uint8_t record_type;
182#endif
183
186
189
190 uint8_t _unused : 6;
191};
192
201
204
206 struct net_if *iface;
207
210
213
216
217 uint8_t _unused : 6;
218};
219
228
230 struct net_addr address;
231
233 struct net_if *iface;
234
237
240
243
246
249
250 uint8_t _unused : 5;
251};
252
308
319
320#if defined(CONFIG_NET_OFFLOAD)
321struct net_offload;
322#endif /* CONFIG_NET_OFFLOAD */
323
325#if defined(CONFIG_NET_IPV6)
326#define NET_IF_MAX_IPV6_ADDR CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT
327#define NET_IF_MAX_IPV6_MADDR CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT
328#define NET_IF_MAX_IPV6_PREFIX CONFIG_NET_IF_IPV6_PREFIX_COUNT
329#else
330#define NET_IF_MAX_IPV6_ADDR 0
331#define NET_IF_MAX_IPV6_MADDR 0
332#define NET_IF_MAX_IPV6_PREFIX 0
333#endif
334/* @endcond */
335
339 struct net_if_addr unicast[NET_IF_MAX_IPV6_ADDR];
340
342 struct net_if_mcast_addr mcast[NET_IF_MAX_IPV6_MADDR];
343
345 struct net_if_ipv6_prefix prefix[NET_IF_MAX_IPV6_PREFIX];
346
349
352
355
356#if defined(CONFIG_NET_IPV6_IID_STABLE)
358 struct net_if_addr *iid;
359
363 uint32_t network_counter;
364#endif /* CONFIG_NET_IPV6_IID_STABLE */
365
366#if defined(CONFIG_NET_IPV6_PE)
371 uint32_t desync_factor;
372#endif /* CONFIG_NET_IPV6_PE */
373
374#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
376 sys_snode_t rs_node;
377
378 /* RS start time */
379 uint32_t rs_start;
380
382 uint8_t rs_count;
383#endif
384
387
390};
391
392#if defined(CONFIG_NET_DHCPV6) && defined(CONFIG_NET_NATIVE_IPV6)
394struct net_if_dhcpv6 {
396 sys_snode_t node;
397
399 struct net_dhcpv6_duid_storage clientid;
400
402 struct net_dhcpv6_duid_storage serverid;
403
405 enum net_dhcpv6_state state;
406
408 struct net_dhcpv6_params params;
409
411 uint64_t timeout;
412
414 uint64_t exchange_start;
415
417 uint64_t t1;
418
420 uint64_t t2;
421
425 uint64_t expire;
426
428 uint32_t addr_iaid;
429
431 uint32_t prefix_iaid;
432
434 uint32_t retransmit_timeout;
435
437 uint32_t sol_max_rt;
438
440 uint32_t inf_max_rt;
441
445 uint32_t info_refresh_time;
446
448 int16_t server_preference;
449
451 uint8_t retransmissions;
452
454 uint8_t tid[DHCPV6_TID_SIZE];
455
457 uint8_t prefix_len;
458
460 struct net_in6_addr prefix;
461
463 struct net_in6_addr addr;
464};
465#endif /* defined(CONFIG_NET_DHCPV6) && defined(CONFIG_NET_NATIVE_IPV6) */
466
468#if defined(CONFIG_NET_IPV4)
469#define NET_IF_MAX_IPV4_ADDR CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT
470#define NET_IF_MAX_IPV4_MADDR CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT
471#else
472#define NET_IF_MAX_IPV4_ADDR 0
473#define NET_IF_MAX_IPV4_MADDR 0
474#endif
476
488
492 struct net_if_addr_ipv4 unicast[NET_IF_MAX_IPV4_ADDR];
493
495 struct net_if_mcast_addr mcast[NET_IF_MAX_IPV4_MADDR];
496
499
502
505
506#if defined(CONFIG_NET_IPV4_ACD)
508 uint8_t conflict_cnt;
509#endif
510};
511
512#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
513struct net_if_dhcpv4 {
515 sys_snode_t node;
516
518 int64_t timer_start;
519
521 uint32_t request_time;
522
523 uint32_t xid;
524
526 uint32_t lease_time;
527
529 uint32_t renewal_time;
530
532 uint32_t rebinding_time;
533
535 struct net_in_addr server_id;
536
538 struct net_in_addr requested_ip;
539
541 struct net_in_addr netmask;
542
547 enum net_dhcpv4_state state;
548
550 uint8_t attempts;
551
553 struct net_in_addr request_server_addr;
554
556 struct net_in_addr response_src_addr;
557
558#ifdef CONFIG_NET_DHCPV4_OPTION_NTP_SERVER
560 struct net_in_addr ntp_addr;
561#endif
562};
563#endif /* CONFIG_NET_DHCPV4 */
564
565#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
566struct net_if_ipv4_autoconf {
568 struct net_if *iface;
569
571 struct net_in_addr requested_ip;
572
576};
577#endif /* CONFIG_NET_IPV4_AUTO */
578
582struct net_if_ip {
583#if defined(CONFIG_NET_IPV6)
584 struct net_if_ipv6 *ipv6;
585#endif /* CONFIG_NET_IPV6 */
586
587#if defined(CONFIG_NET_IPV4)
588 struct net_if_ipv4 *ipv4;
589#endif /* CONFIG_NET_IPV4 */
590};
591
596#if defined(CONFIG_NET_IP)
598 struct net_if_ip ip;
599#endif
600
601#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
602 struct net_if_dhcpv4 dhcpv4;
603#endif /* CONFIG_NET_DHCPV4 */
604
605#if defined(CONFIG_NET_DHCPV6) && defined(CONFIG_NET_NATIVE_IPV6)
606 struct net_if_dhcpv6 dhcpv6;
607#endif /* CONFIG_NET_DHCPV6 */
608
609#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
610 struct net_if_ipv4_autoconf ipv4auto;
611#endif /* CONFIG_NET_IPV4_AUTO */
612
613#if defined(CONFIG_NET_L2_VIRTUAL)
618 sys_slist_t virtual_interfaces;
619#endif /* CONFIG_NET_L2_VIRTUAL */
620
621#if defined(CONFIG_NET_INTERFACE_NAME)
626 char name[CONFIG_NET_INTERFACE_NAME_LEN + 1];
627#endif
628};
629
641 struct k_fifo fifo;
642
643#if NET_TC_COUNT > 1 || defined(CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO) \
644 || defined(CONFIG_NET_TC_RX_SKIP_FOR_HIGH_PRIO)
646 struct k_sem fifo_slot;
647#endif
648
651
654};
655
662typedef int (*net_socket_create_t)(int, int, int);
663
685 const struct device *dev;
686
688 const struct net_l2 * const l2;
689
691 void *l2_data;
692
694 ATOMIC_DEFINE(flags, NET_IF_NUM_FLAGS);
695
697 struct net_linkaddr link_addr;
698
699#if defined(CONFIG_NET_OFFLOAD)
705 struct net_offload *offload;
706#endif /* CONFIG_NET_OFFLOAD */
707
709 uint16_t mtu;
710
711#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
715 net_socket_create_t socket_offload;
716#endif /* CONFIG_NET_SOCKETS_OFFLOAD */
717
719 enum net_if_oper_state oper_state;
720
730 int64_t oper_state_change_time;
734};
735
744struct net_if {
749 struct net_if_dev *if_dev;
750
751#if defined(CONFIG_NET_STATISTICS_PER_INTERFACE)
753 struct net_stats stats;
754
756 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS,
757 (struct prometheus_collector *collector);)
758#endif /* CONFIG_NET_STATISTICS_PER_INTERFACE */
759
761 struct net_if_config config;
762
763#if defined(CONFIG_NET_POWER_MANAGEMENT)
768 int tx_pending;
769#endif
770
772 struct k_mutex lock;
773
775 struct k_mutex tx_lock;
776
781 uint8_t pe_enabled : 1;
782
786 uint8_t pe_prefer_public : 1;
787
789 uint8_t _unused : 6;
793};
794
796
797static inline void net_if_lock(struct net_if *iface)
798{
799 NET_ASSERT(iface);
800
801 (void)k_mutex_lock(&iface->lock, K_FOREVER);
802}
803
804static inline void net_if_unlock(struct net_if *iface)
805{
806 NET_ASSERT(iface);
807
808 k_mutex_unlock(&iface->lock);
809}
810
811static inline bool net_if_flag_is_set(struct net_if *iface,
812 enum net_if_flag value);
813
814static inline void net_if_tx_lock(struct net_if *iface)
815{
816 NET_ASSERT(iface);
817
819 return;
820 }
821
822 (void)k_mutex_lock(&iface->tx_lock, K_FOREVER);
823}
824
825static inline void net_if_tx_unlock(struct net_if *iface)
826{
827 NET_ASSERT(iface);
828
830 return;
831 }
832
833 k_mutex_unlock(&iface->tx_lock);
834}
835
837
844static inline void net_if_flag_set(struct net_if *iface,
845 enum net_if_flag value)
846{
847 if (iface == NULL) {
848 return;
849 }
850
851 NET_ASSERT(iface->if_dev != NULL);
852
853 atomic_set_bit(iface->if_dev->flags, value);
854}
855
864static inline bool net_if_flag_test_and_set(struct net_if *iface,
865 enum net_if_flag value)
866{
867 if (iface == NULL) {
868 return false;
869 }
870
871 NET_ASSERT(iface->if_dev != NULL);
872
873 return atomic_test_and_set_bit(iface->if_dev->flags, value);
874}
875
882static inline void net_if_flag_clear(struct net_if *iface,
883 enum net_if_flag value)
884{
885 if (iface == NULL) {
886 return;
887 }
888
889 NET_ASSERT(iface->if_dev != NULL);
890
891 atomic_clear_bit(iface->if_dev->flags, value);
892}
893
902static inline bool net_if_flag_test_and_clear(struct net_if *iface,
903 enum net_if_flag value)
904{
905 if (iface == NULL) {
906 return false;
907 }
908
909 NET_ASSERT(iface->if_dev != NULL);
910
911 return atomic_test_and_clear_bit(iface->if_dev->flags, value);
912}
913
922static inline bool net_if_flag_is_set(struct net_if *iface,
923 enum net_if_flag value)
924{
925 if (iface == NULL) {
926 return false;
927 }
928
929 NET_ASSERT(iface->if_dev != NULL);
930
931 return atomic_test_bit(iface->if_dev->flags, value);
932}
933
943 struct net_if *iface, enum net_if_oper_state oper_state)
944{
945 if (iface == NULL) {
946 return NET_IF_OPER_UNKNOWN;
947 }
948
949 NET_ASSERT(iface->if_dev != NULL);
950
951 if (oper_state <= NET_IF_OPER_UP) {
952 iface->if_dev->oper_state = oper_state;
953 }
954
955 net_if_lock(iface);
956
957 iface->if_dev->oper_state_change_time = k_uptime_get();
958
959 net_if_unlock(iface);
960
961 return iface->if_dev->oper_state;
962}
963
971static inline enum net_if_oper_state net_if_oper_state(struct net_if *iface)
972{
973 if (iface == NULL) {
974 return NET_IF_OPER_UNKNOWN;
975 }
976
977 NET_ASSERT(iface->if_dev != NULL);
978
979 return iface->if_dev->oper_state;
980}
981
994static inline int net_if_oper_state_change_time(struct net_if *iface,
995 int64_t *change_time)
996{
997 if (iface == NULL || change_time == NULL) {
998 return -EINVAL;
999 }
1000
1001 NET_ASSERT(iface->if_dev != NULL);
1002
1003 net_if_lock(iface);
1004
1005 *change_time = iface->if_dev->oper_state_change_time;
1006
1007 net_if_unlock(iface);
1008
1009 return 0;
1010}
1011
1022 struct net_pkt *pkt, k_timeout_t timeout);
1023
1033static inline enum net_verdict net_if_send_data(struct net_if *iface,
1034 struct net_pkt *pkt)
1035{
1037
1038 return net_if_try_send_data(iface, pkt, timeout);
1039}
1040
1048static inline const struct net_l2 *net_if_l2(struct net_if *iface)
1049{
1050 if (iface == NULL) {
1051 return NULL;
1052 }
1053
1054 NET_ASSERT(iface->if_dev != NULL);
1055
1056 return iface->if_dev->l2;
1057}
1058
1067enum net_verdict net_if_recv_data(struct net_if *iface, struct net_pkt *pkt);
1068
1076static inline void *net_if_l2_data(struct net_if *iface)
1077{
1078 if (iface == NULL) {
1079 return NULL;
1080 }
1081
1082 NET_ASSERT(iface->if_dev != NULL);
1083
1084 return iface->if_dev->l2_data;
1085}
1086
1094static inline const struct device *net_if_get_device(struct net_if *iface)
1095{
1096 if (iface == NULL) {
1097 return NULL;
1098 }
1099
1100 NET_ASSERT(iface->if_dev != NULL);
1101
1102 return iface->if_dev->dev;
1103}
1104
1112void net_if_try_queue_tx(struct net_if *iface, struct net_pkt *pkt, k_timeout_t timeout);
1113
1121static inline void net_if_queue_tx(struct net_if *iface, struct net_pkt *pkt)
1122{
1124
1125 net_if_try_queue_tx(iface, pkt, timeout);
1126}
1127
1135static inline bool net_if_is_ip_offloaded(struct net_if *iface)
1136{
1137#if defined(CONFIG_NET_OFFLOAD)
1138 __ASSERT_NO_MSG(iface == NULL || iface->if_dev != NULL);
1139 return (iface != NULL && iface->if_dev->offload != NULL);
1140#else
1141 ARG_UNUSED(iface);
1142
1143 return false;
1144#endif
1145}
1146
1154bool net_if_is_offloaded(struct net_if *iface);
1155
1163static inline struct net_offload *net_if_offload(struct net_if *iface)
1164{
1165#if defined(CONFIG_NET_OFFLOAD)
1166 if (iface == NULL) {
1167 return NULL;
1168 }
1169
1170 NET_ASSERT(iface->if_dev != NULL);
1171
1172 return iface->if_dev->offload;
1173#else
1174 ARG_UNUSED(iface);
1175
1176 return NULL;
1177#endif
1178}
1179
1186static inline void net_if_offload_set(struct net_if *iface, struct net_offload *offload)
1187{
1188#if defined(CONFIG_NET_OFFLOAD)
1189 if (iface == NULL) {
1190 return;
1191 }
1192
1193 NET_ASSERT(iface->if_dev != NULL);
1194
1195 iface->if_dev->offload = offload;
1196#else
1197 ARG_UNUSED(iface);
1198 ARG_UNUSED(offload);
1199#endif
1200}
1201
1209static inline bool net_if_is_socket_offloaded(struct net_if *iface)
1210{
1211#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
1212 if (iface == NULL) {
1213 return false;
1214 }
1215
1216 NET_ASSERT(iface->if_dev != NULL);
1217
1218 return (iface->if_dev->socket_offload != NULL);
1219#else
1220 ARG_UNUSED(iface);
1221
1222 return false;
1223#endif
1224}
1225
1232static inline void net_if_socket_offload_set(
1233 struct net_if *iface, net_socket_create_t socket_offload)
1234{
1235#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
1236 if (iface == NULL) {
1237 return;
1238 }
1239
1240 NET_ASSERT(iface->if_dev != NULL);
1241
1242 iface->if_dev->socket_offload = socket_offload;
1243#else
1244 ARG_UNUSED(iface);
1245 ARG_UNUSED(socket_offload);
1246#endif
1247}
1248
1257{
1258#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
1259 if (iface == NULL) {
1260 return NULL;
1261 }
1262
1263 NET_ASSERT(iface->if_dev != NULL);
1264
1265 return iface->if_dev->socket_offload;
1266#else
1267 ARG_UNUSED(iface);
1268
1269 return NULL;
1270#endif
1271}
1272
1280static inline struct net_linkaddr *net_if_get_link_addr(struct net_if *iface)
1281{
1282 if (iface == NULL) {
1283 return NULL;
1284 }
1285
1286 NET_ASSERT(iface->if_dev != NULL);
1287
1288 return &iface->if_dev->link_addr;
1289}
1290
1298static inline struct net_if_config *net_if_get_config(struct net_if *iface)
1299{
1300 if (iface == NULL) {
1301 return NULL;
1302 }
1303
1304 return &iface->config;
1305}
1306
1312#if defined(CONFIG_NET_IPV6_DAD) && defined(CONFIG_NET_NATIVE_IPV6)
1313void net_if_start_dad(struct net_if *iface);
1314#else
1315static inline void net_if_start_dad(struct net_if *iface)
1316{
1317 ARG_UNUSED(iface);
1318}
1319#endif
1320
1326void net_if_start_rs(struct net_if *iface);
1327
1328
1334#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
1335void net_if_stop_rs(struct net_if *iface);
1336#else
1337static inline void net_if_stop_rs(struct net_if *iface)
1338{
1339 ARG_UNUSED(iface);
1340}
1341#endif /* CONFIG_NET_IPV6_ND */
1342
1355#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
1356void net_if_nbr_reachability_hint(struct net_if *iface, const struct net_in6_addr *ipv6_addr);
1357#else
1358static inline void net_if_nbr_reachability_hint(struct net_if *iface,
1359 const struct net_in6_addr *ipv6_addr)
1360{
1361 ARG_UNUSED(iface);
1362 ARG_UNUSED(ipv6_addr);
1363}
1364#endif
1365
1367
1368static inline int net_if_set_link_addr_unlocked(struct net_if *iface,
1369 const uint8_t *addr, uint8_t len,
1370 enum net_link_type type)
1371{
1372 int ret;
1373
1374 if (net_if_flag_is_set(iface, NET_IF_RUNNING)) {
1375 return -EPERM;
1376 }
1377
1378 if (len > sizeof(net_if_get_link_addr(iface)->addr)) {
1379 return -EINVAL;
1380 }
1381
1382 ret = net_linkaddr_create(net_if_get_link_addr(iface), addr, len, type);
1383 if (ret < 0) {
1384 return ret;
1385 }
1386
1387 net_hostname_set_postfix(addr, len);
1388
1389 return 0;
1390}
1391
1392int net_if_set_link_addr_locked(struct net_if *iface,
1393 const uint8_t *addr, uint8_t len,
1394 enum net_link_type type);
1395
1396#if CONFIG_NET_IF_LOG_LEVEL >= LOG_LEVEL_DBG
1397extern int net_if_addr_unref_debug(struct net_if *iface,
1398 net_sa_family_t family,
1399 const void *addr,
1400 struct net_if_addr **ifaddr,
1401 const char *caller, int line);
1402#define net_if_addr_unref(iface, family, addr, ifaddr) \
1403 net_if_addr_unref_debug(iface, family, addr, ifaddr, __func__, __LINE__)
1404
1405extern struct net_if_addr *net_if_addr_ref_debug(struct net_if *iface,
1406 net_sa_family_t family,
1407 const void *addr,
1408 const char *caller,
1409 int line);
1410#define net_if_addr_ref(iface, family, addr) \
1411 net_if_addr_ref_debug(iface, family, addr, __func__, __LINE__)
1412#else
1413extern int net_if_addr_unref(struct net_if *iface,
1414 net_sa_family_t family,
1415 const void *addr,
1416 struct net_if_addr **ifaddr);
1417extern struct net_if_addr *net_if_addr_ref(struct net_if *iface,
1418 net_sa_family_t family,
1419 const void *addr);
1420#endif /* CONFIG_NET_IF_LOG_LEVEL */
1421
1423
1434static inline int net_if_set_link_addr(struct net_if *iface,
1435 const uint8_t *addr, uint8_t len,
1436 enum net_link_type type)
1437{
1438#if defined(CONFIG_NET_RAW_MODE)
1439 return net_if_set_link_addr_unlocked(iface, addr, len, type);
1440#else
1441 return net_if_set_link_addr_locked(iface, addr, len, type);
1442#endif
1443}
1444
1452static inline uint16_t net_if_get_mtu(struct net_if *iface)
1453{
1454 if (iface == NULL) {
1455 return 0U;
1456 }
1457
1458 NET_ASSERT(iface->if_dev != NULL);
1459
1460 return iface->if_dev->mtu;
1461}
1462
1469static inline void net_if_set_mtu(struct net_if *iface,
1470 uint16_t mtu)
1471{
1472 if (iface == NULL) {
1473 return;
1474 }
1475
1476 NET_ASSERT(iface->if_dev != NULL);
1477
1478 iface->if_dev->mtu = mtu;
1479}
1480
1487static inline void net_if_addr_set_lf(struct net_if_addr *ifaddr,
1488 bool is_infinite)
1489{
1490 if (ifaddr == NULL) {
1491 return;
1492 }
1493
1494 ifaddr->is_infinite = is_infinite;
1495}
1496
1505
1513struct net_if *net_if_lookup_by_dev(const struct device *dev);
1514
1520void net_if_router_rm(struct net_if_router *router);
1521
1527void net_if_set_default(struct net_if *iface);
1528
1535
1544struct net_if *net_if_get_first_by_type(const struct net_l2 *l2);
1545
1553
1554#if defined(CONFIG_NET_L2_IEEE802154)
1561static inline struct net_if *net_if_get_ieee802154(void)
1562{
1563 return net_if_get_first_by_type(&NET_L2_GET_NAME(IEEE802154));
1564}
1565#endif /* CONFIG_NET_L2_IEEE802154 */
1566
1578 struct net_if_ipv6 **ipv6);
1579
1588
1589
1591struct net_if_addr *net_if_ipv6_addr_lookup_raw(const uint8_t *addr,
1592 struct net_if **ret);
1594
1604 struct net_if **iface);
1605
1607struct net_if_addr *net_if_ipv6_addr_lookup_by_iface_raw(struct net_if *iface,
1608 const uint8_t *addr);
1610
1620 const struct net_in6_addr *addr);
1621
1630__syscall int net_if_ipv6_addr_lookup_by_index(const struct net_in6_addr *addr);
1631
1643 const struct net_in6_addr *addr,
1645 uint32_t vlifetime);
1646
1657__syscall bool net_if_ipv6_addr_add_by_index(int index,
1658 const struct net_in6_addr *addr,
1660 uint32_t vlifetime);
1661
1669 uint32_t vlifetime);
1670
1679bool net_if_ipv6_addr_rm(struct net_if *iface, const struct net_in6_addr *addr);
1680
1689__syscall bool net_if_ipv6_addr_rm_by_index(int index,
1690 const struct net_in6_addr *addr);
1691
1700typedef void (*net_if_ip_addr_cb_t)(struct net_if *iface,
1701 struct net_if_addr *addr,
1702 void *user_data);
1703
1713 void *user_data);
1714
1724 const struct net_in6_addr *addr);
1725
1734bool net_if_ipv6_maddr_rm(struct net_if *iface, const struct net_in6_addr *addr);
1735
1744typedef void (*net_if_ip_maddr_cb_t)(struct net_if *iface,
1745 struct net_if_mcast_addr *maddr,
1746 void *user_data);
1747
1757 void *user_data);
1758
1759
1761struct net_if_mcast_addr *net_if_ipv6_maddr_lookup_raw(const uint8_t *maddr,
1762 struct net_if **ret);
1764
1776 struct net_if **iface);
1777
1788typedef void (*net_if_mcast_callback_t)(struct net_if *iface,
1789 const struct net_addr *addr,
1790 bool is_joined);
1791
1810
1820 struct net_if *iface,
1822
1829
1837void net_if_mcast_monitor(struct net_if *iface, const struct net_addr *addr,
1838 bool is_joined);
1839
1847 struct net_if_mcast_addr *addr);
1848
1856static inline bool net_if_ipv6_maddr_is_joined(struct net_if_mcast_addr *addr)
1857{
1858 if (addr == NULL) {
1859 return false;
1860 }
1861
1862 return addr->is_joined;
1863}
1864
1872 struct net_if_mcast_addr *addr);
1873
1883 const struct net_in6_addr *addr);
1884
1895 const struct net_in6_addr *addr,
1896 uint8_t len);
1897
1909 const struct net_in6_addr *prefix,
1910 uint8_t len,
1912
1922bool net_if_ipv6_prefix_rm(struct net_if *iface, const struct net_in6_addr *addr,
1923 uint8_t len);
1924
1932 bool is_infinite)
1933{
1934 prefix->is_infinite = is_infinite;
1935}
1936
1945
1952
1963bool net_if_ipv6_addr_onlink(struct net_if **iface, const struct net_in6_addr *addr);
1964
1971#if defined(CONFIG_NET_NATIVE_IPV6)
1972static inline struct net_in6_addr *net_if_router_ipv6(struct net_if_router *router)
1973{
1974 if (router == NULL) {
1975 return NULL;
1976 }
1977
1978 return &router->address.in6_addr;
1979}
1980#else
1981static inline struct net_in6_addr *net_if_router_ipv6(struct net_if_router *router)
1982{
1983 static struct net_in6_addr addr;
1984
1985 ARG_UNUSED(router);
1986
1987 return &addr;
1988}
1989#endif
1990
2001 const struct net_in6_addr *addr);
2002
2013 const struct net_in6_addr *addr);
2014
2023
2035 const struct net_in6_addr *addr,
2036 bool is_default,
2037 uint16_t router_lifetime);
2038
2047
2056#if defined(CONFIG_NET_NATIVE_IPV6)
2058#else
2060{
2061 ARG_UNUSED(iface);
2062
2063 return 0;
2064}
2065#endif /* CONFIG_NET_NATIVE_IPV6 */
2066
2073#if defined(CONFIG_NET_NATIVE_IPV6)
2074void net_if_ipv6_set_hop_limit(struct net_if *iface, uint8_t hop_limit);
2075#else
2076static inline void net_if_ipv6_set_hop_limit(struct net_if *iface,
2077 uint8_t hop_limit)
2078{
2079 ARG_UNUSED(iface);
2080 ARG_UNUSED(hop_limit);
2081}
2082#endif /* CONFIG_NET_NATIVE_IPV6 */
2083
2092#if defined(CONFIG_NET_NATIVE_IPV6)
2094#else
2096{
2097 ARG_UNUSED(iface);
2098
2099 return 0;
2100}
2101#endif /* CONFIG_NET_NATIVE_IPV6 */
2102
2109#if defined(CONFIG_NET_NATIVE_IPV6)
2110void net_if_ipv6_set_mcast_hop_limit(struct net_if *iface, uint8_t hop_limit);
2111#else
2113 uint8_t hop_limit)
2114{
2115 ARG_UNUSED(iface);
2116 ARG_UNUSED(hop_limit);
2117}
2118#endif /* CONFIG_NET_NATIVE_IPV6 */
2119
2129#define NET_IPV6_MAX_REACHABLE_TIME 3600000U
2130
2139 uint32_t reachable_time)
2140{
2141#if defined(CONFIG_NET_NATIVE_IPV6)
2142 if (iface == NULL) {
2143 return;
2144 }
2145
2146 if (!iface->config.ip.ipv6) {
2147 return;
2148 }
2149
2150 if (reachable_time > NET_IPV6_MAX_REACHABLE_TIME) {
2151 reachable_time = NET_IPV6_MAX_REACHABLE_TIME;
2152 }
2153
2154 iface->config.ip.ipv6->base_reachable_time = reachable_time;
2155#else
2156 ARG_UNUSED(iface);
2157 ARG_UNUSED(reachable_time);
2158
2159#endif
2160}
2161
2170{
2171#if defined(CONFIG_NET_NATIVE_IPV6)
2172 if (iface == NULL) {
2173 return 0;
2174 }
2175
2176 if (iface->config.ip.ipv6 == NULL) {
2177 return 0;
2178 }
2179
2180 return iface->config.ip.ipv6->base_reachable_time;
2181#else
2182 ARG_UNUSED(iface);
2183 return 0;
2184#endif
2185}
2186
2195{
2196#if defined(CONFIG_NET_NATIVE_IPV6)
2197 if (iface == NULL) {
2198 return 0;
2199 }
2200
2201 if (!iface->config.ip.ipv6) {
2202 return 0;
2203 }
2204
2205 return iface->config.ip.ipv6->reachable_time;
2206#else
2207 ARG_UNUSED(iface);
2208 return 0;
2209#endif
2210}
2211
2220
2227static inline void net_if_ipv6_set_reachable_time(struct net_if_ipv6 *ipv6)
2228{
2229#if defined(CONFIG_NET_NATIVE_IPV6)
2230 if (ipv6 == NULL) {
2231 return;
2232 }
2233
2235#else
2236 ARG_UNUSED(ipv6);
2237#endif
2238}
2239
2246static inline void net_if_ipv6_set_retrans_timer(struct net_if *iface,
2247 uint32_t retrans_timer)
2248{
2249#if defined(CONFIG_NET_NATIVE_IPV6)
2250 if (iface == NULL) {
2251 return;
2252 }
2253
2254 if (!iface->config.ip.ipv6) {
2255 return;
2256 }
2257
2258 iface->config.ip.ipv6->retrans_timer = retrans_timer;
2259#else
2260 ARG_UNUSED(iface);
2261 ARG_UNUSED(retrans_timer);
2262#endif
2263}
2264
2273{
2274#if defined(CONFIG_NET_NATIVE_IPV6)
2275 if (iface == NULL) {
2276 return 0;
2277 }
2278
2279 if (!iface->config.ip.ipv6) {
2280 return 0;
2281 }
2282
2283 return iface->config.ip.ipv6->retrans_timer;
2284#else
2285 ARG_UNUSED(iface);
2286 return 0;
2287#endif
2288}
2289
2301#if defined(CONFIG_NET_IPV6)
2302const struct net_in6_addr *net_if_ipv6_select_src_addr(struct net_if *iface,
2303 const struct net_in6_addr *dst);
2304#else
2305static inline const struct net_in6_addr *net_if_ipv6_select_src_addr(
2306 struct net_if *iface, const struct net_in6_addr *dst)
2307{
2308 ARG_UNUSED(iface);
2309 ARG_UNUSED(dst);
2310
2311 return NULL;
2312}
2313#endif
2314
2328#if defined(CONFIG_NET_IPV6)
2329const struct net_in6_addr *net_if_ipv6_select_src_addr_hint(struct net_if *iface,
2330 const struct net_in6_addr *dst,
2331 int flags);
2332#else
2334 struct net_if *iface, const struct net_in6_addr *dst, int flags)
2335{
2336 ARG_UNUSED(iface);
2337 ARG_UNUSED(dst);
2338 ARG_UNUSED(flags);
2339
2340 return NULL;
2341}
2342#endif
2343
2353#if defined(CONFIG_NET_IPV6)
2354struct net_if *net_if_ipv6_select_src_iface(const struct net_in6_addr *dst);
2355#else
2357 const struct net_in6_addr *dst)
2358{
2359 ARG_UNUSED(dst);
2360
2361 return NULL;
2362}
2363#endif
2364
2377#if defined(CONFIG_NET_IPV6)
2378struct net_if *net_if_ipv6_select_src_iface_addr(const struct net_in6_addr *dst,
2379 const struct net_in6_addr **src_addr);
2380#else
2382 const struct net_in6_addr *dst, const struct net_in6_addr **src_addr)
2383{
2384 ARG_UNUSED(dst);
2385 ARG_UNUSED(src_addr);
2386
2387 return NULL;
2388}
2389#endif /* CONFIG_NET_IPV6 */
2390
2401 enum net_addr_state addr_state);
2402
2413 struct net_if **iface);
2414
2422void net_if_ipv6_dad_failed(struct net_if *iface, const struct net_in6_addr *addr);
2423
2436 struct net_if **iface);
2437
2449 struct net_if_ipv4 **ipv4);
2450
2459
2468
2475void net_if_ipv4_set_ttl(struct net_if *iface, uint8_t ttl);
2476
2485
2493
2504bool net_if_ipv4_addr_onlink(struct net_if **iface, const struct net_in_addr *addr);
2505
2515 struct net_if **iface);
2516
2528 const struct net_in_addr *addr,
2530 uint32_t vlifetime);
2531
2540bool net_if_ipv4_addr_rm(struct net_if *iface, const struct net_in_addr *addr);
2541
2550__syscall int net_if_ipv4_addr_lookup_by_index(const struct net_in_addr *addr);
2551
2562__syscall bool net_if_ipv4_addr_add_by_index(int index,
2563 const struct net_in_addr *addr,
2565 uint32_t vlifetime);
2566
2575__syscall bool net_if_ipv4_addr_rm_by_index(int index,
2576 const struct net_in_addr *addr);
2577
2587 void *user_data);
2588
2598 const struct net_in_addr *addr);
2599
2608bool net_if_ipv4_maddr_rm(struct net_if *iface, const struct net_in_addr *addr);
2609
2619 void *user_data);
2620
2632 struct net_if **iface);
2633
2641 struct net_if_mcast_addr *addr);
2642
2650static inline bool net_if_ipv4_maddr_is_joined(struct net_if_mcast_addr *addr)
2651{
2652 if (addr == NULL) {
2653 return false;
2654 }
2655
2656 return addr->is_joined;
2657}
2658
2666 struct net_if_mcast_addr *addr);
2667
2674#if defined(CONFIG_NET_NATIVE_IPV4)
2675static inline struct net_in_addr *net_if_router_ipv4(struct net_if_router *router)
2676{
2677 if (router == NULL) {
2678 return NULL;
2679 }
2680
2681 return &router->address.in_addr;
2682}
2683#else
2684static inline struct net_in_addr *net_if_router_ipv4(struct net_if_router *router)
2685{
2686 static struct net_in_addr addr;
2687
2688 ARG_UNUSED(router);
2689
2690 return &addr;
2691}
2692#endif
2693
2704 const struct net_in_addr *addr);
2705
2716 const struct net_in_addr *addr);
2728 const struct net_in_addr *addr,
2729 bool is_default,
2730 uint16_t router_lifetime);
2731
2740
2754int net_if_ipv4_route_add(struct net_if *iface, const struct net_in_addr *addr, uint8_t mask_len,
2755 const struct net_in_addr *nexthop, uint32_t lifetime);
2756
2766 const struct net_in_addr *addr);
2767
2777 const struct net_in_addr *addr);
2778
2788#if defined(CONFIG_NET_IPV4)
2789struct net_if *net_if_ipv4_select_src_iface(const struct net_in_addr *dst);
2790#else
2792 const struct net_in_addr *dst)
2793{
2794 ARG_UNUSED(dst);
2795
2796 return NULL;
2797}
2798#endif
2799
2812#if defined(CONFIG_NET_IPV4)
2813struct net_if *net_if_ipv4_select_src_iface_addr(const struct net_in_addr *dst,
2814 const struct net_in_addr **src_addr);
2815#else
2817 const struct net_in_addr *dst, const struct net_in_addr **src_addr)
2818{
2819 ARG_UNUSED(dst);
2820 ARG_UNUSED(src_addr);
2821
2822 return NULL;
2823}
2824#endif /* CONFIG_NET_IPV4 */
2825
2837#if defined(CONFIG_NET_IPV4)
2838const struct net_in_addr *net_if_ipv4_select_src_addr(struct net_if *iface,
2839 const struct net_in_addr *dst);
2840#else
2841static inline const struct net_in_addr *net_if_ipv4_select_src_addr(
2842 struct net_if *iface, const struct net_in_addr *dst)
2843{
2844 ARG_UNUSED(iface);
2845 ARG_UNUSED(dst);
2846
2847 return NULL;
2848}
2849#endif
2850
2861 enum net_addr_state addr_state);
2862
2873 enum net_addr_state addr_state);
2874
2885 const struct net_in_addr *addr);
2886
2897 const struct net_in_addr *addr,
2898 const struct net_in_addr *netmask);
2899
2910 const struct net_in_addr *addr,
2911 const struct net_in_addr *netmask);
2912
2921
2928void net_if_ipv4_set_gw(struct net_if *iface, const struct net_in_addr *gw);
2929
2938__syscall bool net_if_ipv4_set_gw_by_index(int index, const struct net_in_addr *gw);
2939
2951
2960typedef void (*net_if_link_callback_t)(struct net_if *iface,
2961 struct net_linkaddr *dst,
2962 int status);
2963
2979
2988
2995
3003void net_if_call_link_cb(struct net_if *iface, struct net_linkaddr *lladdr,
3004 int status);
3005
3007
3008/* used to ensure encoding of checksum support in net_if.h and
3009 * ethernet.h is the same
3010 */
3011#define NET_IF_CHECKSUM_NONE_BIT 0
3012#define NET_IF_CHECKSUM_IPV4_HEADER_BIT BIT(0)
3013#define NET_IF_CHECKSUM_IPV4_ICMP_BIT BIT(1)
3014/* Space for future protocols and restrictions for IPV4 */
3015#define NET_IF_CHECKSUM_IPV6_HEADER_BIT BIT(10)
3016#define NET_IF_CHECKSUM_IPV6_ICMP_BIT BIT(11)
3017/* Space for future protocols and restrictions for IPV6 */
3018#define NET_IF_CHECKSUM_TCP_BIT BIT(21)
3019#define NET_IF_CHECKSUM_UDP_BIT BIT(22)
3020
3022
3028 NET_IF_CHECKSUM_IPV4_HEADER = NET_IF_CHECKSUM_IPV4_HEADER_BIT,
3030 NET_IF_CHECKSUM_IPV4_TCP = NET_IF_CHECKSUM_IPV4_HEADER_BIT |
3031 NET_IF_CHECKSUM_TCP_BIT,
3033 NET_IF_CHECKSUM_IPV4_UDP = NET_IF_CHECKSUM_IPV4_HEADER_BIT |
3034 NET_IF_CHECKSUM_UDP_BIT,
3036 NET_IF_CHECKSUM_IPV4_ICMP = NET_IF_CHECKSUM_IPV4_ICMP_BIT,
3038 NET_IF_CHECKSUM_IPV6_HEADER = NET_IF_CHECKSUM_IPV6_HEADER_BIT,
3040 NET_IF_CHECKSUM_IPV6_TCP = NET_IF_CHECKSUM_IPV6_HEADER_BIT |
3041 NET_IF_CHECKSUM_TCP_BIT,
3043 NET_IF_CHECKSUM_IPV6_UDP = NET_IF_CHECKSUM_IPV6_HEADER_BIT |
3044 NET_IF_CHECKSUM_UDP_BIT,
3046 NET_IF_CHECKSUM_IPV6_ICMP = NET_IF_CHECKSUM_IPV6_ICMP_BIT
3047};
3048
3059#if defined(CONFIG_NET_CHECKSUM_OFFLOAD)
3060bool net_if_need_calc_rx_checksum(struct net_if *iface,
3061 enum net_if_checksum_type chksum_type);
3062#else /* CONFIG_NET_CHECKSUM_OFFLOAD */
3063static inline bool net_if_need_calc_rx_checksum(struct net_if *iface,
3064 enum net_if_checksum_type chksum_type)
3065{
3066 ARG_UNUSED(iface);
3067 ARG_UNUSED(chksum_type);
3068 return true;
3069}
3070#endif /* CONFIG_NET_CHECKSUM_OFFLOAD */
3071
3083#if defined(CONFIG_NET_CHECKSUM_OFFLOAD)
3084bool net_if_need_calc_tx_checksum(struct net_if *iface,
3085 enum net_if_checksum_type chksum_type);
3086#else /* CONFIG_NET_CHECKSUM_OFFLOAD */
3087static inline bool net_if_need_calc_tx_checksum(struct net_if *iface,
3088 enum net_if_checksum_type chksum_type)
3089{
3090 ARG_UNUSED(iface);
3091 ARG_UNUSED(chksum_type);
3092 return true;
3093}
3094#endif /* CONFIG_NET_CHECKSUM_OFFLOAD */
3095
3106__syscall struct net_if *net_if_get_by_index(int index);
3107
3115int net_if_get_by_iface(struct net_if *iface);
3116
3124typedef void (*net_if_cb_t)(struct net_if *iface, void *user_data);
3125
3133void net_if_foreach(net_if_cb_t cb, void *user_data);
3134
3142int net_if_up(struct net_if *iface);
3143
3151static inline bool net_if_is_up(struct net_if *iface)
3152{
3153 if (iface == NULL) {
3154 return false;
3155 }
3156
3157 return net_if_flag_is_set(iface, NET_IF_UP) &&
3159}
3160
3168int net_if_down(struct net_if *iface);
3169
3177static inline bool net_if_is_admin_up(struct net_if *iface)
3178{
3179 if (iface == NULL) {
3180 return false;
3181 }
3182
3183 return net_if_flag_is_set(iface, NET_IF_UP);
3184}
3185
3194void net_if_carrier_on(struct net_if *iface);
3195
3204void net_if_carrier_off(struct net_if *iface);
3205
3213static inline bool net_if_is_carrier_ok(struct net_if *iface)
3214{
3215 if (iface == NULL) {
3216 return false;
3217 }
3218
3219 return net_if_flag_is_set(iface, NET_IF_LOWER_UP);
3220}
3221
3232void net_if_dormant_on(struct net_if *iface);
3233
3242void net_if_dormant_off(struct net_if *iface);
3243
3251static inline bool net_if_is_dormant(struct net_if *iface)
3252{
3253 if (iface == NULL) {
3254 return false;
3255 }
3256
3257 return net_if_flag_is_set(iface, NET_IF_DORMANT);
3258}
3259
3260#if defined(CONFIG_NET_PKT_TIMESTAMP_THREAD) || defined(__DOXYGEN__)
3268typedef void (*net_if_timestamp_callback_t)(struct net_pkt *pkt);
3269
3295
3307 struct net_pkt *pkt,
3308 struct net_if *iface,
3310
3317
3324
3325/*
3326 * @brief Add timestamped TX buffer to be handled
3327 *
3328 * @param pkt Timestamped buffer
3329 */
3331#endif /* CONFIG_NET_PKT_TIMESTAMP_THREAD */
3332
3342#if defined(CONFIG_NET_PROMISCUOUS_MODE)
3343int net_if_set_promisc(struct net_if *iface);
3344#else
3345static inline int net_if_set_promisc(struct net_if *iface)
3346{
3347 ARG_UNUSED(iface);
3348
3349 return -ENOTSUP;
3350}
3351#endif
3352
3358#if defined(CONFIG_NET_PROMISCUOUS_MODE)
3359void net_if_unset_promisc(struct net_if *iface);
3360#else
3361static inline void net_if_unset_promisc(struct net_if *iface)
3362{
3363 ARG_UNUSED(iface);
3364}
3365#endif
3366
3375#if defined(CONFIG_NET_PROMISCUOUS_MODE)
3376bool net_if_is_promisc(struct net_if *iface);
3377#else
3378static inline bool net_if_is_promisc(struct net_if *iface)
3379{
3380 ARG_UNUSED(iface);
3381
3382 return false;
3383}
3384#endif
3385
3395static inline bool net_if_are_pending_tx_packets(struct net_if *iface)
3396{
3397#if defined(CONFIG_NET_POWER_MANAGEMENT)
3398 return !!iface->tx_pending;
3399#else
3400 ARG_UNUSED(iface);
3401
3402 return false;
3403#endif
3404}
3405
3406#ifdef CONFIG_NET_POWER_MANAGEMENT
3414int net_if_suspend(struct net_if *iface);
3415
3423int net_if_resume(struct net_if *iface);
3424
3432bool net_if_is_suspended(struct net_if *iface);
3433#endif /* CONFIG_NET_POWER_MANAGEMENT */
3434
3442bool net_if_is_ethernet(struct net_if *iface);
3443
3450
3458bool net_if_is_wifi(struct net_if *iface);
3459
3466
3473
3480
3495int net_if_get_name(struct net_if *iface, char *buf, int len);
3496
3511int net_if_set_name(struct net_if *iface, const char *buf);
3512
3520int net_if_get_by_name(const char *name);
3521
3523struct net_if_api {
3524 void (*init)(struct net_if *iface);
3525};
3526
3527#define NET_IF_DHCPV4_INIT \
3528 IF_ENABLED(UTIL_AND(IS_ENABLED(CONFIG_NET_DHCPV4), \
3529 IS_ENABLED(CONFIG_NET_NATIVE_IPV4)), \
3530 (.dhcpv4.state = NET_DHCPV4_DISABLED,))
3531
3532#define NET_IF_DHCPV6_INIT \
3533 IF_ENABLED(UTIL_AND(IS_ENABLED(CONFIG_NET_DHCPV6), \
3534 IS_ENABLED(CONFIG_NET_NATIVE_IPV6)), \
3535 (.dhcpv6.state = NET_DHCPV6_DISABLED,))
3536
3537#define NET_IF_CONFIG_INIT \
3538 .config = { \
3539 IF_ENABLED(CONFIG_NET_IP, (.ip = {},)) \
3540 NET_IF_DHCPV4_INIT \
3541 NET_IF_DHCPV6_INIT \
3542 }
3543
3544#define NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, sfx) \
3545 net_stats_##dev_id##_##sfx##_collector
3546#define NET_PROMETHEUS_INIT(dev_id, sfx) \
3547 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS, \
3548 (.collector = &NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, sfx),))
3549
3550#define NET_IF_GET_NAME(dev_id, sfx) __net_if_##dev_id##_##sfx
3551#define NET_IF_DEV_GET_NAME(dev_id, sfx) __net_if_dev_##dev_id##_##sfx
3552
3553#define NET_IF_GET(dev_id, sfx) \
3554 ((struct net_if *)&NET_IF_GET_NAME(dev_id, sfx))
3555
3556#if defined(CONFIG_NET_STATISTICS_VIA_PROMETHEUS)
3557extern int net_stats_prometheus_scrape(struct prometheus_collector *collector,
3558 struct prometheus_metric *metric,
3559 void *user_data);
3560#endif /* CONFIG_NET_STATISTICS_VIA_PROMETHEUS */
3561
3562#define NET_IF_INIT(dev_id, sfx, _l2, _mtu) \
3563 static STRUCT_SECTION_ITERABLE(net_if_dev, \
3564 NET_IF_DEV_GET_NAME(dev_id, sfx)) = { \
3565 .dev = &(DEVICE_NAME_GET(dev_id)), \
3566 .l2 = &(NET_L2_GET_NAME(_l2)), \
3567 .l2_data = &(NET_L2_GET_DATA(dev_id, sfx)), \
3568 .mtu = _mtu, \
3569 .flags = {BIT(NET_IF_LOWER_UP)}, \
3570 }; \
3571 static STRUCT_SECTION_ITERABLE(net_if, \
3572 NET_IF_GET_NAME(dev_id, sfx)) = { \
3573 .if_dev = &(NET_IF_DEV_GET_NAME(dev_id, sfx)), \
3574 NET_IF_CONFIG_INIT \
3575 }; \
3576 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS, \
3577 (static PROMETHEUS_COLLECTOR_DEFINE( \
3578 NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, \
3579 sfx), \
3580 net_stats_prometheus_scrape, \
3581 NET_IF_GET(dev_id, sfx)); \
3582 NET_STATS_PROMETHEUS(NET_IF_GET(dev_id, sfx), \
3583 dev_id, sfx);))
3584
3585#define NET_IF_OFFLOAD_INIT(dev_id, sfx, _mtu) \
3586 static STRUCT_SECTION_ITERABLE(net_if_dev, \
3587 NET_IF_DEV_GET_NAME(dev_id, sfx)) = { \
3588 .dev = &(DEVICE_NAME_GET(dev_id)), \
3589 .mtu = _mtu, \
3590 .l2 = &(NET_L2_GET_NAME(OFFLOADED_NETDEV)), \
3591 .flags = {BIT(NET_IF_LOWER_UP)}, \
3592 }; \
3593 static STRUCT_SECTION_ITERABLE(net_if, \
3594 NET_IF_GET_NAME(dev_id, sfx)) = { \
3595 .if_dev = &(NET_IF_DEV_GET_NAME(dev_id, sfx)), \
3596 NET_IF_CONFIG_INIT \
3597 }; \
3598 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS, \
3599 (static PROMETHEUS_COLLECTOR_DEFINE( \
3600 NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, \
3601 sfx), \
3602 net_stats_prometheus_scrape, \
3603 NET_IF_GET(dev_id, sfx)); \
3604 NET_STATS_PROMETHEUS(NET_IF_GET(dev_id, sfx), \
3605 dev_id, sfx);))
3606
3607
3609
3610/* Network device initialization macros */
3611
3620#define NET_IF_DECLARE(dev_id, inst) \
3621 static struct net_if NET_IF_GET_NAME(dev_id, inst)
3622
3623#define Z_NET_DEVICE_IF_INIT_INSTANCE(dev_id, instance, l2, \
3624 l2_ctx_type, mtu) \
3625 NET_L2_DATA_INIT(dev_id, instance, l2_ctx_type); \
3626 NET_IF_INIT(dev_id, instance, l2, mtu)
3627
3628#define Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
3629 init_fn, pm, data, config, prio, \
3630 api, l2, l2_ctx_type, mtu) \
3631 Z_DEVICE_STATE_DEFINE(dev_id); \
3632 Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, NULL, \
3633 Z_DEVICE_DT_FLAGS(node_id), pm, data, \
3634 config, POST_KERNEL, prio, api, \
3635 &Z_DEVICE_STATE_NAME(dev_id)); \
3636 Z_NET_DEVICE_IF_INIT_INSTANCE(dev_id, instance, l2, \
3637 l2_ctx_type, mtu)
3638
3639#define Z_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
3640 config, prio, api, l2, l2_ctx_type, mtu) \
3641 Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, 0, init_fn, \
3642 pm, data, config, prio, api, l2, \
3643 l2_ctx_type, mtu)
3644
3651#define NET_IF_DT_DECLARE(node_id, instance) \
3652 NET_IF_DECLARE(Z_DEVICE_DT_DEV_ID(node_id), instance)
3653
3661#define NET_IF_DT_INST_DECLARE(inst, ...) NET_IF_DT_DECLARE(DT_DRV_INST(inst), __VA_ARGS__)
3662
3670#define NET_IF_DT_GET(node_id, instance) NET_IF_GET(Z_DEVICE_DT_DEV_ID(node_id), instance)
3671
3680#define NET_IF_DT_INST_GET(inst, ...) NET_IF_DT_GET(DT_DRV_INST(inst), __VA_ARGS__)
3681
3701#define NET_DEVICE_INIT(dev_id, name, init_fn, pm, data, config, prio, \
3702 api, l2, l2_ctx_type, mtu) \
3703 Z_NET_DEVICE_INIT(DT_INVALID_NODE, dev_id, name, init_fn, pm, \
3704 data, config, prio, api, l2, l2_ctx_type, mtu)
3705
3717#define NET_DEVICE_DT_ADD_IFACE(node_id, l2, l2_ctx_type, mtu, instance) \
3718 Z_NET_DEVICE_IF_INIT_INSTANCE(Z_DEVICE_DT_DEV_ID(node_id), instance, l2, l2_ctx_type, mtu)
3719
3728#define NET_DEVICE_DT_INST_ADD_IFACE(inst, ...) \
3729 NET_DEVICE_DT_ADD_IFACE(DT_DRV_INST(inst), __VA_ARGS__)
3730
3749#define NET_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, \
3750 config, prio, api, l2, l2_ctx_type, mtu) \
3751 Z_NET_DEVICE_INIT(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
3752 DEVICE_DT_NAME(node_id), init_fn, pm, data, \
3753 config, prio, api, l2, l2_ctx_type, mtu)
3754
3763#define NET_DEVICE_DT_INST_DEFINE(inst, ...) \
3764 NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
3765
3789#define NET_DEVICE_INIT_INSTANCE(dev_id, name, instance, init_fn, pm, \
3790 data, config, prio, api, l2, \
3791 l2_ctx_type, mtu) \
3792 Z_NET_DEVICE_INIT_INSTANCE(DT_INVALID_NODE, dev_id, name, \
3793 instance, init_fn, pm, data, config, \
3794 prio, api, l2, l2_ctx_type, mtu)
3795
3818#define NET_DEVICE_DT_DEFINE_INSTANCE(node_id, instance, init_fn, pm, \
3819 data, config, prio, api, l2, \
3820 l2_ctx_type, mtu) \
3821 Z_NET_DEVICE_INIT_INSTANCE(node_id, \
3822 Z_DEVICE_DT_DEV_ID(node_id), \
3823 DEVICE_DT_NAME(node_id), instance, \
3824 init_fn, pm, data, config, prio, \
3825 api, l2, l2_ctx_type, mtu)
3826
3836#define NET_DEVICE_DT_INST_DEFINE_INSTANCE(inst, ...) \
3837 NET_DEVICE_DT_DEFINE_INSTANCE(DT_DRV_INST(inst), __VA_ARGS__)
3838
3839#define Z_NET_DEVICE_OFFLOAD_INIT(node_id, dev_id, name, init_fn, pm, \
3840 data, config, prio, api, mtu) \
3841 Z_DEVICE_STATE_DEFINE(dev_id); \
3842 Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, NULL, \
3843 Z_DEVICE_DT_FLAGS(node_id), pm, data, \
3844 config, POST_KERNEL, prio, api, \
3845 &Z_DEVICE_STATE_NAME(dev_id)); \
3846 NET_IF_OFFLOAD_INIT(dev_id, 0, mtu)
3847
3867#define NET_DEVICE_OFFLOAD_INIT(dev_id, name, init_fn, pm, data, \
3868 config, prio, api, mtu) \
3869 Z_NET_DEVICE_OFFLOAD_INIT(DT_INVALID_NODE, dev_id, name, \
3870 init_fn, pm, data, config, prio, api, \
3871 mtu)
3872
3891#define NET_DEVICE_DT_OFFLOAD_DEFINE(node_id, init_fn, pm, data, \
3892 config, prio, api, mtu) \
3893 Z_NET_DEVICE_OFFLOAD_INIT(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
3894 DEVICE_DT_NAME(node_id), init_fn, pm, \
3895 data, config, prio, api, mtu)
3896
3906#define NET_DEVICE_DT_INST_OFFLOAD_DEFINE(inst, ...) \
3907 NET_DEVICE_DT_OFFLOAD_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
3908
3914#define NET_IFACE_COUNT(_dst) \
3915 do { \
3916 extern struct net_if _net_if_list_start[]; \
3917 extern struct net_if _net_if_list_end[]; \
3918 *(_dst) = ((uintptr_t)_net_if_list_end - \
3919 (uintptr_t)_net_if_list_start) / \
3920 sizeof(struct net_if); \
3921 } while (0)
3922
3923#ifdef __cplusplus
3924}
3925#endif
3926
3927#include <zephyr/syscalls/net_if.h>
3928
3932
3933#endif /* ZEPHYR_INCLUDE_NET_NET_IF_H_ */
struct z_thread_stack_element k_thread_stack_t
Typedef of struct z_thread_stack_element.
Definition arch_interface.h:46
Prometheus collector APIs.
DHCPv4 Client Handler.
DHCPv6 client.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:31
static void atomic_set_bit(atomic_t *target, int bit)
Atomically set a bit.
Definition atomic.h:242
static bool atomic_test_bit(const atomic_t *target, int bit)
Atomically get and test a bit.
Definition atomic.h:135
static void atomic_clear_bit(atomic_t *target, int bit)
Atomically clear a bit.
Definition atomic.h:224
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition atomic.h:119
static bool atomic_test_and_clear_bit(atomic_t *target, int bit)
Atomically clear a bit and test it.
Definition atomic.h:155
static bool atomic_test_and_set_bit(atomic_t *target, int bit)
Atomically set a bit and test it.
Definition atomic.h:178
#define K_FOREVER
Generate infinite timeout delay.
Definition kernel.h:1761
#define K_NO_WAIT
Generate null timeout delay.
Definition kernel.h:1651
static int64_t k_uptime_get(void)
Get system uptime.
Definition kernel.h:2265
net_addr_state
What is the current state of the network address.
Definition net_ip.h:583
unsigned short int net_sa_family_t
Socket address family type.
Definition net_ip.h:169
net_addr_type
How the network address is assigned to network interface.
Definition net_ip.h:591
bool k_is_in_isr(void)
Determine if code is running at interrupt level.
int k_mutex_unlock(struct k_mutex *mutex)
Unlock a mutex.
int k_mutex_lock(struct k_mutex *mutex, k_timeout_t timeout)
Lock a mutex.
net_verdict
Net Verdict.
Definition net_core.h:84
static int net_hostname_set_postfix(const uint8_t *hostname_postfix, int postfix_len)
Set the device hostname postfix.
Definition hostname.h:118
#define NET_IPV6_MAX_REACHABLE_TIME
Maximum IPv6 base reachable time in milliseconds.
Definition net_if.h:2129
int net_if_get_by_iface(struct net_if *iface)
Get interface index according to pointer.
int net_if_up(struct net_if *iface)
Bring interface up.
struct net_if * net_if_get_first_up(void)
Get the first network interface which is up.
int net_if_set_name(struct net_if *iface, const char *buf)
Set network interface name.
struct net_if_router * net_if_ipv4_router_add(struct net_if *iface, const struct net_in_addr *addr, bool is_default, uint16_t router_lifetime)
Add IPv4 router to the system.
void net_if_ipv4_set_gw(struct net_if *iface, const struct net_in_addr *gw)
Set IPv4 gateway for an interface.
static bool net_if_is_carrier_ok(struct net_if *iface)
Check if carrier is present on network device.
Definition net_if.h:3213
static bool net_if_is_admin_up(struct net_if *iface)
Check if interface was brought up by the administrator.
Definition net_if.h:3177
void net_if_set_default(struct net_if *iface)
Set the default network interface.
void(* net_if_mcast_callback_t)(struct net_if *iface, const struct net_addr *addr, bool is_joined)
Define a callback that is called whenever a IPv6 or IPv4 multicast address group is joined or left.
Definition net_if.h:1788
static bool net_if_need_calc_tx_checksum(struct net_if *iface, enum net_if_checksum_type chksum_type)
Check if network packet checksum calculation can be avoided or not when sending the packet.
Definition net_if.h:3087
bool net_if_ipv4_addr_onlink(struct net_if **iface, const struct net_in_addr *addr)
Check if this IPv4 address is part of the subnet of our network interface.
void(* net_if_link_callback_t)(struct net_if *iface, struct net_linkaddr *dst, int status)
Define callback that is called after a network packet has been sent.
Definition net_if.h:2960
struct net_if * net_if_get_wifi_sta(void)
Get Wi-Fi network station interface.
struct net_in_addr net_if_ipv4_get_gw(struct net_if *iface)
Get IPv4 gateway of an interface.
void net_if_add_tx_timestamp(struct net_pkt *pkt)
void net_if_ipv4_maddr_leave(struct net_if *iface, struct net_if_mcast_addr *addr)
Mark a given multicast address to be left.
struct net_if_mcast_addr * net_if_ipv6_maddr_add(struct net_if *iface, const struct net_in6_addr *addr)
Add a IPv6 multicast address to an interface.
int net_if_get_by_name(const char *name)
Get interface index according to its name.
static struct net_in6_addr * net_if_router_ipv6(struct net_if_router *router)
Get the IPv6 address of the given router.
Definition net_if.h:1981
void net_if_register_timestamp_cb(struct net_if_timestamp_cb *handle, struct net_pkt *pkt, struct net_if *iface, net_if_timestamp_callback_t cb)
Register a timestamp callback.
struct net_if * net_if_get_by_link_addr(struct net_linkaddr *ll_addr)
Get an interface according to link layer address.
bool net_if_ipv4_addr_rm_by_index(int index, const struct net_in_addr *addr)
Remove a IPv4 address from an interface by interface index.
void net_if_dormant_off(struct net_if *iface)
Mark interface as not dormant.
bool net_if_ipv6_router_rm(struct net_if_router *router)
Remove IPv6 router from the system.
static struct net_if * net_if_ipv4_select_src_iface(const struct net_in_addr *dst)
Get a network interface that should be used when sending IPv4 network data to destination.
Definition net_if.h:2791
static enum net_if_oper_state net_if_oper_state_set(struct net_if *iface, enum net_if_oper_state oper_state)
Set an operational state on an interface.
Definition net_if.h:942
int net_if_down(struct net_if *iface)
Bring interface down.
struct net_if_ipv6_prefix * net_if_ipv6_prefix_add(struct net_if *iface, const struct net_in6_addr *prefix, uint8_t len, uint32_t lifetime)
Add a IPv6 prefix to an network interface.
bool net_if_ipv4_addr_rm(struct net_if *iface, const struct net_in_addr *addr)
Remove a IPv4 address from an interface.
static struct net_if * net_if_ipv4_select_src_iface_addr(const struct net_in_addr *dst, const struct net_in_addr **src_addr)
Get a network interface that should be used when sending IPv4 network data to destination.
Definition net_if.h:2816
static void net_if_queue_tx(struct net_if *iface, struct net_pkt *pkt)
Queue a packet to the net interface TX queue.
Definition net_if.h:1121
void net_if_ipv6_prefix_unset_timer(struct net_if_ipv6_prefix *prefix)
Unset the prefix lifetime timer.
bool net_if_ipv4_addr_add_by_index(int index, const struct net_in_addr *addr, enum net_addr_type addr_type, uint32_t vlifetime)
Add a IPv4 address to an interface by network interface index.
int net_if_config_ipv4_get(struct net_if *iface, struct net_if_ipv4 **ipv4)
Allocate network interface IPv4 config.
void net_if_carrier_on(struct net_if *iface)
Underlying network device has detected the carrier (cable connected).
void net_if_try_queue_tx(struct net_if *iface, struct net_pkt *pkt, k_timeout_t timeout)
Try enqueuing a packet to the net interface TX queue.
static struct net_if * net_if_ipv6_select_src_iface(const struct net_in6_addr *dst)
Get a network interface that should be used when sending IPv6 network data to destination.
Definition net_if.h:2356
void net_if_mcast_monitor(struct net_if *iface, const struct net_addr *addr, bool is_joined)
Call registered multicast monitors.
static int net_if_set_link_addr(struct net_if *iface, const uint8_t *addr, uint8_t len, enum net_link_type type)
Set a network interface's link address.
Definition net_if.h:1434
struct net_if_addr * net_if_ipv6_addr_add(struct net_if *iface, const struct net_in6_addr *addr, enum net_addr_type addr_type, uint32_t vlifetime)
Add a IPv6 address to an interface.
static void * net_if_l2_data(struct net_if *iface)
Get a pointer to the interface L2 private data.
Definition net_if.h:1076
static bool net_if_are_pending_tx_packets(struct net_if *iface)
Check if there are any pending TX network data for a given network interface.
Definition net_if.h:3395
static bool net_if_flag_test_and_set(struct net_if *iface, enum net_if_flag value)
Test and set a value in network interface flags.
Definition net_if.h:864
struct net_if_addr * net_if_ipv6_addr_lookup(const struct net_in6_addr *addr, struct net_if **iface)
Check if this IPv6 address belongs to one of the interfaces.
bool net_if_ipv4_is_addr_bcast(struct net_if *iface, const struct net_in_addr *addr)
Check if the given IPv4 address is a broadcast address.
static struct net_linkaddr * net_if_get_link_addr(struct net_if *iface)
Get an network interface's link address.
Definition net_if.h:1280
void net_if_ipv6_maddr_join(struct net_if *iface, struct net_if_mcast_addr *addr)
Mark a given multicast address to be joined.
struct net_if_router * net_if_ipv4_router_lookup(struct net_if *iface, const struct net_in_addr *addr)
Check if IPv4 address is one of the routers configured in the system.
bool net_if_ipv6_prefix_rm(struct net_if *iface, const struct net_in6_addr *addr, uint8_t len)
Remove an IPv6 prefix from an interface.
static struct net_in_addr * net_if_router_ipv4(struct net_if_router *router)
Get the IPv4 address of the given router.
Definition net_if.h:2684
static struct net_offload * net_if_offload(struct net_if *iface)
Return the IP offload plugin.
Definition net_if.h:1163
struct net_if * net_if_get_first_ethernet(void)
Get first Cabled Ethernet network interface.
static void net_if_flag_set(struct net_if *iface, enum net_if_flag value)
Set a value in network interface flags.
Definition net_if.h:844
bool net_if_ipv6_addr_onlink(struct net_if **iface, const struct net_in6_addr *addr)
Check if this IPv6 address is part of the subnet of our network interface.
struct net_if_addr * net_if_ipv4_addr_lookup(const struct net_in_addr *addr, struct net_if **iface)
Check if this IPv4 address belongs to one of the interfaces.
struct net_if * net_if_get_default(void)
Get the default network interface.
void net_if_ipv4_set_ttl(struct net_if *iface, uint8_t ttl)
Set IPv4 time-to-live value specified to a given interface.
static const struct net_in6_addr * net_if_ipv6_select_src_addr_hint(struct net_if *iface, const struct net_in6_addr *dst, int flags)
Get a IPv6 source address that should be used when sending network data to destination.
Definition net_if.h:2333
int net_if_config_ipv6_get(struct net_if *iface, struct net_if_ipv6 **ipv6)
Allocate network interface IPv6 config.
static uint8_t net_if_ipv6_get_mcast_hop_limit(struct net_if *iface)
Get IPv6 multicast hop limit specified for a given interface.
Definition net_if.h:2095
void net_if_ipv6_addr_foreach(struct net_if *iface, net_if_ip_addr_cb_t cb, void *user_data)
Go through all IPv6 addresses on a network interface and call callback for each used address.
static void net_if_ipv6_set_hop_limit(struct net_if *iface, uint8_t hop_limit)
Set the default IPv6 hop limit of a given interface.
Definition net_if.h:2076
enum net_verdict net_if_try_send_data(struct net_if *iface, struct net_pkt *pkt, k_timeout_t timeout)
Try sending a packet through a net iface.
int net_if_get_name(struct net_if *iface, char *buf, int len)
Get network interface name.
static const struct net_in6_addr * net_if_ipv6_select_src_addr(struct net_if *iface, const struct net_in6_addr *dst)
Get a IPv6 source address that should be used when sending network data to destination.
Definition net_if.h:2305
static void net_if_nbr_reachability_hint(struct net_if *iface, const struct net_in6_addr *ipv6_addr)
Provide a reachability hint for IPv6 Neighbor Discovery.
Definition net_if.h:1358
void(* net_if_timestamp_callback_t)(struct net_pkt *pkt)
Define callback that is called after a network packet has been timestamped.
Definition net_if.h:3268
static uint8_t net_if_ipv6_get_hop_limit(struct net_if *iface)
Get IPv6 hop limit specified for a given interface.
Definition net_if.h:2059
void net_if_carrier_off(struct net_if *iface)
Underlying network device has lost the carrier (cable disconnected).
void net_if_ipv6_prefix_set_timer(struct net_if_ipv6_prefix *prefix, uint32_t lifetime)
Set the prefix lifetime timer.
void net_if_unregister_link_cb(struct net_if_link_cb *link)
Unregister a link callback.
bool net_if_ipv4_router_rm(struct net_if_router *router)
Remove IPv4 router from the system.
static bool net_if_is_ip_offloaded(struct net_if *iface)
Return the IP offload status.
Definition net_if.h:1135
bool net_if_ipv6_maddr_rm(struct net_if *iface, const struct net_in6_addr *addr)
Remove an IPv6 multicast address from an interface.
static bool net_if_is_dormant(struct net_if *iface)
Check if the interface is dormant.
Definition net_if.h:3251
struct net_if * net_if_get_first_wifi(void)
Get first Wi-Fi network interface.
struct net_in_addr * net_if_ipv4_get_ll(struct net_if *iface, enum net_addr_state addr_state)
Get a IPv4 link local address in a given state.
bool net_if_is_ethernet(struct net_if *iface)
Check if the network interface is cabled ethernet.
uint8_t net_if_ipv4_get_mcast_ttl(struct net_if *iface)
Get IPv4 multicast time-to-live value specified for a given interface.
static uint32_t net_if_ipv6_get_base_reachable_time(struct net_if *iface)
Get IPv6 base reachable time for a given interface.
Definition net_if.h:2169
struct net_if_mcast_addr * net_if_ipv4_maddr_add(struct net_if *iface, const struct net_in_addr *addr)
Add a IPv4 multicast address to an interface.
void(* net_if_ip_maddr_cb_t)(struct net_if *iface, struct net_if_mcast_addr *maddr, void *user_data)
Callback used while iterating over network interface multicast IP addresses.
Definition net_if.h:1744
struct net_if * net_if_get_by_index(int index)
Get interface according to index.
enum net_verdict net_if_recv_data(struct net_if *iface, struct net_pkt *pkt)
Input a packet through a net iface.
struct net_if * net_if_get_first_by_type(const struct net_l2 *l2)
Get the first network interface according to its type.
struct net_in_addr * net_if_ipv4_get_global_addr(struct net_if *iface, enum net_addr_state addr_state)
Get a IPv4 global address in a given state.
static void net_if_set_mtu(struct net_if *iface, uint16_t mtu)
Set an network interface's MTU.
Definition net_if.h:1469
struct net_in6_addr * net_if_ipv6_get_ll(struct net_if *iface, enum net_addr_state addr_state)
Get a IPv6 link local address in a given state.
uint8_t net_if_ipv4_get_ttl(struct net_if *iface)
Get IPv4 time-to-live value specified for a given interface.
static bool net_if_is_up(struct net_if *iface)
Check if interface is up and running.
Definition net_if.h:3151
struct net_if_addr * net_if_ipv4_addr_add(struct net_if *iface, const struct net_in_addr *addr, enum net_addr_type addr_type, uint32_t vlifetime)
Add a IPv4 address to an interface.
static void net_if_ipv6_set_reachable_time(struct net_if_ipv6 *ipv6)
Set IPv6 reachable time for a given interface.
Definition net_if.h:2227
static enum net_verdict net_if_send_data(struct net_if *iface, struct net_pkt *pkt)
Send a packet through a net iface.
Definition net_if.h:1033
bool net_if_ipv4_set_gw_by_index(int index, const struct net_in_addr *gw)
Set IPv4 gateway for an interface index.
int net_if_config_ipv4_put(struct net_if *iface)
Release network interface IPv4 config.
void net_if_dormant_on(struct net_if *iface)
Mark interface as dormant.
struct net_in6_addr * net_if_ipv6_get_ll_addr(enum net_addr_state state, struct net_if **iface)
Return link local IPv6 address from the first interface that has a link local address matching give s...
int net_if_config_ipv6_put(struct net_if *iface)
Release network interface IPv6 config.
static struct net_if * net_if_ipv6_select_src_iface_addr(const struct net_in6_addr *dst, const struct net_in6_addr **src_addr)
Get a network interface that should be used when sending IPv6 network data to destination.
Definition net_if.h:2381
struct net_if_router * net_if_ipv6_router_add(struct net_if *iface, const struct net_in6_addr *addr, bool is_default, uint16_t router_lifetime)
Add IPv6 router to the system.
net_if_checksum_type
Type of checksum for which support in the interface will be queried.
Definition net_if.h:3026
void net_if_ipv6_dad_failed(struct net_if *iface, const struct net_in6_addr *addr)
Stop IPv6 Duplicate Address Detection (DAD) procedure if we find out that our IPv6 address is already...
void net_if_mcast_mon_register(struct net_if_mcast_monitor *mon, struct net_if *iface, net_if_mcast_callback_t cb)
Register a multicast monitor.
bool net_if_ipv4_addr_mask_cmp(struct net_if *iface, const struct net_in_addr *addr)
Check if the given IPv4 address belongs to local subnet.
void net_if_ipv4_set_mcast_ttl(struct net_if *iface, uint8_t ttl)
Set IPv4 multicast time-to-live value specified to a given interface.
static void net_if_start_dad(struct net_if *iface)
Start duplicate address detection procedure.
Definition net_if.h:1315
void net_if_foreach(net_if_cb_t cb, void *user_data)
Go through all the network interfaces and call callback for each interface.
struct net_if_ipv6_prefix * net_if_ipv6_prefix_lookup(struct net_if *iface, const struct net_in6_addr *addr, uint8_t len)
Check if this IPv6 prefix belongs to this interface.
struct net_if_ipv6_prefix * net_if_ipv6_prefix_get(struct net_if *iface, const struct net_in6_addr *addr)
Return prefix that corresponds to this IPv6 address.
static void net_if_unset_promisc(struct net_if *iface)
Set network interface into normal mode.
Definition net_if.h:3361
static void net_if_socket_offload_set(struct net_if *iface, net_socket_create_t socket_offload)
Set the function to create an offloaded socket.
Definition net_if.h:1232
static uint32_t net_if_ipv6_get_reachable_time(struct net_if *iface)
Get IPv6 reachable timeout specified for a given interface.
Definition net_if.h:2194
static bool net_if_is_promisc(struct net_if *iface)
Check if promiscuous mode is set or not.
Definition net_if.h:3378
static bool net_if_ipv4_maddr_is_joined(struct net_if_mcast_addr *addr)
Check if given multicast address is joined or not.
Definition net_if.h:2650
static void net_if_ipv6_prefix_set_lf(struct net_if_ipv6_prefix *prefix, bool is_infinite)
Set the infinite status of the prefix.
Definition net_if.h:1931
bool net_if_ipv4_set_netmask_by_addr(struct net_if *iface, const struct net_in_addr *addr, const struct net_in_addr *netmask)
Set IPv4 netmask for an interface index for a given address.
bool net_if_is_wifi(struct net_if *iface)
Check if the network interface supports Wi-Fi.
bool net_if_ipv4_set_netmask_by_addr_by_index(int index, const struct net_in_addr *addr, const struct net_in_addr *netmask)
Set IPv4 netmask for an interface index for a given address.
void net_if_unregister_timestamp_cb(struct net_if_timestamp_cb *handle)
Unregister a timestamp callback.
bool net_if_ipv4_maddr_rm(struct net_if *iface, const struct net_in_addr *addr)
Remove an IPv4 multicast address from an interface.
void net_if_register_link_cb(struct net_if_link_cb *link, net_if_link_callback_t cb)
Register a link callback.
void net_if_call_link_cb(struct net_if *iface, struct net_linkaddr *lladdr, int status)
Call a link callback function.
int net_if_ipv6_addr_lookup_by_index(const struct net_in6_addr *addr)
Check if this IPv6 address belongs to one of the interface indices.
void net_if_ipv6_router_update_lifetime(struct net_if_router *router, uint16_t lifetime)
Update validity lifetime time of a router.
void net_if_ipv4_addr_foreach(struct net_if *iface, net_if_ip_addr_cb_t cb, void *user_data)
Go through all IPv4 addresses on a network interface and call callback for each used address.
struct net_in_addr net_if_ipv4_get_netmask_by_addr(struct net_if *iface, const struct net_in_addr *addr)
Get IPv4 netmask related to an address of an interface.
static void net_if_stop_rs(struct net_if *iface)
Stop neighbor discovery.
Definition net_if.h:1337
uint32_t net_if_ipv6_calc_reachable_time(struct net_if_ipv6 *ipv6)
Calculate next reachable time value for IPv6 reachable time.
static void net_if_ipv6_set_base_reachable_time(struct net_if *iface, uint32_t reachable_time)
Set IPv6 reachable time for a given interface.
Definition net_if.h:2138
struct net_if * net_if_select_src_iface(const struct net_sockaddr *dst)
Get a network interface that should be used when sending IPv6 or IPv4 network data to destination.
void(* net_if_ip_addr_cb_t)(struct net_if *iface, struct net_if_addr *addr, void *user_data)
Callback used while iterating over network interface IP addresses.
Definition net_if.h:1700
void net_if_ipv6_maddr_foreach(struct net_if *iface, net_if_ip_maddr_cb_t cb, void *user_data)
Go through all IPv6 multicast addresses on a network interface and call callback for each used addres...
struct net_if_mcast_addr * net_if_ipv4_maddr_lookup(const struct net_in_addr *addr, struct net_if **iface)
Check if this IPv4 multicast address belongs to a specific interface or one of the interfaces.
static bool net_if_flag_test_and_clear(struct net_if *iface, enum net_if_flag value)
Test and clear a value in network interface flags.
Definition net_if.h:902
void net_if_start_rs(struct net_if *iface)
Start neighbor discovery and send router solicitation message.
static int net_if_oper_state_change_time(struct net_if *iface, int64_t *change_time)
Get an operational state change time of an interface.
Definition net_if.h:994
static bool net_if_ipv6_maddr_is_joined(struct net_if_mcast_addr *addr)
Check if given multicast address is joined or not.
Definition net_if.h:1856
struct net_if_router * net_if_ipv6_router_find_default(struct net_if *iface, const struct net_in6_addr *addr)
Find default router for this IPv6 address.
static bool net_if_need_calc_rx_checksum(struct net_if *iface, enum net_if_checksum_type chksum_type)
Check if received network packet checksum calculation can be avoided or not.
Definition net_if.h:3063
void(* net_if_cb_t)(struct net_if *iface, void *user_data)
Callback used while iterating over network interfaces.
Definition net_if.h:3124
struct net_if_router * net_if_ipv6_router_lookup(struct net_if *iface, const struct net_in6_addr *addr)
Check if IPv6 address is one of the routers configured in the system.
static uint16_t net_if_get_mtu(struct net_if *iface)
Get an network interface's MTU.
Definition net_if.h:1452
bool net_if_ipv6_addr_rm(struct net_if *iface, const struct net_in6_addr *addr)
Remove an IPv6 address from an interface.
void net_if_ipv6_maddr_leave(struct net_if *iface, struct net_if_mcast_addr *addr)
Mark a given multicast address to be left.
void net_if_mcast_mon_unregister(struct net_if_mcast_monitor *mon)
Unregister a multicast monitor.
struct net_if_mcast_addr * net_if_ipv6_maddr_lookup(const struct net_in6_addr *addr, struct net_if **iface)
Check if this IPv6 multicast address belongs to a specific interface or one of the interfaces.
bool net_if_ipv6_addr_add_by_index(int index, const struct net_in6_addr *addr, enum net_addr_type addr_type, uint32_t vlifetime)
Add a IPv6 address to an interface by index.
static void net_if_ipv6_set_retrans_timer(struct net_if *iface, uint32_t retrans_timer)
Set IPv6 retransmit timer for a given interface.
Definition net_if.h:2246
void net_if_call_timestamp_cb(struct net_pkt *pkt)
Call a timestamp callback function.
struct net_if * net_if_lookup_by_dev(const struct device *dev)
Find an interface from it's related device.
bool net_if_ipv6_addr_rm_by_index(int index, const struct net_in6_addr *addr)
Remove an IPv6 address from an interface by index.
void net_if_router_rm(struct net_if_router *router)
Remove a router from the system.
int net_if_ipv4_route_add(struct net_if *iface, const struct net_in_addr *addr, uint8_t mask_len, const struct net_in_addr *nexthop, uint32_t lifetime)
Add an IPv4 route to the system routing table.
static uint32_t net_if_ipv6_get_retrans_timer(struct net_if *iface)
Get IPv6 retransmit timer specified for a given interface.
Definition net_if.h:2272
net_if_oper_state
Network interface operational status (RFC 2863).
Definition net_if.h:310
static bool net_if_flag_is_set(struct net_if *iface, enum net_if_flag value)
Check if a value in network interface flags is set.
Definition net_if.h:922
static struct net_if_config * net_if_get_config(struct net_if *iface)
Return network configuration for this network interface.
Definition net_if.h:1298
void net_if_ipv4_maddr_join(struct net_if *iface, struct net_if_mcast_addr *addr)
Mark a given multicast address to be joined.
struct net_if_addr * net_if_ipv6_addr_lookup_by_iface(struct net_if *iface, const struct net_in6_addr *addr)
Check if this IPv6 address belongs to this specific interfaces.
static void net_if_addr_set_lf(struct net_if_addr *ifaddr, bool is_infinite)
Set the infinite status of the network interface address.
Definition net_if.h:1487
net_if_flag
Network interface flags.
Definition net_if.h:254
int net_if_ipv4_addr_lookup_by_index(const struct net_in_addr *addr)
Check if this IPv4 address belongs to one of the interface indices.
static const struct net_in_addr * net_if_ipv4_select_src_addr(struct net_if *iface, const struct net_in_addr *dst)
Get a IPv4 source address that should be used when sending network data to destination.
Definition net_if.h:2841
void net_if_ipv4_maddr_foreach(struct net_if *iface, net_if_ip_maddr_cb_t cb, void *user_data)
Go through all IPv4 multicast addresses on a network interface and call callback for each used addres...
static const struct device * net_if_get_device(struct net_if *iface)
Get an network interface's device.
Definition net_if.h:1094
bool net_if_is_offloaded(struct net_if *iface)
Return offload status of a given network interface.
int(* net_socket_create_t)(int, int, int)
A function prototype to create an offloaded socket.
Definition net_if.h:662
void net_if_ipv6_addr_update_lifetime(struct net_if_addr *ifaddr, uint32_t vlifetime)
Update validity lifetime time of an IPv6 address.
static void net_if_offload_set(struct net_if *iface, struct net_offload *offload)
Set the IP offload plugin.
Definition net_if.h:1186
static bool net_if_is_socket_offloaded(struct net_if *iface)
Return the socket offload status.
Definition net_if.h:1209
struct net_in6_addr * net_if_ipv6_get_global_addr(enum net_addr_state state, struct net_if **iface)
Return global IPv6 address from the first interface that has a global IPv6 address matching the given...
static void net_if_ipv6_set_mcast_hop_limit(struct net_if *iface, uint8_t hop_limit)
Set the default IPv6 multicast hop limit of a given interface.
Definition net_if.h:2112
struct net_if * net_if_get_wifi_sap(void)
Get first Wi-Fi network Soft-AP interface.
static int net_if_set_promisc(struct net_if *iface)
Set network interface into promiscuous mode.
Definition net_if.h:3345
static const struct net_l2 * net_if_l2(struct net_if *iface)
Get a pointer to the interface L2.
Definition net_if.h:1048
static net_socket_create_t net_if_socket_offload(struct net_if *iface)
Return the function to create an offloaded socket.
Definition net_if.h:1256
static void net_if_flag_clear(struct net_if *iface, enum net_if_flag value)
Clear a value in network interface flags.
Definition net_if.h:882
struct net_if_router * net_if_ipv4_router_find_default(struct net_if *iface, const struct net_in_addr *addr)
Find default router for this IPv4 address.
@ NET_IF_CHECKSUM_IPV4_ICMP
Interface supports checksum calculation for ICMP4 payload in IPv4.
Definition net_if.h:3036
@ NET_IF_CHECKSUM_IPV6_TCP
Interface supports checksum calculation for TCP payload in IPv6.
Definition net_if.h:3040
@ NET_IF_CHECKSUM_IPV6_UDP
Interface supports checksum calculation for UDP payload in IPv6.
Definition net_if.h:3043
@ NET_IF_CHECKSUM_IPV4_HEADER
Interface supports IP version 4 header checksum calculation.
Definition net_if.h:3028
@ NET_IF_CHECKSUM_IPV4_TCP
Interface supports checksum calculation for TCP payload in IPv4.
Definition net_if.h:3030
@ NET_IF_CHECKSUM_IPV6_HEADER
Interface supports IP version 6 header checksum calculation.
Definition net_if.h:3038
@ NET_IF_CHECKSUM_IPV6_ICMP
Interface supports checksum calculation for ICMP6 payload in IPv6.
Definition net_if.h:3046
@ NET_IF_CHECKSUM_IPV4_UDP
Interface supports checksum calculation for UDP payload in IPv4.
Definition net_if.h:3033
@ NET_IF_OPER_TESTING
Training mode.
Definition net_if.h:315
@ NET_IF_OPER_DORMANT
Waiting external action.
Definition net_if.h:316
@ NET_IF_OPER_UP
Interface is up.
Definition net_if.h:317
@ NET_IF_OPER_NOTPRESENT
Hardware missing.
Definition net_if.h:312
@ NET_IF_OPER_UNKNOWN
Initial (unknown) value.
Definition net_if.h:311
@ NET_IF_OPER_DOWN
Interface is down.
Definition net_if.h:313
@ NET_IF_OPER_LOWERLAYERDOWN
Lower layer interface is down.
Definition net_if.h:314
@ NET_IF_NO_AUTO_START
Do not bring the interface immediately up after initialization.
Definition net_if.h:268
@ NET_IF_IPV6_NO_MLD
IPv6 Multicast Listener Discovery disabled.
Definition net_if.h:298
@ NET_IF_POINTOPOINT
Interface is pointopoint.
Definition net_if.h:259
@ NET_IF_IPV6_NO_ND
IPv6 Neighbor Discovery disabled.
Definition net_if.h:295
@ NET_IF_FORWARD_MULTICASTS
Flag defines if received multicasts of other interface are forwarded on this interface.
Definition net_if.h:277
@ NET_IF_IPV4
Interface supports IPv4.
Definition net_if.h:280
@ NET_IF_PROMISC
Interface is in promiscuous mode.
Definition net_if.h:262
@ NET_IF_DORMANT
Driver signals dormant.
Definition net_if.h:292
@ NET_IF_SUSPENDED
Power management specific: interface is being suspended.
Definition net_if.h:271
@ NET_IF_IPV6
Interface supports IPv6.
Definition net_if.h:283
@ NET_IF_UP
Interface is admin up.
Definition net_if.h:256
@ NET_IF_LOWER_UP
Driver signals L1 is up.
Definition net_if.h:289
@ NET_IF_RUNNING
Interface up and running (ready to receive and transmit).
Definition net_if.h:286
@ NET_IF_NO_TX_LOCK
Mutex locking on TX data path disabled on the interface.
Definition net_if.h:301
net_link_type
Type of the link address.
Definition net_linkaddr.h:58
static int net_linkaddr_create(struct net_linkaddr *lladdr, const uint8_t *addr, uint8_t len, enum net_link_type type)
Create a link address structure.
Definition net_linkaddr.h:179
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:52
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:42
#define IF_ENABLED(_flag, _code)
Insert code if _flag is defined and equals 1.
Definition util_macro.h:278
#define EINVAL
Invalid argument.
Definition errno.h:61
#define ENOTSUP
Unsupported value.
Definition errno.h:115
#define EPERM
Not owner.
Definition errno.h:40
Hostname configuration definitions.
#define NULL
Definition iar_missing_defs.h:20
IPv4 Autoconfiguration.
net_ipv4_autoconf_state
Current state of IPv4 Autoconfiguration.
Definition ipv4_autoconf.h:15
Network core definitions.
IPv6 and IPv4 definitions.
Public API for network L2 interface.
Public API for network link address.
Network statistics.
Network timer with wrap around.
flags
Definition parser.h:97
state
Definition parser_state.h:29
Header file for the single-linked list API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT64_TYPE__ int64_t
Definition stdint.h:75
__INT16_TYPE__ int16_t
Definition stdint.h:73
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
Kernel FIFO structure.
Definition kernel.h:3023
Kernel mutex structure.
Definition kernel.h:3572
Semaphore structure.
Definition kernel.h:3798
Thread Structure.
Definition thread.h:259
Kernel timeout type.
Definition clock.h:65
Kernel timepoint type.
Definition clock.h:291
DHCPv6 client configuration parameters.
Definition dhcpv6.h:63
Network Interface unicast IPv4 address and netmask.
Definition net_if.h:482
struct net_in_addr netmask
Netmask.
Definition net_if.h:486
struct net_if_addr ipv4
IPv4 address.
Definition net_if.h:484
Network Interface unicast IP addresses.
Definition net_if.h:56
struct net_addr address
IP address.
Definition net_if.h:58
uint8_t is_mesh_local
Is this IP address usage limited to the subnet (mesh) or not.
Definition net_if.h:143
uint8_t is_temporary
Is this IP address temporary and generated for example by IPv6 privacy extension (RFC 8981).
Definition net_if.h:148
enum net_addr_state addr_state
What is the current state of the address.
Definition net_if.h:73
uint8_t is_infinite
Is the IP address valid forever.
Definition net_if.h:137
atomic_t atomic_ref
Reference counter.
Definition net_if.h:63
uint8_t is_added
Was this address added or not.
Definition net_if.h:151
enum net_addr_type addr_type
How the IP address was set.
Definition net_if.h:70
uint8_t is_used
Is this IP address used or not.
Definition net_if.h:140
IP and other configuration related data for network interface.
Definition net_if.h:595
Network Interface Device structure.
Definition net_if.h:680
Network interface IP address configuration.
Definition net_if.h:582
IPv4 configuration.
Definition net_if.h:490
uint8_t mcast_ttl
IPv4 time-to-live for multicast packets.
Definition net_if.h:504
struct net_if_addr_ipv4 unicast[NET_IF_MAX_IPV4_ADDR]
Unicast IP addresses.
Definition net_if.h:492
struct net_in_addr gw
Gateway.
Definition net_if.h:498
uint8_t ttl
IPv4 time-to-live.
Definition net_if.h:501
struct net_if_mcast_addr mcast[NET_IF_MAX_IPV4_MADDR]
Multicast IP addresses.
Definition net_if.h:495
Network Interface IPv6 prefixes.
Definition net_if.h:198
struct net_if * iface
Backpointer to network interface where this prefix is used.
Definition net_if.h:206
uint8_t is_infinite
Is the IP prefix valid forever.
Definition net_if.h:212
uint8_t len
Prefix length.
Definition net_if.h:209
uint8_t is_used
Is this prefix used or not.
Definition net_if.h:215
struct net_timeout lifetime
Prefix lifetime.
Definition net_if.h:200
struct net_in6_addr prefix
IPv6 prefix.
Definition net_if.h:203
IPv6 configuration.
Definition net_if.h:337
struct net_if_ipv6_prefix prefix[NET_IF_MAX_IPV6_PREFIX]
Prefixes.
Definition net_if.h:345
uint32_t base_reachable_time
Default reachable time (RFC 4861, page 52).
Definition net_if.h:348
uint8_t hop_limit
IPv6 hop limit.
Definition net_if.h:386
struct net_if_mcast_addr mcast[NET_IF_MAX_IPV6_MADDR]
Multicast IP addresses.
Definition net_if.h:342
uint32_t retrans_timer
Retransmit timer (RFC 4861, page 52).
Definition net_if.h:354
struct net_if_addr unicast[NET_IF_MAX_IPV6_ADDR]
Unicast IP addresses.
Definition net_if.h:339
uint8_t mcast_hop_limit
IPv6 multicast hop limit.
Definition net_if.h:389
uint32_t reachable_time
Reachable time (RFC 4861, page 20).
Definition net_if.h:351
Network Interface multicast IP addresses.
Definition net_if.h:161
struct net_addr address
IP address.
Definition net_if.h:163
uint8_t is_joined
Did we join to this group.
Definition net_if.h:188
sys_snode_t rejoin_node
Rejoining multicast groups list node.
Definition net_if.h:171
atomic_t atomic_ref
Reference counter.
Definition net_if.h:168
uint8_t is_used
Is this multicast IP address used or not.
Definition net_if.h:185
Multicast monitor handler struct.
Definition net_if.h:1800
sys_snode_t node
Node information for the slist.
Definition net_if.h:1802
net_if_mcast_callback_t cb
Multicast callback.
Definition net_if.h:1808
struct net_if * iface
Network interface.
Definition net_if.h:1805
Information about routers in the system.
Definition net_if.h:225
struct net_if * iface
Network interface the router is connected to.
Definition net_if.h:233
uint8_t is_default
Is default router.
Definition net_if.h:245
uint16_t lifetime
Router lifetime.
Definition net_if.h:239
uint8_t is_infinite
Is the router valid forever.
Definition net_if.h:248
uint8_t is_used
Is this router used or not.
Definition net_if.h:242
struct net_addr address
IP address.
Definition net_if.h:230
sys_snode_t node
Slist lifetime timer node.
Definition net_if.h:227
uint32_t life_start
Router life timer start.
Definition net_if.h:236
Timestamp callback handler struct.
Definition net_if.h:3278
sys_snode_t node
Node information for the slist.
Definition net_if.h:3280
struct net_if * iface
Net interface for which the callback is needed.
Definition net_if.h:3290
struct net_pkt * pkt
Packet for which the callback is needed.
Definition net_if.h:3285
net_if_timestamp_callback_t cb
Timestamp callback.
Definition net_if.h:3293
Network Interface structure.
Definition net_if.h:744
IPv6 address struct.
Definition net_ip.h:144
IPv4 address struct.
Definition net_ip.h:156
Network L2 structure.
Definition net_l2.h:58
Hardware link address structure.
Definition net_linkaddr.h:83
Network packet.
Definition net_pkt.h:119
Generic sockaddr struct.
Definition net_ip.h:455
All network statistics in one struct.
Definition net_stats.h:423
Generic struct for handling network timeouts.
Definition net_timeout.h:57
Network traffic class.
Definition net_if.h:639
k_thread_stack_t * stack
Stack for this handler.
Definition net_if.h:653
struct k_thread handler
Traffic class handler thread.
Definition net_if.h:650
struct k_fifo fifo
Fifo for handling this Tx or Rx packet.
Definition net_if.h:641
Prometheus collector definition.
Definition collector.h:50
Type used to represent a Prometheus metric base.
Definition metric.h:47
Iterable sections helpers.