Lines Matching refs:netif
5 * @defgroup netif Network interface (NETIF)
9 * @ingroup netif
12 * @ingroup netif
15 * Store data (void*) on a netif for application usage.
17 * @ingroup netif
59 #include "lwip/netif.h"
75 #include "netif/ethernet.h"
111 struct netif *netif_list;
113 struct netif *netif_default;
127 static void netif_issue_reports(struct netif *netif, u8_t report_type);
130 static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr);
133 static err_t netif_null_output_ip4(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr);
138 static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr);
141 static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr);
146 struct net_group *get_net_group_from_netif(struct netif *netif) {
147 if (netif != NULL) {
148 return get_default_net_group_ops()->get_net_group_from_netif(netif);
153 static struct netif loop_netif;
159 * @param netif the lwip network interface structure for this loopif
164 netif_loopif_init(struct netif *netif)
166 LWIP_ASSERT("netif_loopif_init: invalid netif", netif != NULL);
168 /* initialize the snmp variables and counters inside the struct netif
171 MIB2_INIT_NETIF(netif, snmp_ifType_softwareLoopback, 0);
173 netif->name[0] = 'l';
174 netif->name[1] = 'o';
176 netif->output = netif_loop_output_ipv4;
179 netif->output_ip6 = netif_loop_output_ipv6;
182 netif_set_flags(netif, NETIF_FLAG_IGMP);
184 NETIF_SET_CHECKSUM_CTRL(netif, NETIF_CHECKSUM_DISABLE_ALL);
208 struct netif *loop_netif = group->loop_netif;
249 * ethernet_input() or ip_input() depending on netif flags.
251 * netif->input().
252 * Only works if the netif driver correctly sets
256 netif_input(struct pbuf *p, struct netif *inp)
261 LWIP_ASSERT("netif_input: invalid netif", inp != NULL);
272 * @ingroup netif
277 struct netif *
279 netif_add_noaddr(struct netif *netif, struct net_group *group, void *state, netif_init_fn init, netif_input_fn input)
281 netif_add_noaddr(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
285 return netif_add(netif, group,
287 return netif_add(netif,
296 * @ingroup netif
299 * @param netif a pre-allocated netif structure
300 * @param ipaddr IP address for the new netif
301 * @param netmask network mask for the new netif
302 * @param gw default gateway IP address for the new netif
303 * @param state opaque data passed to the new netif
310 * These functions use netif flags NETIF_FLAG_ETHARP and NETIF_FLAG_ETHERNET
312 * In other words, the functions only work when the netif
314 * Most members of struct netif should be be initialized by the
315 * netif init function = netif driver (init parameter of this function).\n
317 * setting the MAC address in struct netif.hwaddr
320 * @return netif, or NULL if failed.
322 struct netif *
324 netif_add(struct netif *netif, struct net_group *group,
326 netif_add(struct netif *netif,
340 get_default_net_group_ops()->set_netif_net_group(netif, group);
349 LWIP_ASSERT("single netif already set", 0);
354 LWIP_ERROR("netif_add: invalid netif", netif != NULL, return NULL);
369 ip_addr_set_zero_ip4(&netif->ip_addr);
370 ip_addr_set_zero_ip4(&netif->netmask);
371 ip_addr_set_zero_ip4(&netif->gw);
372 netif->output = netif_null_output_ip4;
376 ip_addr_set_zero_ip6(&netif->ip6_addr[i]);
377 netif->ip6_addr_state[i] = IP6_ADDR_INVALID;
379 netif->ip6_addr_valid_life[i] = IP6_ADDR_LIFE_STATIC;
380 netif->ip6_addr_pref_life[i] = IP6_ADDR_LIFE_STATIC;
383 netif->output_ip6 = netif_null_output_ip6;
385 NETIF_SET_CHECKSUM_CTRL(netif, NETIF_CHECKSUM_ENABLE_ALL);
386 netif->mtu = 0;
387 netif->flags = 0;
389 memset(netif->client_data, 0, sizeof(netif->client_data));
394 netif->ip6_autoconfig_enabled = 0;
396 nd6_restart_netif(netif);
399 netif->status_callback = NULL;
402 netif->link_callback = NULL;
405 netif->igmp_mac_filter = NULL;
408 netif->mld_mac_filter = NULL;
411 /* remember netif specific state information data */
412 netif->state = state;
414 netif->num = group->netif_num;
416 netif->num = netif_num;
418 netif->input = input;
420 NETIF_RESET_HINTS(netif);
422 netif->loop_first = NULL;
423 netif->loop_last = NULL;
425 netif->loop_cnt_current = 0;
428 netif->reschedule_poll = 0;
433 netif_set_addr(netif, ipaddr, netmask, gw);
436 /* call user specified initialization function for netif */
437 if (init(netif) != ERR_OK) {
441 /* Initialize the MTU for IPv6 to the one set by the netif driver.
443 netif->mtu6 = netif->mtu;
447 /* Assign a unique netif number in the range [0..254], so that (num+1) can
449 We assume that the new netif has not yet been added to the list here.
453 struct netif *netif2;
456 if (netif->num == 255) {
457 netif->num = 0;
465 LWIP_ASSERT("netif already added", netif2 != netif);
468 if (netif2->num == netif->num) {
469 netif->num++;
475 if (netif->num == 254) {
483 group->netif_num = (u8_t)(netif->num + 1);
485 netif_num = (u8_t)(netif->num + 1);
489 /* add this netif to the list */
491 netif->next = group->netif_list;
492 group->netif_list = netif;
494 netif->next = netif_list;
495 netif_list = netif;
498 mib2_netif_added(netif);
502 if (netif->flags & NETIF_FLAG_IGMP) {
503 igmp_start(netif);
507 LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP",
508 netif->name[0], netif->name[1]));
519 netif_invoke_ext_callback(netif, LWIP_NSC_NETIF_ADDED, NULL);
521 return netif;
540 netif_do_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr, ip_addr_t *old_addr)
546 if (ip4_addr_cmp(ipaddr, netif_ip4_addr(netif)) == 0) {
551 ip_addr_copy(*old_addr, *netif_ip_addr4(netif));
553 LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
556 mib2_remove_ip4(netif);
557 mib2_remove_route_ip4(0, netif);
558 /* set new IP address to netif */
559 ip4_addr_set(ip_2_ip4(&netif->ip_addr), ipaddr);
560 IP_SET_TYPE_VAL(netif->ip_addr, IPADDR_TYPE_V4);
561 mib2_add_ip4(netif);
562 mib2_add_route_ip4(0, netif);
564 netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4);
566 NETIF_STATUS_CALLBACK(netif);
576 * @param netif the network interface to change
583 netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
587 LWIP_ERROR("netif_set_ipaddr: invalid netif", netif != NULL, return);
596 if (netif_do_set_ipaddr(netif, ipaddr, &old_addr)) {
600 netif_invoke_ext_callback(netif, LWIP_NSC_IPV4_ADDRESS_CHANGED, &args);
606 netif_do_set_netmask(struct netif *netif, const ip4_addr_t *netmask, ip_addr_t *old_nm)
609 if (ip4_addr_cmp(netmask, netif_ip4_netmask(netif)) == 0) {
612 ip_addr_copy(*old_nm, *netif_ip_netmask4(netif));
616 mib2_remove_route_ip4(0, netif);
617 /* set new netmask to netif */
618 ip4_addr_set(ip_2_ip4(&netif->netmask), netmask);
619 IP_SET_TYPE_VAL(netif->netmask, IPADDR_TYPE_V4);
620 mib2_add_route_ip4(0, netif);
621 LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
622 netif->name[0], netif->name[1],
623 ip4_addr1_16(netif_ip4_netmask(netif)),
624 ip4_addr2_16(netif_ip4_netmask(netif)),
625 ip4_addr3_16(netif_ip4_netmask(netif)),
626 ip4_addr4_16(netif_ip4_netmask(netif))));
636 * @param netif the network interface to change
643 netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask)
653 LWIP_ERROR("netif_set_netmask: invalid netif", netif != NULL, return);
660 if (netif_do_set_netmask(netif, netmask, old_nm)) {
664 netif_invoke_ext_callback(netif, LWIP_NSC_IPV4_NETMASK_CHANGED, &args);
670 netif_do_set_gw(struct netif *netif, const ip4_addr_t *gw, ip_addr_t *old_gw)
673 if (ip4_addr_cmp(gw, netif_ip4_gw(netif)) == 0) {
676 ip_addr_copy(*old_gw, *netif_ip_gw4(netif));
681 ip4_addr_set(ip_2_ip4(&netif->gw), gw);
682 IP_SET_TYPE_VAL(netif->gw, IPADDR_TYPE_V4);
683 LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
684 netif->name[0], netif->name[1],
685 ip4_addr1_16(netif_ip4_gw(netif)),
686 ip4_addr2_16(netif_ip4_gw(netif)),
687 ip4_addr3_16(netif_ip4_gw(netif)),
688 ip4_addr4_16(netif_ip4_gw(netif))));
698 * @param netif the network interface to change
704 netif_set_gw(struct netif *netif, const ip4_addr_t *gw)
714 LWIP_ERROR("netif_set_gw: invalid netif", netif != NULL, return);
721 if (netif_do_set_gw(netif, gw, old_gw)) {
725 netif_invoke_ext_callback(netif, LWIP_NSC_IPV4_GATEWAY_CHANGED, &args);
735 * @param netif the network interface to change
741 netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask,
775 if (netif_do_set_ipaddr(netif, ipaddr, &old_addr)) {
782 if (netif_do_set_netmask(netif, netmask, old_nm)) {
788 if (netif_do_set_gw(netif, gw, old_gw)) {
796 if (netif_do_set_ipaddr(netif, ipaddr, &old_addr)) {
807 netif_invoke_ext_callback(netif, change_reason, &cb_args);
814 * @ingroup netif
817 * @param netif the network interface to remove
820 netif_remove(struct netif *netif)
828 if (netif == NULL) {
832 struct net_group *group = get_net_group_from_netif(netif);
838 netif_invoke_ext_callback(netif, LWIP_NSC_NETIF_REMOVED, NULL);
841 if (!ip4_addr_isany_val(*netif_ip4_addr(netif))) {
842 netif_do_ip_addr_changed(netif_ip_addr4(netif), NULL);
847 if (netif->flags & NETIF_FLAG_IGMP) {
848 igmp_stop(netif);
855 if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i))) {
856 netif_do_ip_addr_changed(netif_ip_addr6(netif, i), NULL);
861 mld6_stop(netif);
864 if (netif_is_up(netif)) {
865 /* set netif down before removing (call callback function) */
866 netif_set_down(netif);
869 mib2_remove_ip4(netif);
871 /* this netif is default? */
873 if (group->netif_default == netif) {
875 if (netif_default == netif) {
877 /* reset default netif */
885 /* is it the first netif? */
887 if (group->netif_list == netif) {
888 group->netif_list = netif->next;
890 if (netif_list == netif) {
891 netif_list = netif->next;
894 /* look for netif further down the list */
895 struct netif *tmp_netif;
901 if (tmp_netif->next == netif) {
902 tmp_netif->next = netif->next;
907 return; /* netif is not on the list */
911 mib2_netif_removed(netif);
913 if (netif->remove_callback) {
914 netif->remove_callback(netif);
917 LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
921 * @ingroup netif
925 * @param netif the default network interface
929 netif_set_default(struct netif *netif, struct net_group *group)
931 netif_set_default(struct netif *netif)
936 if (netif == NULL) {
938 mib2_remove_route_ip4(1, netif);
941 mib2_add_route_ip4(1, netif);
944 group->netif_default = netif;
946 netif_default = netif;
948 LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
949 netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
954 netif_set_default2(struct netif *netif)
956 netif_set_default(netif, get_curr_process_net_group());
960 * @ingroup netif
965 netif_set_up(struct netif *netif)
969 LWIP_ERROR("netif_set_up: invalid netif", netif != NULL, return);
971 if (!(netif->flags & NETIF_FLAG_UP)) {
972 netif_set_flags(netif, NETIF_FLAG_UP);
974 MIB2_COPY_SYSUPTIME_TO(&netif->ts);
976 NETIF_STATUS_CALLBACK(netif);
982 netif_invoke_ext_callback(netif, LWIP_NSC_STATUS_CHANGED, &args);
986 netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
988 nd6_restart_netif(netif);
993 /** Send ARP/IGMP/MLD/RS events, e.g. on link-up/netif-up or addr-change
996 netif_issue_reports(struct netif *netif, u8_t report_type)
998 LWIP_ASSERT("netif_issue_reports: invalid netif", netif != NULL);
1001 if (!(netif->flags & NETIF_FLAG_LINK_UP) ||
1002 !(netif->flags & NETIF_FLAG_UP)) {
1008 !ip4_addr_isany_val(*netif_ip4_addr(netif))) {
1011 if (netif->flags & (NETIF_FLAG_ETHARP)) {
1012 etharp_gratuitous(netif);
1018 if (netif->flags & NETIF_FLAG_IGMP) {
1019 igmp_report_groups(netif);
1029 mld6_report_groups(netif);
1036 * @ingroup netif
1040 netif_set_down(struct netif *netif)
1044 LWIP_ERROR("netif_set_down: invalid netif", netif != NULL, return);
1046 if (netif->flags & NETIF_FLAG_UP) {
1051 netif_invoke_ext_callback(netif, LWIP_NSC_STATUS_CHANGED, &args);
1055 netif_clear_flags(netif, NETIF_FLAG_UP);
1056 MIB2_COPY_SYSUPTIME_TO(&netif->ts);
1059 if (netif->flags & NETIF_FLAG_ETHARP) {
1060 etharp_cleanup_netif(netif);
1065 nd6_cleanup_netif(netif);
1068 NETIF_STATUS_CALLBACK(netif);
1074 * @ingroup netif
1078 netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)
1082 if (netif) {
1083 netif->status_callback = status_callback;
1090 * @ingroup netif
1094 netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback)
1098 if (netif) {
1099 netif->remove_callback = remove_callback;
1105 * @ingroup netif
1109 netif_set_link_up(struct netif *netif)
1113 LWIP_ERROR("netif_set_link_up: invalid netif", netif != NULL, return);
1115 if (!(netif->flags & NETIF_FLAG_LINK_UP)) {
1116 netif_set_flags(netif, NETIF_FLAG_LINK_UP);
1119 dhcp_network_changed(netif);
1123 autoip_network_changed(netif);
1126 netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
1128 nd6_restart_netif(netif);
1131 NETIF_LINK_CALLBACK(netif);
1136 netif_invoke_ext_callback(netif, LWIP_NSC_LINK_CHANGED, &args);
1143 * @ingroup netif
1147 netif_set_link_down(struct netif *netif)
1151 LWIP_ERROR("netif_set_link_down: invalid netif", netif != NULL, return);
1153 if (netif->flags & NETIF_FLAG_LINK_UP) {
1154 netif_clear_flags(netif, NETIF_FLAG_LINK_UP);
1156 netif->mtu6 = netif->mtu;
1159 NETIF_LINK_CALLBACK(netif);
1164 netif_invoke_ext_callback(netif, LWIP_NSC_LINK_CHANGED, &args);
1172 * @ingroup netif
1176 netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)
1180 if (netif) {
1181 netif->link_callback = link_callback;
1188 * @ingroup netif
1189 * Send an IP packet to be received on the same netif (loopif-like).
1191 * netif->input by netif_poll().
1197 * @param netif the lwip network interface structure
1203 netif_loop_output(struct netif *netif, struct pbuf *p)
1212 * if not they are adjusted for 'netif'. */
1216 struct netif *stats_if = get_net_group_from_netif(netif)->loop_netif;
1218 struct netif *stats_if = &loop_netif;
1221 struct netif *stats_if = netif;
1229 LWIP_ASSERT("netif_loop_output: invalid netif", netif != NULL);
1243 if (((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
1244 ((netif->loop_cnt_current + clen) > LWIP_MIN(LWIP_LOOPBACK_MAX_PBUFS, 0xFFFF))) {
1251 netif->loop_cnt_current = (u16_t)(netif->loop_cnt_current + clen);
1272 if (netif->loop_first != NULL) {
1273 LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL);
1274 netif->loop_last->next = r;
1275 netif->loop_last = last;
1277 if (netif->reschedule_poll) {
1279 netif->reschedule_poll = 0;
1283 netif->loop_first = r;
1284 netif->loop_last = last;
1299 if (tcpip_try_callback((tcpip_callback_fn)netif_poll, netif) != ERR_OK) {
1301 netif->reschedule_poll = 1;
1313 netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr)
1316 return netif_loop_output(netif, p);
1322 netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr)
1325 return netif_loop_output(netif, p);
1334 * netif_loop_output() are put on a list that is passed to netif->input() by
1338 netif_poll(struct netif *netif)
1341 * if not they are adjusted for 'netif'. */
1345 struct netif *stats_if = get_net_group_from_netif(netif)->loop_netif;
1347 struct netif *stats_if = &loop_netif;
1350 struct netif *stats_if = netif;
1355 LWIP_ASSERT("netif_poll: invalid netif", netif != NULL);
1359 while (netif->loop_first != NULL) {
1365 in = in_end = netif->loop_first;
1375 LWIP_ASSERT("netif->loop_cnt_current underflow",
1376 ((netif->loop_cnt_current - clen) < netif->loop_cnt_current));
1377 netif->loop_cnt_current = (u16_t)(netif->loop_cnt_current - clen);
1381 if (in_end == netif->loop_last) {
1383 netif->loop_first = netif->loop_last = NULL;
1386 netif->loop_first = in_end->next;
1387 LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL);
1393 in->if_idx = netif_get_index(netif);
1399 if (ip_input(in, netif) != ERR_OK) {
1409 * Calls netif_poll() for every netif on the netif_list.
1414 struct netif *netif;
1416 NETIF_FOREACH(netif) {
1417 netif_poll(netif);
1426 * Allocate an index to store data in client_data member of struct netif.
1451 * @param netif the network interface to change
1458 netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6)
1462 LWIP_ASSERT("netif_ip6_addr_set: invalid netif", netif != NULL);
1465 netif_ip6_addr_set_parts(netif, addr_idx, addr6->addr[0], addr6->addr[1],
1472 * @param netif the network interface to change
1480 netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, u32_t i2, u32_t i3)
1485 LWIP_ASSERT("netif != NULL", netif != NULL);
1488 ip6_addr_copy(*ip_2_ip6(&old_addr), *netif_ip6_addr(netif, addr_idx));
1494 LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_ip6_addr_set: netif address being changed\n"));
1497 ip6_addr_assign_zone(ip_2_ip6(&new_ipaddr), IP6_UNICAST, netif);
1499 if (ip6_addr_isvalid(netif_ip6_addr_state(netif, addr_idx))) {
1500 netif_do_ip_addr_changed(netif_ip_addr6(netif, addr_idx), &new_ipaddr);
1504 ip_addr_copy(netif->ip6_addr[addr_idx], new_ipaddr);
1506 if (ip6_addr_isvalid(netif_ip6_addr_state(netif, addr_idx))) {
1507 netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV6);
1508 NETIF_STATUS_CALLBACK(netif);
1516 netif_invoke_ext_callback(netif, LWIP_NSC_IPV6_SET, &args);
1521 LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IPv6 address %d of interface %c%c set to %s/0x%"X8_F"\n",
1522 addr_idx, netif->name[0], netif->name[1], ip6addr_ntoa(netif_ip6_addr(netif, addr_idx)),
1523 netif_ip6_addr_state(netif, addr_idx)));
1532 * @param netif the network interface to change
1537 netif_ip6_addr_set_state(struct netif *netif, s8_t addr_idx, u8_t state)
1541 LWIP_ASSERT("netif != NULL", netif != NULL);
1544 old_state = netif_ip6_addr_state(netif, addr_idx);
1549 LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_ip6_addr_set_state: netif address state being changed\n"));
1553 if (netif->flags & NETIF_FLAG_MLD6) {
1554 nd6_adjust_mld_membership(netif, addr_idx, state);
1560 netif_do_ip_addr_changed(netif_ip_addr6(netif, addr_idx), NULL);
1563 netif->ip6_addr_state[addr_idx] = state;
1568 IP6_ADDR_ZONECHECK_NETIF(netif_ip6_addr(netif, addr_idx), netif);
1570 netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV6);
1575 NETIF_STATUS_CALLBACK(netif);
1583 args.ipv6_addr_state_changed.address = netif_ip_addr6(netif, addr_idx);
1584 netif_invoke_ext_callback(netif, LWIP_NSC_IPV6_ADDR_STATE_CHANGED, &args);
1588 LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IPv6 address %d of interface %c%c set to %s/0x%"X8_F"\n",
1589 addr_idx, netif->name[0], netif->name[1], ip6addr_ntoa(netif_ip6_addr(netif, addr_idx)),
1590 netif_ip6_addr_state(netif, addr_idx)));
1594 * Checks if a specific local address is present on the netif and returns its
1600 * for the given netif, or no match will be found.
1602 * @param netif the netif to check
1605 * -1: address not found on this netif
1608 netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr)
1614 LWIP_ASSERT("netif_get_ip6_addr_match: invalid netif", netif != NULL);
1618 if (ip6_addr_has_zone(ip6addr) && !ip6_addr_test_zone(ip6addr, netif)) {
1624 if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i)) &&
1625 ip6_addr_cmp_zoneless(netif_ip6_addr(netif, i), ip6addr)) {
1634 * Create a link-local IPv6 address on a netif (stored in slot 0)
1636 * @param netif the netif to create the address on
1641 netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
1647 LWIP_ASSERT("netif_create_ip6_linklocal_address: invalid netif", netif != NULL);
1650 ip_2_ip6(&netif->ip6_addr[0])->addr[0] = PP_HTONL(0xfe800000ul);
1651 ip_2_ip6(&netif->ip6_addr[0])->addr[1] = 0;
1656 ip_2_ip6(&netif->ip6_addr[0])->addr[2] = lwip_htonl((((u32_t)(netif->hwaddr[0] ^ 0x02)) << 24) |
1657 ((u32_t)(netif->hwaddr[1]) << 16) |
1658 ((u32_t)(netif->hwaddr[2]) << 8) |
1660 ip_2_ip6(&netif->ip6_addr[0])->addr[3] = lwip_htonl((u32_t)(0xfeul << 24) |
1661 ((u32_t)(netif->hwaddr[3]) << 16) |
1662 ((u32_t)(netif->hwaddr[4]) << 8) |
1663 (netif->hwaddr[5]));
1666 ip_2_ip6(&netif->ip6_addr[0])->addr[2] = 0;
1667 ip_2_ip6(&netif->ip6_addr[0])->addr[3] = 0;
1670 for (i = 0; (i < 8) && (i < netif->hwaddr_len); i++) {
1674 ip_2_ip6(&netif->ip6_addr[0])->addr[addr_index] |= lwip_htonl(((u32_t)(netif->hwaddr[netif->hwaddr_len - i - 1])) << (8 * (i & 0x03)));
1679 * netif, setting the zone anyway has two important conceptual advantages:
1686 ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[0]), IP6_UNICAST, netif);
1691 netif_ip6_addr_set_state(netif, 0, IP6_ADDR_TENTATIVE);
1694 netif_ip6_addr_set_state(netif, 0, IP6_ADDR_PREFERRED);
1704 * @param netif netif to add the address on
1709 netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx)
1715 LWIP_ASSERT("netif_add_ip6_address: invalid netif", netif != NULL);
1718 i = netif_get_ip6_addr_match(netif, ip6addr);
1729 if (ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
1730 ip_addr_copy_from_ip6(netif->ip6_addr[i], *ip6addr);
1731 ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[i]), IP6_UNICAST, netif);
1732 netif_ip6_addr_set_state(netif, i, IP6_ADDR_TENTATIVE);
1749 netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr)
1751 LWIP_UNUSED_ARG(netif);
1763 netif_null_output_ip4(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
1765 LWIP_UNUSED_ARG(netif);
1774 * @ingroup netif
1775 * Return the interface index for the netif with name
1778 * @param name the name of the netif
1783 struct netif *netif = netif_find(name);
1784 if (netif != NULL) {
1785 return netif_get_index(netif);
1792 * @ingroup netif
1793 * Return the interface name for the netif matching index
1796 * @param idx the interface index of the netif
1807 struct netif *netif = netif_get_by_index(idx, group);
1809 struct netif *netif = netif_get_by_index(idx);
1812 if (netif != NULL) {
1813 name[0] = netif->name[0];
1814 name[1] = netif->name[1];
1822 * @ingroup netif
1823 * Return the interface for the netif index
1825 * @param idx index of netif to find
1827 struct netif *
1834 struct netif *netif;
1840 NETIF_FOREACH(netif, group) {
1843 NETIF_FOREACH(netif) {
1845 if (idx == netif_get_index(netif)) {
1846 return netif; /* found! */
1856 * @ingroup netif
1859 * @param name the name of the netif (like netif->name) plus concatenated number
1862 struct netif *
1865 struct netif *netif;
1880 NETIF_FOREACH(netif) {
1881 if (num == netif->num &&
1882 name[0] == netif->name[0] &&
1883 name[1] == netif->name[1]) {
1885 return netif;
1895 * @ingroup netif
1896 * Add extended netif events listener
1913 * @ingroup netif
1914 * Remove extended netif events listener
1945 * Invoke extended netif status event
1946 * @param netif netif that is affected by change
1951 netif_invoke_ext_callback(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
1955 LWIP_ASSERT("netif must be != NULL", netif != NULL);
1958 callback->callback_fn(netif, reason, args);