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
52#define NET_IF_IPV6_DAD_NONCE_LEN 6U
53
61 struct net_addr address;
62
67
68#if defined(CONFIG_NET_NATIVE_IPV6)
69 struct net_timeout lifetime;
70#endif
71
74
77
78#if defined(CONFIG_NET_NATIVE_IPV6)
79#if defined(CONFIG_NET_IPV6_PE)
83 uint32_t addr_create_time;
84
87 uint32_t addr_preferred_lifetime;
88
93 int32_t addr_timeout;
94#endif
95#endif /* CONFIG_NET_NATIVE_IPV6 */
96
97 union {
98#if defined(CONFIG_NET_IPV6_DAD)
99 struct {
101 sys_snode_t dad_node;
102
104 sys_snode_t dad_need_node;
105
107 uint32_t dad_start;
108
110 uint8_t dad_count;
111
117 uint8_t dad_tx_failures;
118
121 };
122#endif /* CONFIG_NET_IPV6_DAD */
123#if defined(CONFIG_NET_IPV4_ACD)
124 struct {
126 sys_snode_t acd_node;
127
129 sys_snode_t acd_need_node;
130
132 k_timepoint_t acd_timeout;
133
135 uint8_t acd_count;
136
138 uint8_t acd_state;
139 };
140#endif /* CONFIG_NET_IPV4_ACD */
141 uint8_t _dummy;
142 };
143
144#if defined(CONFIG_NET_IPV6_DAD) || defined(CONFIG_NET_IPV4_ACD)
146 uint8_t ifindex;
147#endif
148
151
154
157
162
165
166 uint8_t _unused : 3;
167};
168
176 struct net_addr address;
177
182
185
186#if defined(CONFIG_NET_IPV4_IGMPV3)
188 struct net_addr sources[CONFIG_NET_IF_MCAST_IPV4_SOURCE_COUNT];
189
191 uint16_t sources_len;
192
194 uint8_t record_type;
195#endif
196
199
202
203 uint8_t _unused : 6;
204};
205
214
217
219 struct net_if *iface;
220
223
226
229
232
233 uint8_t _unused : 5;
234};
235
244
246 struct net_addr address;
247
249 struct net_if *iface;
250
253
256
259
262
265
266 uint8_t _unused : 5;
267};
268
324
335
336#if defined(CONFIG_NET_OFFLOAD)
337struct net_offload;
338#endif /* CONFIG_NET_OFFLOAD */
339
341#if defined(CONFIG_NET_IPV6)
342#define NET_IF_MAX_IPV6_ADDR CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT
343#define NET_IF_MAX_IPV6_MADDR CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT
344#define NET_IF_MAX_IPV6_PREFIX CONFIG_NET_IF_IPV6_PREFIX_COUNT
345#else
346#define NET_IF_MAX_IPV6_ADDR 0
347#define NET_IF_MAX_IPV6_MADDR 0
348#define NET_IF_MAX_IPV6_PREFIX 0
349#endif
350/* @endcond */
351
355 struct net_if_addr unicast[NET_IF_MAX_IPV6_ADDR];
356
358 struct net_if_mcast_addr mcast[NET_IF_MAX_IPV6_MADDR];
359
361 struct net_if_ipv6_prefix prefix[NET_IF_MAX_IPV6_PREFIX];
362
365
368
371
372#if defined(CONFIG_NET_IPV6_IID_STABLE)
374 struct net_if_addr *iid;
375
379 uint32_t network_counter;
380#endif /* CONFIG_NET_IPV6_IID_STABLE */
381
382#if defined(CONFIG_NET_IPV6_PE)
387 uint32_t desync_factor;
388#endif /* CONFIG_NET_IPV6_PE */
389
390#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
392 sys_snode_t rs_node;
393
394 /* RS start time */
395 uint32_t rs_start;
396
398 uint8_t rs_count;
399#endif
400
403
406
407#if defined(CONFIG_NET_IPV6_ND_RA_TX) && defined(CONFIG_NET_NATIVE_IPV6)
411 int64_t ra_last_sent;
412
416 int64_t ra_pending_at;
417
421 uint8_t is_router : 1;
422#endif
423};
424
425#if defined(CONFIG_NET_DHCPV6) && defined(CONFIG_NET_NATIVE_IPV6)
427struct net_if_dhcpv6 {
429 sys_snode_t node;
430
432 struct net_dhcpv6_duid_storage clientid;
433
435 struct net_dhcpv6_duid_storage serverid;
436
438 enum net_dhcpv6_state state;
439
441 struct net_dhcpv6_params params;
442
444 uint64_t timeout;
445
447 uint64_t exchange_start;
448
450 uint64_t t1;
451
453 uint64_t t2;
454
458 uint64_t expire;
459
461 uint32_t addr_iaid;
462
464 uint32_t prefix_iaid;
465
467 uint32_t retransmit_timeout;
468
470 uint32_t sol_max_rt;
471
473 uint32_t inf_max_rt;
474
478 uint32_t info_refresh_time;
479
481 int16_t server_preference;
482
484 uint8_t retransmissions;
485
487 uint8_t tid[DHCPV6_TID_SIZE];
488
490 uint8_t prefix_len;
491
493 struct net_in6_addr prefix;
494
496 struct net_in6_addr addr;
497};
498#endif /* defined(CONFIG_NET_DHCPV6) && defined(CONFIG_NET_NATIVE_IPV6) */
499
501#if defined(CONFIG_NET_IPV4)
502#define NET_IF_MAX_IPV4_ADDR CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT
503#define NET_IF_MAX_IPV4_MADDR CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT
504#else
505#define NET_IF_MAX_IPV4_ADDR 0
506#define NET_IF_MAX_IPV4_MADDR 0
507#endif
509
521
525 struct net_if_addr_ipv4 unicast[NET_IF_MAX_IPV4_ADDR];
526
528 struct net_if_mcast_addr mcast[NET_IF_MAX_IPV4_MADDR];
529
532
535
538
539#if defined(CONFIG_NET_IPV4_ACD)
541 uint8_t conflict_cnt;
542#endif
543};
544
545#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
546struct net_if_dhcpv4 {
548 sys_snode_t node;
549
551 int64_t timer_start;
552
554 uint32_t request_time;
555
556 uint32_t xid;
557
559 uint32_t lease_time;
560
562 uint32_t renewal_time;
563
565 uint32_t rebinding_time;
566
568 struct net_in_addr server_id;
569
571 struct net_in_addr requested_ip;
572
574 struct net_in_addr netmask;
575
580 enum net_dhcpv4_state state;
581
583 uint8_t attempts;
584
586 struct net_in_addr request_server_addr;
587
589 struct net_in_addr response_src_addr;
590
591#ifdef CONFIG_NET_DHCPV4_OPTION_NTP_SERVER
593 struct net_in_addr ntp_addr;
594#endif
595};
596#endif /* CONFIG_NET_DHCPV4 */
597
598#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
599struct net_if_ipv4_autoconf {
601 struct net_if *iface;
602
604 struct net_in_addr requested_ip;
605
609};
610#endif /* CONFIG_NET_IPV4_AUTO */
611
615struct net_if_ip {
616#if defined(CONFIG_NET_IPV6)
617 struct net_if_ipv6 *ipv6;
618#endif /* CONFIG_NET_IPV6 */
619
620#if defined(CONFIG_NET_IPV4)
621 struct net_if_ipv4 *ipv4;
622#endif /* CONFIG_NET_IPV4 */
623};
624
629#if defined(CONFIG_NET_IP)
631 struct net_if_ip ip;
632#endif
633
634#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
635 struct net_if_dhcpv4 dhcpv4;
636#endif /* CONFIG_NET_DHCPV4 */
637
638#if defined(CONFIG_NET_DHCPV6) && defined(CONFIG_NET_NATIVE_IPV6)
639 struct net_if_dhcpv6 dhcpv6;
640#endif /* CONFIG_NET_DHCPV6 */
641
642#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
643 struct net_if_ipv4_autoconf ipv4auto;
644#endif /* CONFIG_NET_IPV4_AUTO */
645
646#if defined(CONFIG_NET_L2_VIRTUAL)
651 sys_slist_t virtual_interfaces;
652#endif /* CONFIG_NET_L2_VIRTUAL */
653
654#if defined(CONFIG_NET_INTERFACE_NAME)
659 char name[CONFIG_NET_INTERFACE_NAME_LEN + 1];
660#endif
661};
662
674 struct k_fifo fifo;
675
676#if NET_TC_COUNT > 1 || defined(CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO) \
677 || defined(CONFIG_NET_TC_RX_SKIP_FOR_HIGH_PRIO)
679 struct k_sem fifo_slot;
680#endif
681
684
687};
688
695typedef int (*net_socket_create_t)(int, int, int);
696
718 const struct device *dev;
719
721 const struct net_l2 * const l2;
722
724 void *l2_data;
725
727 ATOMIC_DEFINE(flags, NET_IF_NUM_FLAGS);
728
730 struct net_linkaddr link_addr;
731
732#if defined(CONFIG_NET_OFFLOAD)
738 struct net_offload *offload;
739#endif /* CONFIG_NET_OFFLOAD */
740
742 uint16_t mtu;
743
744#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
748 net_socket_create_t socket_offload;
749#endif /* CONFIG_NET_SOCKETS_OFFLOAD */
750
752 enum net_if_oper_state oper_state;
753
763 int64_t oper_state_change_time;
767};
768
777struct net_if {
782 struct net_if_dev *if_dev;
783
784#if defined(CONFIG_NET_STATISTICS_PER_INTERFACE)
786 struct net_stats stats;
787
789 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS,
790 (struct prometheus_collector *collector);)
791#endif /* CONFIG_NET_STATISTICS_PER_INTERFACE */
792
794 struct net_if_config config;
795
796#if defined(CONFIG_NET_POWER_MANAGEMENT)
801 int tx_pending;
802#endif
803
805 struct k_mutex lock;
806
808 struct k_mutex tx_lock;
809
814 uint8_t pe_enabled : 1;
815
819 uint8_t pe_prefer_public : 1;
820
822 uint8_t _unused : 6;
826};
827
829
830static inline void net_if_lock(struct net_if *iface)
831{
832 NET_ASSERT(iface);
833
834 (void)k_mutex_lock(&iface->lock, K_FOREVER);
835}
836
837static inline void net_if_unlock(struct net_if *iface)
838{
839 NET_ASSERT(iface);
840
841 k_mutex_unlock(&iface->lock);
842}
843
844static inline bool net_if_flag_is_set(struct net_if *iface,
845 enum net_if_flag value);
846
847static inline void net_if_tx_lock(struct net_if *iface)
848{
849 NET_ASSERT(iface);
850
852 return;
853 }
854
855 (void)k_mutex_lock(&iface->tx_lock, K_FOREVER);
856}
857
858static inline void net_if_tx_unlock(struct net_if *iface)
859{
860 NET_ASSERT(iface);
861
863 return;
864 }
865
866 k_mutex_unlock(&iface->tx_lock);
867}
868
870
877static inline void net_if_flag_set(struct net_if *iface,
878 enum net_if_flag value)
879{
880 if (iface == NULL) {
881 return;
882 }
883
884 NET_ASSERT(iface->if_dev != NULL);
885
886 atomic_set_bit(iface->if_dev->flags, value);
887}
888
897static inline bool net_if_flag_test_and_set(struct net_if *iface,
898 enum net_if_flag value)
899{
900 if (iface == NULL) {
901 return false;
902 }
903
904 NET_ASSERT(iface->if_dev != NULL);
905
906 return atomic_test_and_set_bit(iface->if_dev->flags, value);
907}
908
915static inline void net_if_flag_clear(struct net_if *iface,
916 enum net_if_flag value)
917{
918 if (iface == NULL) {
919 return;
920 }
921
922 NET_ASSERT(iface->if_dev != NULL);
923
924 atomic_clear_bit(iface->if_dev->flags, value);
925}
926
935static inline bool net_if_flag_test_and_clear(struct net_if *iface,
936 enum net_if_flag value)
937{
938 if (iface == NULL) {
939 return false;
940 }
941
942 NET_ASSERT(iface->if_dev != NULL);
943
944 return atomic_test_and_clear_bit(iface->if_dev->flags, value);
945}
946
955static inline bool net_if_flag_is_set(struct net_if *iface,
956 enum net_if_flag value)
957{
958 if (iface == NULL) {
959 return false;
960 }
961
962 NET_ASSERT(iface->if_dev != NULL);
963
964 return atomic_test_bit(iface->if_dev->flags, value);
965}
966
976 struct net_if *iface, enum net_if_oper_state oper_state)
977{
978 if (iface == NULL) {
979 return NET_IF_OPER_UNKNOWN;
980 }
981
982 NET_ASSERT(iface->if_dev != NULL);
983
984 if (oper_state <= NET_IF_OPER_UP) {
985 iface->if_dev->oper_state = oper_state;
986 }
987
988 net_if_lock(iface);
989
990 iface->if_dev->oper_state_change_time = k_uptime_get();
991
992 net_if_unlock(iface);
993
994 return iface->if_dev->oper_state;
995}
996
1004static inline enum net_if_oper_state net_if_oper_state(struct net_if *iface)
1005{
1006 if (iface == NULL) {
1007 return NET_IF_OPER_UNKNOWN;
1008 }
1009
1010 NET_ASSERT(iface->if_dev != NULL);
1011
1012 return iface->if_dev->oper_state;
1013}
1014
1027static inline int net_if_oper_state_change_time(struct net_if *iface,
1028 int64_t *change_time)
1029{
1030 if (iface == NULL || change_time == NULL) {
1031 return -EINVAL;
1032 }
1033
1034 NET_ASSERT(iface->if_dev != NULL);
1035
1036 net_if_lock(iface);
1037
1038 *change_time = iface->if_dev->oper_state_change_time;
1039
1040 net_if_unlock(iface);
1041
1042 return 0;
1043}
1044
1055 struct net_pkt *pkt, k_timeout_t timeout);
1056
1066static inline enum net_verdict net_if_send_data(struct net_if *iface,
1067 struct net_pkt *pkt)
1068{
1070
1071 return net_if_try_send_data(iface, pkt, timeout);
1072}
1073
1081static inline const struct net_l2 *net_if_l2(struct net_if *iface)
1082{
1083 if (iface == NULL) {
1084 return NULL;
1085 }
1086
1087 NET_ASSERT(iface->if_dev != NULL);
1088
1089 return iface->if_dev->l2;
1090}
1091
1100enum net_verdict net_if_recv_data(struct net_if *iface, struct net_pkt *pkt);
1101
1109static inline void *net_if_l2_data(struct net_if *iface)
1110{
1111 if (iface == NULL) {
1112 return NULL;
1113 }
1114
1115 NET_ASSERT(iface->if_dev != NULL);
1116
1117 return iface->if_dev->l2_data;
1118}
1119
1127static inline const struct device *net_if_get_device(struct net_if *iface)
1128{
1129 if (iface == NULL) {
1130 return NULL;
1131 }
1132
1133 NET_ASSERT(iface->if_dev != NULL);
1134
1135 return iface->if_dev->dev;
1136}
1137
1145void net_if_try_queue_tx(struct net_if *iface, struct net_pkt *pkt, k_timeout_t timeout);
1146
1154static inline void net_if_queue_tx(struct net_if *iface, struct net_pkt *pkt)
1155{
1157
1158 net_if_try_queue_tx(iface, pkt, timeout);
1159}
1160
1168static inline bool net_if_is_ip_offloaded(struct net_if *iface)
1169{
1170#if defined(CONFIG_NET_OFFLOAD)
1171 __ASSERT_NO_MSG(iface == NULL || iface->if_dev != NULL);
1172 return (iface != NULL && iface->if_dev->offload != NULL);
1173#else
1174 ARG_UNUSED(iface);
1175
1176 return false;
1177#endif
1178}
1179
1187bool net_if_is_offloaded(struct net_if *iface);
1188
1196static inline struct net_offload *net_if_offload(struct net_if *iface)
1197{
1198#if defined(CONFIG_NET_OFFLOAD)
1199 if (iface == NULL) {
1200 return NULL;
1201 }
1202
1203 NET_ASSERT(iface->if_dev != NULL);
1204
1205 return iface->if_dev->offload;
1206#else
1207 ARG_UNUSED(iface);
1208
1209 return NULL;
1210#endif
1211}
1212
1219static inline void net_if_offload_set(struct net_if *iface, struct net_offload *offload)
1220{
1221#if defined(CONFIG_NET_OFFLOAD)
1222 if (iface == NULL) {
1223 return;
1224 }
1225
1226 NET_ASSERT(iface->if_dev != NULL);
1227
1228 iface->if_dev->offload = offload;
1229#else
1230 ARG_UNUSED(iface);
1231 ARG_UNUSED(offload);
1232#endif
1233}
1234
1242static inline bool net_if_is_socket_offloaded(struct net_if *iface)
1243{
1244#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
1245 if (iface == NULL) {
1246 return false;
1247 }
1248
1249 NET_ASSERT(iface->if_dev != NULL);
1250
1251 return (iface->if_dev->socket_offload != NULL);
1252#else
1253 ARG_UNUSED(iface);
1254
1255 return false;
1256#endif
1257}
1258
1265static inline void net_if_socket_offload_set(
1266 struct net_if *iface, net_socket_create_t socket_offload)
1267{
1268#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
1269 if (iface == NULL) {
1270 return;
1271 }
1272
1273 NET_ASSERT(iface->if_dev != NULL);
1274
1275 iface->if_dev->socket_offload = socket_offload;
1276#else
1277 ARG_UNUSED(iface);
1278 ARG_UNUSED(socket_offload);
1279#endif
1280}
1281
1290{
1291#if defined(CONFIG_NET_SOCKETS_OFFLOAD)
1292 if (iface == NULL) {
1293 return NULL;
1294 }
1295
1296 NET_ASSERT(iface->if_dev != NULL);
1297
1298 return iface->if_dev->socket_offload;
1299#else
1300 ARG_UNUSED(iface);
1301
1302 return NULL;
1303#endif
1304}
1305
1313static inline struct net_linkaddr *net_if_get_link_addr(struct net_if *iface)
1314{
1315 if (iface == NULL) {
1316 return NULL;
1317 }
1318
1319 NET_ASSERT(iface->if_dev != NULL);
1320
1321 return &iface->if_dev->link_addr;
1322}
1323
1331static inline struct net_if_config *net_if_get_config(struct net_if *iface)
1332{
1333 if (iface == NULL) {
1334 return NULL;
1335 }
1336
1337 return &iface->config;
1338}
1339
1345#if defined(CONFIG_NET_IPV6_DAD) && defined(CONFIG_NET_NATIVE_IPV6)
1346void net_if_start_dad(struct net_if *iface);
1347#else
1348static inline void net_if_start_dad(struct net_if *iface)
1349{
1350 ARG_UNUSED(iface);
1351}
1352#endif
1353
1359void net_if_start_rs(struct net_if *iface);
1360
1361
1367#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
1368void net_if_stop_rs(struct net_if *iface);
1369#else
1370static inline void net_if_stop_rs(struct net_if *iface)
1371{
1372 ARG_UNUSED(iface);
1373}
1374#endif /* CONFIG_NET_IPV6_ND */
1375
1388#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
1389void net_if_nbr_reachability_hint(struct net_if *iface, const struct net_in6_addr *ipv6_addr);
1390#else
1391static inline void net_if_nbr_reachability_hint(struct net_if *iface,
1392 const struct net_in6_addr *ipv6_addr)
1393{
1394 ARG_UNUSED(iface);
1395 ARG_UNUSED(ipv6_addr);
1396}
1397#endif
1398
1409#if defined(CONFIG_NET_IPV6)
1410void net_if_ipv6_nbr_flush(struct net_if *iface);
1411#else
1412static inline void net_if_ipv6_nbr_flush(struct net_if *iface)
1413{
1414 ARG_UNUSED(iface);
1415}
1416#endif
1417
1430#if defined(CONFIG_NET_IPV6)
1431bool net_if_ipv6_nbr_rm(struct net_if *iface, const struct net_in6_addr *addr);
1432#else
1433static inline bool net_if_ipv6_nbr_rm(struct net_if *iface,
1434 const struct net_in6_addr *addr)
1435{
1436 ARG_UNUSED(iface);
1437 ARG_UNUSED(addr);
1438
1439 return false;
1440}
1441#endif
1442
1444
1445static inline int net_if_set_link_addr_unlocked(struct net_if *iface,
1446 const uint8_t *addr, uint8_t len,
1447 enum net_link_type type)
1448{
1449 int ret;
1450
1451 if (net_if_flag_is_set(iface, NET_IF_RUNNING)) {
1452 return -EPERM;
1453 }
1454
1455 if (len > sizeof(net_if_get_link_addr(iface)->addr)) {
1456 return -EINVAL;
1457 }
1458
1459 ret = net_linkaddr_create(net_if_get_link_addr(iface), addr, len, type);
1460 if (ret < 0) {
1461 return ret;
1462 }
1463
1464 net_hostname_set_postfix(addr, len);
1465
1466 return 0;
1467}
1468
1469int net_if_set_link_addr_locked(struct net_if *iface,
1470 const uint8_t *addr, uint8_t len,
1471 enum net_link_type type);
1472
1473#if CONFIG_NET_IF_LOG_LEVEL >= LOG_LEVEL_DBG
1474extern int net_if_addr_unref_debug(struct net_if *iface,
1475 net_sa_family_t family,
1476 const void *addr,
1477 struct net_if_addr **ifaddr,
1478 const char *caller, int line);
1479#define net_if_addr_unref(iface, family, addr, ifaddr) \
1480 net_if_addr_unref_debug(iface, family, addr, ifaddr, __func__, __LINE__)
1481
1482extern struct net_if_addr *net_if_addr_ref_debug(struct net_if *iface,
1483 net_sa_family_t family,
1484 const void *addr,
1485 const char *caller,
1486 int line);
1487#define net_if_addr_ref(iface, family, addr) \
1488 net_if_addr_ref_debug(iface, family, addr, __func__, __LINE__)
1489#else
1490extern int net_if_addr_unref(struct net_if *iface,
1491 net_sa_family_t family,
1492 const void *addr,
1493 struct net_if_addr **ifaddr);
1494extern struct net_if_addr *net_if_addr_ref(struct net_if *iface,
1495 net_sa_family_t family,
1496 const void *addr);
1497#endif /* CONFIG_NET_IF_LOG_LEVEL */
1498
1500
1511static inline int net_if_set_link_addr(struct net_if *iface,
1512 const uint8_t *addr, uint8_t len,
1513 enum net_link_type type)
1514{
1515#if defined(CONFIG_NET_RAW_MODE)
1516 return net_if_set_link_addr_unlocked(iface, addr, len, type);
1517#else
1518 return net_if_set_link_addr_locked(iface, addr, len, type);
1519#endif
1520}
1521
1529static inline uint16_t net_if_get_mtu(struct net_if *iface)
1530{
1531 if (iface == NULL) {
1532 return 0U;
1533 }
1534
1535 NET_ASSERT(iface->if_dev != NULL);
1536
1537 return iface->if_dev->mtu;
1538}
1539
1546static inline void net_if_set_mtu(struct net_if *iface,
1547 uint16_t mtu)
1548{
1549 if (iface == NULL) {
1550 return;
1551 }
1552
1553 NET_ASSERT(iface->if_dev != NULL);
1554
1555 iface->if_dev->mtu = mtu;
1556}
1557
1564static inline void net_if_addr_set_lf(struct net_if_addr *ifaddr,
1565 bool is_infinite)
1566{
1567 if (ifaddr == NULL) {
1568 return;
1569 }
1570
1571 ifaddr->is_infinite = is_infinite;
1572}
1573
1582
1590struct net_if *net_if_lookup_by_dev(const struct device *dev);
1591
1597void net_if_router_rm(struct net_if_router *router);
1598
1604void net_if_set_default(struct net_if *iface);
1605
1612
1621struct net_if *net_if_get_first_by_type(const struct net_l2 *l2);
1622
1630
1631#if defined(CONFIG_NET_L2_IEEE802154)
1638static inline struct net_if *net_if_get_ieee802154(void)
1639{
1640 return net_if_get_first_by_type(&NET_L2_GET_NAME(IEEE802154));
1641}
1642#endif /* CONFIG_NET_L2_IEEE802154 */
1643
1655 struct net_if_ipv6 **ipv6);
1656
1673
1674
1676struct net_if_addr *net_if_ipv6_addr_lookup_raw(const uint8_t *addr,
1677 struct net_if **ret);
1679
1689 struct net_if **iface);
1690
1692struct net_if_addr *net_if_ipv6_addr_lookup_by_iface_raw(struct net_if *iface,
1693 const uint8_t *addr);
1695
1705 const struct net_in6_addr *addr);
1706
1715__syscall int net_if_ipv6_addr_lookup_by_index(const struct net_in6_addr *addr);
1716
1728 const struct net_in6_addr *addr,
1730 uint32_t vlifetime);
1731
1742__syscall bool net_if_ipv6_addr_add_by_index(int index,
1743 const struct net_in6_addr *addr,
1745 uint32_t vlifetime);
1746
1754 uint32_t vlifetime);
1755
1764bool net_if_ipv6_addr_rm(struct net_if *iface, const struct net_in6_addr *addr);
1765
1774__syscall bool net_if_ipv6_addr_rm_by_index(int index,
1775 const struct net_in6_addr *addr);
1776
1785typedef void (*net_if_ip_addr_cb_t)(struct net_if *iface,
1786 struct net_if_addr *addr,
1787 void *user_data);
1788
1798 void *user_data);
1799
1809 const struct net_in6_addr *addr);
1810
1819bool net_if_ipv6_maddr_rm(struct net_if *iface, const struct net_in6_addr *addr);
1820
1829typedef void (*net_if_ip_maddr_cb_t)(struct net_if *iface,
1830 struct net_if_mcast_addr *maddr,
1831 void *user_data);
1832
1842 void *user_data);
1843
1844
1846struct net_if_mcast_addr *net_if_ipv6_maddr_lookup_raw(const uint8_t *maddr,
1847 struct net_if **ret);
1849
1861 struct net_if **iface);
1862
1873typedef void (*net_if_mcast_callback_t)(struct net_if *iface,
1874 const struct net_addr *addr,
1875 bool is_joined);
1876
1895
1905 struct net_if *iface,
1907
1914
1922void net_if_mcast_monitor(struct net_if *iface, const struct net_addr *addr,
1923 bool is_joined);
1924
1932 struct net_if_mcast_addr *addr);
1933
1941static inline bool net_if_ipv6_maddr_is_joined(struct net_if_mcast_addr *addr)
1942{
1943 if (addr == NULL) {
1944 return false;
1945 }
1946
1947 return addr->is_joined;
1948}
1949
1957 struct net_if_mcast_addr *addr);
1958
1968 const struct net_in6_addr *addr);
1969
1980 const struct net_in6_addr *addr,
1981 uint8_t len);
1982
1994 const struct net_in6_addr *prefix,
1995 uint8_t len,
1997
2007bool net_if_ipv6_prefix_rm(struct net_if *iface, const struct net_in6_addr *addr,
2008 uint8_t len);
2009
2017 bool is_infinite)
2018{
2019 prefix->is_infinite = is_infinite;
2020}
2021
2030
2037
2053 const struct net_in6_addr *prefix,
2054 uint8_t len, bool advertise);
2055
2069
2078
2089bool net_if_ipv6_addr_onlink(struct net_if **iface, const struct net_in6_addr *addr);
2090
2097#if defined(CONFIG_NET_NATIVE_IPV6)
2098static inline struct net_in6_addr *net_if_router_ipv6(struct net_if_router *router)
2099{
2100 if (router == NULL) {
2101 return NULL;
2102 }
2103
2104 return &router->address.in6_addr;
2105}
2106#else
2107static inline struct net_in6_addr *net_if_router_ipv6(struct net_if_router *router)
2108{
2109 static struct net_in6_addr addr;
2110
2111 ARG_UNUSED(router);
2112
2113 return &addr;
2114}
2115#endif
2116
2127 const struct net_in6_addr *addr);
2128
2139 const struct net_in6_addr *addr);
2140
2149
2161 const struct net_in6_addr *addr,
2162 bool is_default,
2163 uint16_t router_lifetime);
2164
2173
2182#if defined(CONFIG_NET_NATIVE_IPV6)
2184#else
2186{
2187 ARG_UNUSED(iface);
2188
2189 return 0;
2190}
2191#endif /* CONFIG_NET_NATIVE_IPV6 */
2192
2199#if defined(CONFIG_NET_NATIVE_IPV6)
2200void net_if_ipv6_set_hop_limit(struct net_if *iface, uint8_t hop_limit);
2201#else
2202static inline void net_if_ipv6_set_hop_limit(struct net_if *iface,
2203 uint8_t hop_limit)
2204{
2205 ARG_UNUSED(iface);
2206 ARG_UNUSED(hop_limit);
2207}
2208#endif /* CONFIG_NET_NATIVE_IPV6 */
2209
2218#if defined(CONFIG_NET_NATIVE_IPV6)
2220#else
2222{
2223 ARG_UNUSED(iface);
2224
2225 return 0;
2226}
2227#endif /* CONFIG_NET_NATIVE_IPV6 */
2228
2235#if defined(CONFIG_NET_NATIVE_IPV6)
2236void net_if_ipv6_set_mcast_hop_limit(struct net_if *iface, uint8_t hop_limit);
2237#else
2239 uint8_t hop_limit)
2240{
2241 ARG_UNUSED(iface);
2242 ARG_UNUSED(hop_limit);
2243}
2244#endif /* CONFIG_NET_NATIVE_IPV6 */
2245
2255#define NET_IPV6_MAX_REACHABLE_TIME 3600000U
2256
2265 uint32_t reachable_time)
2266{
2267#if defined(CONFIG_NET_NATIVE_IPV6)
2268 if (iface == NULL) {
2269 return;
2270 }
2271
2272 if (!iface->config.ip.ipv6) {
2273 return;
2274 }
2275
2276 if (reachable_time > NET_IPV6_MAX_REACHABLE_TIME) {
2277 reachable_time = NET_IPV6_MAX_REACHABLE_TIME;
2278 }
2279
2280 iface->config.ip.ipv6->base_reachable_time = reachable_time;
2281#else
2282 ARG_UNUSED(iface);
2283 ARG_UNUSED(reachable_time);
2284
2285#endif
2286}
2287
2296{
2297#if defined(CONFIG_NET_NATIVE_IPV6)
2298 if (iface == NULL) {
2299 return 0;
2300 }
2301
2302 if (iface->config.ip.ipv6 == NULL) {
2303 return 0;
2304 }
2305
2306 return iface->config.ip.ipv6->base_reachable_time;
2307#else
2308 ARG_UNUSED(iface);
2309 return 0;
2310#endif
2311}
2312
2321{
2322#if defined(CONFIG_NET_NATIVE_IPV6)
2323 if (iface == NULL) {
2324 return 0;
2325 }
2326
2327 if (!iface->config.ip.ipv6) {
2328 return 0;
2329 }
2330
2331 return iface->config.ip.ipv6->reachable_time;
2332#else
2333 ARG_UNUSED(iface);
2334 return 0;
2335#endif
2336}
2337
2346
2353static inline void net_if_ipv6_set_reachable_time(struct net_if_ipv6 *ipv6)
2354{
2355#if defined(CONFIG_NET_NATIVE_IPV6)
2356 if (ipv6 == NULL) {
2357 return;
2358 }
2359
2361#else
2362 ARG_UNUSED(ipv6);
2363#endif
2364}
2365
2372static inline void net_if_ipv6_set_retrans_timer(struct net_if *iface,
2373 uint32_t retrans_timer)
2374{
2375#if defined(CONFIG_NET_NATIVE_IPV6)
2376 if (iface == NULL) {
2377 return;
2378 }
2379
2380 if (!iface->config.ip.ipv6) {
2381 return;
2382 }
2383
2384 iface->config.ip.ipv6->retrans_timer = retrans_timer;
2385#else
2386 ARG_UNUSED(iface);
2387 ARG_UNUSED(retrans_timer);
2388#endif
2389}
2390
2399{
2400#if defined(CONFIG_NET_NATIVE_IPV6)
2401 if (iface == NULL) {
2402 return 0;
2403 }
2404
2405 if (!iface->config.ip.ipv6) {
2406 return 0;
2407 }
2408
2409 return iface->config.ip.ipv6->retrans_timer;
2410#else
2411 ARG_UNUSED(iface);
2412 return 0;
2413#endif
2414}
2415
2427#if defined(CONFIG_NET_IPV6)
2428const struct net_in6_addr *net_if_ipv6_select_src_addr(struct net_if *iface,
2429 const struct net_in6_addr *dst);
2430#else
2431static inline const struct net_in6_addr *net_if_ipv6_select_src_addr(
2432 struct net_if *iface, const struct net_in6_addr *dst)
2433{
2434 ARG_UNUSED(iface);
2435 ARG_UNUSED(dst);
2436
2437 return NULL;
2438}
2439#endif
2440
2454#if defined(CONFIG_NET_IPV6)
2455const struct net_in6_addr *net_if_ipv6_select_src_addr_hint(struct net_if *iface,
2456 const struct net_in6_addr *dst,
2457 int flags);
2458#else
2460 struct net_if *iface, const struct net_in6_addr *dst, int flags)
2461{
2462 ARG_UNUSED(iface);
2463 ARG_UNUSED(dst);
2464 ARG_UNUSED(flags);
2465
2466 return NULL;
2467}
2468#endif
2469
2479#if defined(CONFIG_NET_IPV6)
2480struct net_if *net_if_ipv6_select_src_iface(const struct net_in6_addr *dst);
2481#else
2483 const struct net_in6_addr *dst)
2484{
2485 ARG_UNUSED(dst);
2486
2487 return NULL;
2488}
2489#endif
2490
2503#if defined(CONFIG_NET_IPV6)
2504struct net_if *net_if_ipv6_select_src_iface_addr(const struct net_in6_addr *dst,
2505 const struct net_in6_addr **src_addr);
2506#else
2508 const struct net_in6_addr *dst, const struct net_in6_addr **src_addr)
2509{
2510 ARG_UNUSED(dst);
2511 ARG_UNUSED(src_addr);
2512
2513 return NULL;
2514}
2515#endif /* CONFIG_NET_IPV6 */
2516
2527 enum net_addr_state addr_state);
2528
2539 struct net_if **iface);
2540
2548void net_if_ipv6_dad_failed(struct net_if *iface, const struct net_in6_addr *addr);
2549
2562 struct net_if **iface);
2563
2575 struct net_if_ipv4 **ipv4);
2576
2593
2602
2609void net_if_ipv4_set_ttl(struct net_if *iface, uint8_t ttl);
2610
2619
2627
2638bool net_if_ipv4_addr_onlink(struct net_if **iface, const struct net_in_addr *addr);
2639
2649 struct net_if **iface);
2650
2652struct net_if_addr *net_if_ipv4_addr_lookup_by_iface_raw(struct net_if *iface,
2653 const uint8_t *addr);
2655
2665 const struct net_in_addr *addr);
2666
2678 const struct net_in_addr *addr,
2680 uint32_t vlifetime);
2681
2690bool net_if_ipv4_addr_rm(struct net_if *iface, const struct net_in_addr *addr);
2691
2700__syscall int net_if_ipv4_addr_lookup_by_index(const struct net_in_addr *addr);
2701
2712__syscall bool net_if_ipv4_addr_add_by_index(int index,
2713 const struct net_in_addr *addr,
2715 uint32_t vlifetime);
2716
2725__syscall bool net_if_ipv4_addr_rm_by_index(int index,
2726 const struct net_in_addr *addr);
2727
2737 void *user_data);
2738
2748 const struct net_in_addr *addr);
2749
2758bool net_if_ipv4_maddr_rm(struct net_if *iface, const struct net_in_addr *addr);
2759
2769 void *user_data);
2770
2782 struct net_if **iface);
2783
2791 struct net_if_mcast_addr *addr);
2792
2800static inline bool net_if_ipv4_maddr_is_joined(struct net_if_mcast_addr *addr)
2801{
2802 if (addr == NULL) {
2803 return false;
2804 }
2805
2806 return addr->is_joined;
2807}
2808
2816 struct net_if_mcast_addr *addr);
2817
2829#if defined(CONFIG_NET_IPV4)
2830void net_if_ipv4_nbr_flush(struct net_if *iface);
2831#else
2832static inline void net_if_ipv4_nbr_flush(struct net_if *iface)
2833{
2834 ARG_UNUSED(iface);
2835}
2836#endif
2837
2850#if defined(CONFIG_NET_IPV4)
2851bool net_if_ipv4_nbr_rm(struct net_if *iface, const struct net_in_addr *addr);
2852#else
2853static inline bool net_if_ipv4_nbr_rm(struct net_if *iface,
2854 const struct net_in_addr *addr)
2855{
2856 ARG_UNUSED(iface);
2857 ARG_UNUSED(addr);
2858
2859 return false;
2860}
2861#endif
2862
2869#if defined(CONFIG_NET_NATIVE_IPV4)
2870static inline struct net_in_addr *net_if_router_ipv4(struct net_if_router *router)
2871{
2872 if (router == NULL) {
2873 return NULL;
2874 }
2875
2876 return &router->address.in_addr;
2877}
2878#else
2879static inline struct net_in_addr *net_if_router_ipv4(struct net_if_router *router)
2880{
2881 static struct net_in_addr addr;
2882
2883 ARG_UNUSED(router);
2884
2885 return &addr;
2886}
2887#endif
2888
2899 const struct net_in_addr *addr);
2900
2911 const struct net_in_addr *addr);
2923 const struct net_in_addr *addr,
2924 bool is_default,
2925 uint16_t router_lifetime);
2926
2935
2949int net_if_ipv4_route_add(struct net_if *iface, const struct net_in_addr *addr, uint8_t mask_len,
2950 const struct net_in_addr *nexthop, uint32_t lifetime);
2951
2961 const struct net_in_addr *addr);
2962
2972 const struct net_in_addr *addr);
2973
2983#if defined(CONFIG_NET_IPV4)
2984struct net_if *net_if_ipv4_select_src_iface(const struct net_in_addr *dst);
2985#else
2987 const struct net_in_addr *dst)
2988{
2989 ARG_UNUSED(dst);
2990
2991 return NULL;
2992}
2993#endif
2994
3007#if defined(CONFIG_NET_IPV4)
3008struct net_if *net_if_ipv4_select_src_iface_addr(const struct net_in_addr *dst,
3009 const struct net_in_addr **src_addr);
3010#else
3012 const struct net_in_addr *dst, const struct net_in_addr **src_addr)
3013{
3014 ARG_UNUSED(dst);
3015 ARG_UNUSED(src_addr);
3016
3017 return NULL;
3018}
3019#endif /* CONFIG_NET_IPV4 */
3020
3032#if defined(CONFIG_NET_IPV4)
3033const struct net_in_addr *net_if_ipv4_select_src_addr(struct net_if *iface,
3034 const struct net_in_addr *dst);
3035#else
3036static inline const struct net_in_addr *net_if_ipv4_select_src_addr(
3037 struct net_if *iface, const struct net_in_addr *dst)
3038{
3039 ARG_UNUSED(iface);
3040 ARG_UNUSED(dst);
3041
3042 return NULL;
3043}
3044#endif
3045
3056 enum net_addr_state addr_state);
3057
3068 enum net_addr_state addr_state);
3069
3080 const struct net_in_addr *addr);
3081
3092 const struct net_in_addr *addr,
3093 const struct net_in_addr *netmask);
3094
3105 const struct net_in_addr *addr,
3106 const struct net_in_addr *netmask);
3107
3116
3123void net_if_ipv4_set_gw(struct net_if *iface, const struct net_in_addr *gw);
3124
3133__syscall bool net_if_ipv4_set_gw_by_index(int index, const struct net_in_addr *gw);
3134
3146
3155typedef void (*net_if_link_callback_t)(struct net_if *iface,
3156 struct net_linkaddr *dst,
3157 int status);
3158
3174
3183
3190
3198void net_if_call_link_cb(struct net_if *iface, struct net_linkaddr *lladdr,
3199 int status);
3200
3202
3203/* used to ensure encoding of checksum support in net_if.h and
3204 * ethernet.h is the same
3205 */
3206#define NET_IF_CHECKSUM_NONE_BIT 0
3207#define NET_IF_CHECKSUM_IPV4_HEADER_BIT BIT(0)
3208#define NET_IF_CHECKSUM_IPV4_ICMP_BIT BIT(1)
3209/* Space for future protocols and restrictions for IPV4 */
3210#define NET_IF_CHECKSUM_IPV6_HEADER_BIT BIT(10)
3211#define NET_IF_CHECKSUM_IPV6_ICMP_BIT BIT(11)
3212/* Space for future protocols and restrictions for IPV6 */
3213#define NET_IF_CHECKSUM_TCP_BIT BIT(21)
3214#define NET_IF_CHECKSUM_UDP_BIT BIT(22)
3215
3217
3223 NET_IF_CHECKSUM_IPV4_HEADER = NET_IF_CHECKSUM_IPV4_HEADER_BIT,
3225 NET_IF_CHECKSUM_IPV4_TCP = NET_IF_CHECKSUM_IPV4_HEADER_BIT |
3226 NET_IF_CHECKSUM_TCP_BIT,
3228 NET_IF_CHECKSUM_IPV4_UDP = NET_IF_CHECKSUM_IPV4_HEADER_BIT |
3229 NET_IF_CHECKSUM_UDP_BIT,
3231 NET_IF_CHECKSUM_IPV4_ICMP = NET_IF_CHECKSUM_IPV4_ICMP_BIT,
3233 NET_IF_CHECKSUM_IPV6_HEADER = NET_IF_CHECKSUM_IPV6_HEADER_BIT,
3235 NET_IF_CHECKSUM_IPV6_TCP = NET_IF_CHECKSUM_IPV6_HEADER_BIT |
3236 NET_IF_CHECKSUM_TCP_BIT,
3238 NET_IF_CHECKSUM_IPV6_UDP = NET_IF_CHECKSUM_IPV6_HEADER_BIT |
3239 NET_IF_CHECKSUM_UDP_BIT,
3241 NET_IF_CHECKSUM_IPV6_ICMP = NET_IF_CHECKSUM_IPV6_ICMP_BIT
3242};
3243
3254#if defined(CONFIG_NET_CHECKSUM_OFFLOAD)
3255bool net_if_need_calc_rx_checksum(struct net_if *iface,
3256 enum net_if_checksum_type chksum_type);
3257#else /* CONFIG_NET_CHECKSUM_OFFLOAD */
3258static inline bool net_if_need_calc_rx_checksum(struct net_if *iface,
3259 enum net_if_checksum_type chksum_type)
3260{
3261 ARG_UNUSED(iface);
3262 ARG_UNUSED(chksum_type);
3263 return true;
3264}
3265#endif /* CONFIG_NET_CHECKSUM_OFFLOAD */
3266
3278#if defined(CONFIG_NET_CHECKSUM_OFFLOAD)
3279bool net_if_need_calc_tx_checksum(struct net_if *iface,
3280 enum net_if_checksum_type chksum_type);
3281#else /* CONFIG_NET_CHECKSUM_OFFLOAD */
3282static inline bool net_if_need_calc_tx_checksum(struct net_if *iface,
3283 enum net_if_checksum_type chksum_type)
3284{
3285 ARG_UNUSED(iface);
3286 ARG_UNUSED(chksum_type);
3287 return true;
3288}
3289#endif /* CONFIG_NET_CHECKSUM_OFFLOAD */
3290
3301__syscall struct net_if *net_if_get_by_index(int index);
3302
3310int net_if_get_by_iface(struct net_if *iface);
3311
3319typedef void (*net_if_cb_t)(struct net_if *iface, void *user_data);
3320
3328void net_if_foreach(net_if_cb_t cb, void *user_data);
3329
3337int net_if_up(struct net_if *iface);
3338
3346static inline bool net_if_is_up(struct net_if *iface)
3347{
3348 if (iface == NULL) {
3349 return false;
3350 }
3351
3352 return net_if_flag_is_set(iface, NET_IF_UP) &&
3354}
3355
3363int net_if_down(struct net_if *iface);
3364
3372static inline bool net_if_is_admin_up(struct net_if *iface)
3373{
3374 if (iface == NULL) {
3375 return false;
3376 }
3377
3378 return net_if_flag_is_set(iface, NET_IF_UP);
3379}
3380
3389void net_if_carrier_on(struct net_if *iface);
3390
3399void net_if_carrier_off(struct net_if *iface);
3400
3408static inline bool net_if_is_carrier_ok(struct net_if *iface)
3409{
3410 if (iface == NULL) {
3411 return false;
3412 }
3413
3414 return net_if_flag_is_set(iface, NET_IF_LOWER_UP);
3415}
3416
3427void net_if_dormant_on(struct net_if *iface);
3428
3437void net_if_dormant_off(struct net_if *iface);
3438
3446static inline bool net_if_is_dormant(struct net_if *iface)
3447{
3448 if (iface == NULL) {
3449 return false;
3450 }
3451
3452 return net_if_flag_is_set(iface, NET_IF_DORMANT);
3453}
3454
3455#if defined(CONFIG_NET_PKT_TIMESTAMP_THREAD) || defined(__DOXYGEN__)
3463typedef void (*net_if_timestamp_callback_t)(struct net_pkt *pkt);
3464
3490
3502 struct net_pkt *pkt,
3503 struct net_if *iface,
3505
3512
3519
3520/*
3521 * @brief Add timestamped TX buffer to be handled
3522 *
3523 * @param pkt Timestamped buffer
3524 */
3526#endif /* CONFIG_NET_PKT_TIMESTAMP_THREAD */
3527
3537#if defined(CONFIG_NET_PROMISCUOUS_MODE)
3538int net_if_set_promisc(struct net_if *iface);
3539#else
3540static inline int net_if_set_promisc(struct net_if *iface)
3541{
3542 ARG_UNUSED(iface);
3543
3544 return -ENOTSUP;
3545}
3546#endif
3547
3553#if defined(CONFIG_NET_PROMISCUOUS_MODE)
3554void net_if_unset_promisc(struct net_if *iface);
3555#else
3556static inline void net_if_unset_promisc(struct net_if *iface)
3557{
3558 ARG_UNUSED(iface);
3559}
3560#endif
3561
3570#if defined(CONFIG_NET_PROMISCUOUS_MODE)
3571bool net_if_is_promisc(struct net_if *iface);
3572#else
3573static inline bool net_if_is_promisc(struct net_if *iface)
3574{
3575 ARG_UNUSED(iface);
3576
3577 return false;
3578}
3579#endif
3580
3590static inline bool net_if_are_pending_tx_packets(struct net_if *iface)
3591{
3592#if defined(CONFIG_NET_POWER_MANAGEMENT)
3593 return !!iface->tx_pending;
3594#else
3595 ARG_UNUSED(iface);
3596
3597 return false;
3598#endif
3599}
3600
3601#ifdef CONFIG_NET_POWER_MANAGEMENT
3609int net_if_suspend(struct net_if *iface);
3610
3618int net_if_resume(struct net_if *iface);
3619
3627bool net_if_is_suspended(struct net_if *iface);
3628#endif /* CONFIG_NET_POWER_MANAGEMENT */
3629
3637bool net_if_is_ethernet(struct net_if *iface);
3638
3645
3653bool net_if_is_wifi(struct net_if *iface);
3654
3661
3668
3675
3690int net_if_get_name(struct net_if *iface, char *buf, int len);
3691
3706int net_if_set_name(struct net_if *iface, const char *buf);
3707
3715int net_if_get_by_name(const char *name);
3716
3718struct net_if_api {
3719 void (*init)(struct net_if *iface);
3720};
3721
3722#define NET_IF_DHCPV4_INIT \
3723 IF_ENABLED(UTIL_AND(IS_ENABLED(CONFIG_NET_DHCPV4), \
3724 IS_ENABLED(CONFIG_NET_NATIVE_IPV4)), \
3725 (.dhcpv4.state = NET_DHCPV4_DISABLED,))
3726
3727#define NET_IF_DHCPV6_INIT \
3728 IF_ENABLED(UTIL_AND(IS_ENABLED(CONFIG_NET_DHCPV6), \
3729 IS_ENABLED(CONFIG_NET_NATIVE_IPV6)), \
3730 (.dhcpv6.state = NET_DHCPV6_DISABLED,))
3731
3732#define NET_IF_CONFIG_INIT \
3733 .config = { \
3734 IF_ENABLED(CONFIG_NET_IP, (.ip = {},)) \
3735 NET_IF_DHCPV4_INIT \
3736 NET_IF_DHCPV6_INIT \
3737 }
3738
3739#define NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, sfx) \
3740 net_stats_##dev_id##_##sfx##_collector
3741#define NET_PROMETHEUS_INIT(dev_id, sfx) \
3742 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS, \
3743 (.collector = &NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, sfx),))
3744
3745#define NET_IF_GET_NAME(dev_id, sfx) __net_if_##dev_id##_##sfx
3746#define NET_IF_DEV_GET_NAME(dev_id, sfx) __net_if_dev_##dev_id##_##sfx
3747
3748#define NET_IF_GET(dev_id, sfx) \
3749 ((struct net_if *)&NET_IF_GET_NAME(dev_id, sfx))
3750
3751#if defined(CONFIG_NET_STATISTICS_VIA_PROMETHEUS)
3752extern int net_stats_prometheus_scrape(struct prometheus_collector *collector,
3753 struct prometheus_metric *metric,
3754 void *user_data);
3755#endif /* CONFIG_NET_STATISTICS_VIA_PROMETHEUS */
3756
3757#define NET_IF_INIT(dev_id, sfx, _l2, _mtu) \
3758 static STRUCT_SECTION_ITERABLE(net_if_dev, \
3759 NET_IF_DEV_GET_NAME(dev_id, sfx)) = { \
3760 .dev = &(DEVICE_NAME_GET(dev_id)), \
3761 .l2 = &(NET_L2_GET_NAME(_l2)), \
3762 .l2_data = &(NET_L2_GET_DATA(dev_id, sfx)), \
3763 .mtu = _mtu, \
3764 .flags = {BIT(NET_IF_LOWER_UP)}, \
3765 }; \
3766 static STRUCT_SECTION_ITERABLE(net_if, \
3767 NET_IF_GET_NAME(dev_id, sfx)) = { \
3768 .if_dev = &(NET_IF_DEV_GET_NAME(dev_id, sfx)), \
3769 NET_IF_CONFIG_INIT \
3770 }; \
3771 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS, \
3772 (static PROMETHEUS_COLLECTOR_DEFINE( \
3773 NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, \
3774 sfx), \
3775 net_stats_prometheus_scrape, \
3776 NET_IF_GET(dev_id, sfx)); \
3777 NET_STATS_PROMETHEUS(NET_IF_GET(dev_id, sfx), \
3778 dev_id, sfx);))
3779
3780#define NET_IF_OFFLOAD_INIT(dev_id, sfx, _mtu) \
3781 static STRUCT_SECTION_ITERABLE(net_if_dev, \
3782 NET_IF_DEV_GET_NAME(dev_id, sfx)) = { \
3783 .dev = &(DEVICE_NAME_GET(dev_id)), \
3784 .mtu = _mtu, \
3785 .l2 = &(NET_L2_GET_NAME(OFFLOADED_NETDEV)), \
3786 .flags = {BIT(NET_IF_LOWER_UP)}, \
3787 }; \
3788 static STRUCT_SECTION_ITERABLE(net_if, \
3789 NET_IF_GET_NAME(dev_id, sfx)) = { \
3790 .if_dev = &(NET_IF_DEV_GET_NAME(dev_id, sfx)), \
3791 NET_IF_CONFIG_INIT \
3792 }; \
3793 IF_ENABLED(CONFIG_NET_STATISTICS_VIA_PROMETHEUS, \
3794 (static PROMETHEUS_COLLECTOR_DEFINE( \
3795 NET_PROMETHEUS_GET_COLLECTOR_NAME(dev_id, \
3796 sfx), \
3797 net_stats_prometheus_scrape, \
3798 NET_IF_GET(dev_id, sfx)); \
3799 NET_STATS_PROMETHEUS(NET_IF_GET(dev_id, sfx), \
3800 dev_id, sfx);))
3801
3802
3804
3805/* Network device initialization macros */
3806
3815#define NET_IF_DECLARE(dev_id, inst) \
3816 static struct net_if NET_IF_GET_NAME(dev_id, inst)
3817
3818#define Z_NET_DEVICE_IF_INIT_INSTANCE(dev_id, instance, l2, \
3819 l2_ctx_type, mtu) \
3820 NET_L2_DATA_INIT(dev_id, instance, l2_ctx_type); \
3821 NET_IF_INIT(dev_id, instance, l2, mtu)
3822
3823#define Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
3824 init_fn, pm, data, config, prio, \
3825 api, l2, l2_ctx_type, mtu) \
3826 Z_DEVICE_STATE_DEFINE(dev_id); \
3827 Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, NULL, \
3828 Z_DEVICE_DT_FLAGS(node_id), pm, data, \
3829 config, POST_KERNEL, prio, api, \
3830 &Z_DEVICE_STATE_NAME(dev_id)); \
3831 Z_NET_DEVICE_IF_INIT_INSTANCE(dev_id, instance, l2, \
3832 l2_ctx_type, mtu)
3833
3834#define Z_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
3835 config, prio, api, l2, l2_ctx_type, mtu) \
3836 Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, 0, init_fn, \
3837 pm, data, config, prio, api, l2, \
3838 l2_ctx_type, mtu)
3839
3846#define NET_IF_DT_DECLARE(node_id, instance) \
3847 NET_IF_DECLARE(Z_DEVICE_DT_DEV_ID(node_id), instance)
3848
3856#define NET_IF_DT_INST_DECLARE(inst, ...) NET_IF_DT_DECLARE(DT_DRV_INST(inst), __VA_ARGS__)
3857
3865#define NET_IF_DT_GET(node_id, instance) NET_IF_GET(Z_DEVICE_DT_DEV_ID(node_id), instance)
3866
3875#define NET_IF_DT_INST_GET(inst, ...) NET_IF_DT_GET(DT_DRV_INST(inst), __VA_ARGS__)
3876
3896#define NET_DEVICE_INIT(dev_id, name, init_fn, pm, data, config, prio, \
3897 api, l2, l2_ctx_type, mtu) \
3898 Z_NET_DEVICE_INIT(DT_INVALID_NODE, dev_id, name, init_fn, pm, \
3899 data, config, prio, api, l2, l2_ctx_type, mtu)
3900
3912#define NET_DEVICE_DT_ADD_IFACE(node_id, l2, l2_ctx_type, mtu, instance) \
3913 Z_NET_DEVICE_IF_INIT_INSTANCE(Z_DEVICE_DT_DEV_ID(node_id), instance, l2, l2_ctx_type, mtu)
3914
3923#define NET_DEVICE_DT_INST_ADD_IFACE(inst, ...) \
3924 NET_DEVICE_DT_ADD_IFACE(DT_DRV_INST(inst), __VA_ARGS__)
3925
3944#define NET_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, \
3945 config, prio, api, l2, l2_ctx_type, mtu) \
3946 Z_NET_DEVICE_INIT(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
3947 DEVICE_DT_NAME(node_id), init_fn, pm, data, \
3948 config, prio, api, l2, l2_ctx_type, mtu)
3949
3958#define NET_DEVICE_DT_INST_DEFINE(inst, ...) \
3959 NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
3960
3984#define NET_DEVICE_INIT_INSTANCE(dev_id, name, instance, init_fn, pm, \
3985 data, config, prio, api, l2, \
3986 l2_ctx_type, mtu) \
3987 Z_NET_DEVICE_INIT_INSTANCE(DT_INVALID_NODE, dev_id, name, \
3988 instance, init_fn, pm, data, config, \
3989 prio, api, l2, l2_ctx_type, mtu)
3990
4013#define NET_DEVICE_DT_DEFINE_INSTANCE(node_id, instance, init_fn, pm, \
4014 data, config, prio, api, l2, \
4015 l2_ctx_type, mtu) \
4016 Z_NET_DEVICE_INIT_INSTANCE(node_id, \
4017 Z_DEVICE_DT_DEV_ID(node_id), \
4018 DEVICE_DT_NAME(node_id), instance, \
4019 init_fn, pm, data, config, prio, \
4020 api, l2, l2_ctx_type, mtu)
4021
4031#define NET_DEVICE_DT_INST_DEFINE_INSTANCE(inst, ...) \
4032 NET_DEVICE_DT_DEFINE_INSTANCE(DT_DRV_INST(inst), __VA_ARGS__)
4033
4034#define Z_NET_DEVICE_OFFLOAD_INIT(node_id, dev_id, name, init_fn, pm, \
4035 data, config, prio, api, mtu) \
4036 Z_DEVICE_STATE_DEFINE(dev_id); \
4037 Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, NULL, \
4038 Z_DEVICE_DT_FLAGS(node_id), pm, data, \
4039 config, POST_KERNEL, prio, api, \
4040 &Z_DEVICE_STATE_NAME(dev_id)); \
4041 NET_IF_OFFLOAD_INIT(dev_id, 0, mtu)
4042
4062#define NET_DEVICE_OFFLOAD_INIT(dev_id, name, init_fn, pm, data, \
4063 config, prio, api, mtu) \
4064 Z_NET_DEVICE_OFFLOAD_INIT(DT_INVALID_NODE, dev_id, name, \
4065 init_fn, pm, data, config, prio, api, \
4066 mtu)
4067
4086#define NET_DEVICE_DT_OFFLOAD_DEFINE(node_id, init_fn, pm, data, \
4087 config, prio, api, mtu) \
4088 Z_NET_DEVICE_OFFLOAD_INIT(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
4089 DEVICE_DT_NAME(node_id), init_fn, pm, \
4090 data, config, prio, api, mtu)
4091
4101#define NET_DEVICE_DT_INST_OFFLOAD_DEFINE(inst, ...) \
4102 NET_DEVICE_DT_OFFLOAD_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
4103
4109#define NET_IFACE_COUNT(_dst) \
4110 do { \
4111 extern struct net_if _net_if_list_start[]; \
4112 extern struct net_if _net_if_list_end[]; \
4113 *(_dst) = ((uintptr_t)_net_if_list_end - \
4114 (uintptr_t)_net_if_list_start) / \
4115 sizeof(struct net_if); \
4116 } while (0)
4117
4118#ifdef __cplusplus
4119}
4120#endif
4121
4122#include <zephyr/syscalls/net_if.h>
4123
4127
4128#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.
APIs and macros for the Zephyr device model.
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:245
static bool atomic_test_bit(const atomic_t *target, int bit)
Atomically get and test a bit.
Definition atomic.h:138
static void atomic_clear_bit(atomic_t *target, int bit)
Atomically clear a bit.
Definition atomic.h:227
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition atomic.h:122
static bool atomic_test_and_clear_bit(atomic_t *target, int bit)
Atomically clear a bit and test it.
Definition atomic.h:158
static bool atomic_test_and_set_bit(atomic_t *target, int bit)
Atomically set a bit and test it.
Definition atomic.h:181
#define K_FOREVER
Generate infinite timeout delay.
Definition kernel.h:1712
#define K_NO_WAIT
Generate null timeout delay.
Definition kernel.h:1602
static int64_t k_uptime_get(void)
Get system uptime.
Definition kernel.h:2216
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:2255
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:3408
static bool net_if_is_admin_up(struct net_if *iface)
Check if interface was brought up by the administrator.
Definition net_if.h:3372
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:1873
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:3282
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:3155
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:2107
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.
int net_if_ipv6_router_start(struct net_if *iface)
Enable the IPv6 router role on the interface.
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:2986
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:975
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:3011
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:1154
#define NET_IF_IPV6_DAD_NONCE_LEN
@rfc{7527,section-4} Enhanced DAD nonce payload length in bytes.
Definition net_if.h:52
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:2482
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:1511
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:1109
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:3590
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:897
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:1313
struct net_if_addr * net_if_ipv4_addr_lookup_by_iface(struct net_if *iface, const struct net_in_addr *addr)
Check if this IPv4 address belongs to this specific interfaces.
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:2879
static struct net_offload * net_if_offload(struct net_if *iface)
Return the IP offload plugin.
Definition net_if.h:1196
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:877
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:2459
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:2221
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:2202
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.
static bool net_if_ipv4_nbr_rm(struct net_if *iface, const struct net_in_addr *addr)
Remove one neighbor from the IPv4 neighbor cache.
Definition net_if.h:2853
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:2431
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:1391
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:3463
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:2185
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:1168
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:3446
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:2295
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:1829
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:1546
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:3346
static void net_if_ipv4_nbr_flush(struct net_if *iface)
Flush the IPv4 neighbor cache of a network interface.
Definition net_if.h:2832
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:2353
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:1066
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:2507
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:3221
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:1348
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:3556
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:1265
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:2320
static bool net_if_is_promisc(struct net_if *iface)
Check if promiscuous mode is set or not.
Definition net_if.h:3573
int net_if_ipv6_prefix_set_advertise(struct net_if *iface, const struct net_in6_addr *prefix, uint8_t len, bool advertise)
Mark (or unmark) an IPv6 prefix for advertisement in Router Advertisements sent on the interface.
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:2800
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:2016
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.
int net_if_ipv6_router_stop(struct net_if *iface)
Disable the IPv6 router role on the interface.
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.
static void net_if_ipv6_nbr_flush(struct net_if *iface)
Flush the IPv6 neighbor cache of a network interface.
Definition net_if.h:1412
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:1370
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:2264
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:1785
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:935
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:1027
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:1941
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:3258
void(* net_if_cb_t)(struct net_if *iface, void *user_data)
Callback used while iterating over network interfaces.
Definition net_if.h:3319
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 bool net_if_ipv6_nbr_rm(struct net_if *iface, const struct net_in6_addr *addr)
Remove one neighbor from the IPv6 neighbor cache.
Definition net_if.h:1433
static uint16_t net_if_get_mtu(struct net_if *iface)
Get an network interface's MTU.
Definition net_if.h:1529
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:2372
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:2398
net_if_oper_state
Network interface operational status (@rfc{2863}).
Definition net_if.h:326
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:955
static struct net_if_config * net_if_get_config(struct net_if *iface)
Return network configuration for this network interface.
Definition net_if.h:1331
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:1564
net_if_flag
Network interface flags.
Definition net_if.h:270
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:3036
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:1127
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:695
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:1219
static bool net_if_is_socket_offloaded(struct net_if *iface)
Return the socket offload status.
Definition net_if.h:1242
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:2238
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:3540
static const struct net_l2 * net_if_l2(struct net_if *iface)
Get a pointer to the interface L2.
Definition net_if.h:1081
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:1289
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:915
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:3231
@ NET_IF_CHECKSUM_IPV6_TCP
Interface supports checksum calculation for TCP payload in IPv6.
Definition net_if.h:3235
@ NET_IF_CHECKSUM_IPV6_UDP
Interface supports checksum calculation for UDP payload in IPv6.
Definition net_if.h:3238
@ NET_IF_CHECKSUM_IPV4_HEADER
Interface supports IP version 4 header checksum calculation.
Definition net_if.h:3223
@ NET_IF_CHECKSUM_IPV4_TCP
Interface supports checksum calculation for TCP payload in IPv4.
Definition net_if.h:3225
@ NET_IF_CHECKSUM_IPV6_HEADER
Interface supports IP version 6 header checksum calculation.
Definition net_if.h:3233
@ NET_IF_CHECKSUM_IPV6_ICMP
Interface supports checksum calculation for ICMP6 payload in IPv6.
Definition net_if.h:3241
@ NET_IF_CHECKSUM_IPV4_UDP
Interface supports checksum calculation for UDP payload in IPv4.
Definition net_if.h:3228
@ NET_IF_OPER_TESTING
Training mode.
Definition net_if.h:331
@ NET_IF_OPER_DORMANT
Waiting external action.
Definition net_if.h:332
@ NET_IF_OPER_UP
Interface is up.
Definition net_if.h:333
@ NET_IF_OPER_NOTPRESENT
Hardware missing.
Definition net_if.h:328
@ NET_IF_OPER_UNKNOWN
Initial (unknown) value.
Definition net_if.h:327
@ NET_IF_OPER_DOWN
Interface is down.
Definition net_if.h:329
@ NET_IF_OPER_LOWERLAYERDOWN
Lower layer interface is down.
Definition net_if.h:330
@ NET_IF_NO_AUTO_START
Do not bring the interface immediately up after initialization.
Definition net_if.h:284
@ NET_IF_IPV6_NO_MLD
IPv6 Multicast Listener Discovery disabled.
Definition net_if.h:314
@ NET_IF_POINTOPOINT
Interface is pointopoint.
Definition net_if.h:275
@ NET_IF_IPV6_NO_ND
IPv6 Neighbor Discovery disabled.
Definition net_if.h:311
@ NET_IF_FORWARD_MULTICASTS
Flag defines if received multicasts of other interface are forwarded on this interface.
Definition net_if.h:293
@ NET_IF_IPV4
Interface supports IPv4.
Definition net_if.h:296
@ NET_IF_PROMISC
Interface is in promiscuous mode.
Definition net_if.h:278
@ NET_IF_DORMANT
Driver signals dormant.
Definition net_if.h:308
@ NET_IF_SUSPENDED
Power management specific: interface is being suspended.
Definition net_if.h:287
@ NET_IF_IPV6
Interface supports IPv6.
Definition net_if.h:299
@ NET_IF_UP
Interface is admin up.
Definition net_if.h:272
@ NET_IF_LOWER_UP
Driver signals L1 is up.
Definition net_if.h:305
@ NET_IF_RUNNING
Interface up and running (ready to receive and transmit).
Definition net_if.h:302
@ NET_IF_NO_TX_LOCK
Mutex locking on TX data path disabled on the interface.
Definition net_if.h:317
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:54
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
#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:543
Kernel FIFO structure.
Definition kernel.h:2953
Kernel mutex structure.
Definition kernel.h:3504
Semaphore structure.
Definition kernel.h:3738
Thread Structure.
Definition thread.h:258
Kernel timeout type.
Definition clock.h:65
Kernel timepoint type.
Definition clock.h:291
DHCPv6 client configuration parameters.
Definition dhcpv6.h:71
Network Interface unicast IPv4 address and netmask.
Definition net_if.h:515
struct net_in_addr netmask
Netmask.
Definition net_if.h:519
struct net_if_addr ipv4
IPv4 address.
Definition net_if.h:517
Network Interface unicast IP addresses.
Definition net_if.h:59
struct net_addr address
IP address.
Definition net_if.h:61
uint8_t is_mesh_local
Is this IP address usage limited to the subnet (mesh) or not.
Definition net_if.h:156
uint8_t is_temporary
Is this IP address temporary and generated for example by IPv6 privacy extension (@rfc{8981}...
Definition net_if.h:161
enum net_addr_state addr_state
What is the current state of the address.
Definition net_if.h:76
uint8_t is_infinite
Is the IP address valid forever.
Definition net_if.h:150
atomic_t atomic_ref
Reference counter.
Definition net_if.h:66
uint8_t is_added
Was this address added or not.
Definition net_if.h:164
enum net_addr_type addr_type
How the IP address was set.
Definition net_if.h:73
uint8_t is_used
Is this IP address used or not.
Definition net_if.h:153
IP and other configuration related data for network interface.
Definition net_if.h:628
Network Interface Device structure.
Definition net_if.h:713
Network interface IP address configuration.
Definition net_if.h:615
IPv4 configuration.
Definition net_if.h:523
uint8_t mcast_ttl
IPv4 time-to-live for multicast packets.
Definition net_if.h:537
struct net_if_addr_ipv4 unicast[NET_IF_MAX_IPV4_ADDR]
Unicast IP addresses.
Definition net_if.h:525
struct net_in_addr gw
Gateway.
Definition net_if.h:531
uint8_t ttl
IPv4 time-to-live.
Definition net_if.h:534
struct net_if_mcast_addr mcast[NET_IF_MAX_IPV4_MADDR]
Multicast IP addresses.
Definition net_if.h:528
Network Interface IPv6 prefixes.
Definition net_if.h:211
struct net_if * iface
Backpointer to network interface where this prefix is used.
Definition net_if.h:219
uint8_t is_infinite
Is the IP prefix valid forever.
Definition net_if.h:225
uint8_t len
Prefix length.
Definition net_if.h:222
uint8_t is_used
Is this prefix used or not.
Definition net_if.h:228
struct net_timeout lifetime
Prefix lifetime.
Definition net_if.h:213
struct net_in6_addr prefix
IPv6 prefix.
Definition net_if.h:216
uint8_t is_advertised
Is this prefix advertised in Router Advertisements.
Definition net_if.h:231
IPv6 configuration.
Definition net_if.h:353
struct net_if_ipv6_prefix prefix[NET_IF_MAX_IPV6_PREFIX]
Prefixes.
Definition net_if.h:361
uint32_t base_reachable_time
Default reachable time (@rfc{4861,page-52}).
Definition net_if.h:364
uint8_t hop_limit
IPv6 hop limit.
Definition net_if.h:402
struct net_if_mcast_addr mcast[NET_IF_MAX_IPV6_MADDR]
Multicast IP addresses.
Definition net_if.h:358
uint32_t retrans_timer
Retransmit timer (@rfc{4861,page-52}).
Definition net_if.h:370
struct net_if_addr unicast[NET_IF_MAX_IPV6_ADDR]
Unicast IP addresses.
Definition net_if.h:355
uint8_t mcast_hop_limit
IPv6 multicast hop limit.
Definition net_if.h:405
uint32_t reachable_time
Reachable time (@rfc{4861,page-20}).
Definition net_if.h:367
Network Interface multicast IP addresses.
Definition net_if.h:174
struct net_addr address
IP address.
Definition net_if.h:176
uint8_t is_joined
Did we join to this group.
Definition net_if.h:201
sys_snode_t rejoin_node
Rejoining multicast groups list node.
Definition net_if.h:184
atomic_t atomic_ref
Reference counter.
Definition net_if.h:181
uint8_t is_used
Is this multicast IP address used or not.
Definition net_if.h:198
Multicast monitor handler struct.
Definition net_if.h:1885
sys_snode_t node
Node information for the slist.
Definition net_if.h:1887
net_if_mcast_callback_t cb
Multicast callback.
Definition net_if.h:1893
struct net_if * iface
Network interface.
Definition net_if.h:1890
Information about routers in the system.
Definition net_if.h:241
struct net_if * iface
Network interface the router is connected to.
Definition net_if.h:249
uint8_t is_default
Is default router.
Definition net_if.h:261
uint16_t lifetime
Router lifetime.
Definition net_if.h:255
uint8_t is_infinite
Is the router valid forever.
Definition net_if.h:264
uint8_t is_used
Is this router used or not.
Definition net_if.h:258
struct net_addr address
IP address.
Definition net_if.h:246
sys_snode_t node
Slist lifetime timer node.
Definition net_if.h:243
uint32_t life_start
Router life timer start.
Definition net_if.h:252
Timestamp callback handler struct.
Definition net_if.h:3473
sys_snode_t node
Node information for the slist.
Definition net_if.h:3475
struct net_if * iface
Net interface for which the callback is needed.
Definition net_if.h:3485
struct net_pkt * pkt
Packet for which the callback is needed.
Definition net_if.h:3480
net_if_timestamp_callback_t cb
Timestamp callback.
Definition net_if.h:3488
Network Interface structure.
Definition net_if.h:777
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:672
k_thread_stack_t * stack
Stack for this handler.
Definition net_if.h:686
struct k_thread handler
Traffic class handler thread.
Definition net_if.h:683
struct k_fifo fifo
Fifo for handling this Tx or Rx packet.
Definition net_if.h:674
Prometheus collector definition.
Definition collector.h:50
Type used to represent a Prometheus metric base.
Definition metric.h:47
Iterable sections helpers.