Lines Matching full:slot
59 struct dhcpv4_addr_slot *slot; member
86 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_server_timeout_recalc() local
88 if (slot->state == DHCPV4_SERVER_ADDR_RESERVED || in dhcpv4_server_timeout_recalc()
89 slot->state == DHCPV4_SERVER_ADDR_ALLOCATED || in dhcpv4_server_timeout_recalc()
90 slot->state == DHCPV4_SERVER_ADDR_DECLINED) { in dhcpv4_server_timeout_recalc()
91 if (sys_timepoint_cmp(slot->expiry, next) < 0) { in dhcpv4_server_timeout_recalc()
92 next = slot->expiry; in dhcpv4_server_timeout_recalc()
771 struct dhcpv4_addr_slot *slot) in dhcpv4_probe_address() argument
775 .sin_addr = slot->addr, in dhcpv4_probe_address()
813 if (probe_ctx->slot == NULL) { in echo_reply_handler()
822 if (!net_ipv4_addr_cmp(&peer_addr, &probe_ctx->slot->addr)) { in echo_reply_handler()
827 net_sprint_ipv4_addr(&probe_ctx->slot->addr)); in echo_reply_handler()
829 probe_ctx->slot->state = DHCPV4_SERVER_ADDR_DECLINED; in echo_reply_handler()
830 probe_ctx->slot->expiry = sys_timepoint_calc(ADDRESS_DECLINED_TIMEOUT); in echo_reply_handler()
834 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in echo_reply_handler() local
836 if (slot->state == DHCPV4_SERVER_ADDR_FREE) { in echo_reply_handler()
837 new_slot = slot; in echo_reply_handler()
844 probe_ctx->slot = NULL; in echo_reply_handler()
850 probe_ctx->slot = NULL; in echo_reply_handler()
857 new_slot->client_id.len = probe_ctx->slot->client_id.len; in echo_reply_handler()
858 memcpy(new_slot->client_id.buf, probe_ctx->slot->client_id.buf, in echo_reply_handler()
860 new_slot->lease_time = probe_ctx->slot->lease_time; in echo_reply_handler()
862 probe_ctx->slot = new_slot; in echo_reply_handler()
885 struct dhcpv4_addr_slot *slot, in dhcpv4_server_probe_setup() argument
892 if (ctx->probe_ctx.slot != NULL) { in dhcpv4_server_probe_setup()
896 ret = dhcpv4_probe_address(ctx, slot); in dhcpv4_server_probe_setup()
901 ctx->probe_ctx.slot = slot; in dhcpv4_server_probe_setup()
910 struct dhcpv4_addr_slot *slot) in dhcpv4_server_probe_timeout() argument
913 ctx->probe_ctx.slot = NULL; in dhcpv4_server_probe_timeout()
915 (void)net_arp_clear_pending(ctx->iface, &slot->addr); in dhcpv4_server_probe_timeout()
917 if (dhcpv4_send_offer(ctx, &ctx->probe_ctx.discovery, &slot->addr, in dhcpv4_server_probe_timeout()
918 slot->lease_time, &ctx->probe_ctx.params, in dhcpv4_server_probe_timeout()
920 slot->state = DHCPV4_SERVER_ADDR_FREE; in dhcpv4_server_probe_timeout()
924 slot->expiry = sys_timepoint_calc(ADDRESS_RESERVED_TIMEOUT); in dhcpv4_server_probe_timeout()
928 struct dhcpv4_addr_slot *slot) in dhcpv4_server_is_slot_probed() argument
930 return (ctx->probe_ctx.slot == slot); in dhcpv4_server_is_slot_probed()
963 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_discover() local
965 if ((slot->state == DHCPV4_SERVER_ADDR_RESERVED || in dhcpv4_handle_discover()
966 slot->state == DHCPV4_SERVER_ADDR_ALLOCATED) && in dhcpv4_handle_discover()
967 slot->client_id.len == client_id.len && in dhcpv4_handle_discover()
968 memcmp(slot->client_id.buf, client_id.buf, in dhcpv4_handle_discover()
970 if (slot->state == DHCPV4_SERVER_ADDR_RESERVED && in dhcpv4_handle_discover()
971 dhcpv4_server_is_slot_probed(ctx, slot)) { in dhcpv4_handle_discover()
977 selected = slot; in dhcpv4_handle_discover()
982 if (slot->state == DHCPV4_SERVER_ADDR_FREE && in dhcpv4_handle_discover()
987 selected = slot; in dhcpv4_handle_discover()
988 slot->addr = addr; in dhcpv4_handle_discover()
1004 struct dhcpv4_addr_slot *slot = in dhcpv4_handle_discover() local
1007 if (net_ipv4_addr_cmp(&slot->addr, in dhcpv4_handle_discover()
1009 slot->state == DHCPV4_SERVER_ADDR_FREE) { in dhcpv4_handle_discover()
1011 selected = slot; in dhcpv4_handle_discover()
1030 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_discover() local
1032 if (slot->state == DHCPV4_SERVER_ADDR_FREE) { in dhcpv4_handle_discover()
1034 selected = slot; in dhcpv4_handle_discover()
1041 /* In case no free address slot was found, as a last resort, try to in dhcpv4_handle_discover()
1046 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_discover() local
1048 if (slot->state != DHCPV4_SERVER_ADDR_DECLINED) { in dhcpv4_handle_discover()
1054 (sys_timepoint_cmp(slot->expiry, in dhcpv4_handle_discover()
1056 selected = slot; in dhcpv4_handle_discover()
1147 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_request() local
1149 if (net_ipv4_addr_cmp(&slot->addr, &requested_ip) && in dhcpv4_handle_request()
1150 slot->client_id.len == client_id.len && in dhcpv4_handle_request()
1151 memcmp(slot->client_id.buf, client_id.buf, in dhcpv4_handle_request()
1153 (slot->state == DHCPV4_SERVER_ADDR_RESERVED || in dhcpv4_handle_request()
1154 slot->state == DHCPV4_SERVER_ADDR_ALLOCATED)) { in dhcpv4_handle_request()
1155 selected = slot; in dhcpv4_handle_request()
1161 LOG_ERR("No valid slot found for DHCPv4 Request"); in dhcpv4_handle_request()
1198 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_request() local
1200 if (slot->client_id.len == client_id.len && in dhcpv4_handle_request()
1201 memcmp(slot->client_id.buf, client_id.buf, in dhcpv4_handle_request()
1203 (slot->state == DHCPV4_SERVER_ADDR_RESERVED || in dhcpv4_handle_request()
1204 slot->state == DHCPV4_SERVER_ADDR_ALLOCATED)) { in dhcpv4_handle_request()
1205 selected = slot; in dhcpv4_handle_request()
1246 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_request() local
1248 if (net_ipv4_addr_cmp(&slot->addr, &ciaddr)) { in dhcpv4_handle_request()
1249 selected = slot; in dhcpv4_handle_request()
1313 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_decline() local
1315 if (net_ipv4_addr_cmp(&slot->addr, &requested_ip) && in dhcpv4_handle_decline()
1316 slot->client_id.len == client_id.len && in dhcpv4_handle_decline()
1317 memcmp(slot->client_id.buf, client_id.buf, in dhcpv4_handle_decline()
1319 (slot->state == DHCPV4_SERVER_ADDR_RESERVED || in dhcpv4_handle_decline()
1320 slot->state == DHCPV4_SERVER_ADDR_ALLOCATED)) { in dhcpv4_handle_decline()
1321 slot->state = DHCPV4_SERVER_ADDR_DECLINED; in dhcpv4_handle_decline()
1322 slot->expiry = in dhcpv4_handle_decline()
1358 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_handle_release() local
1360 if (net_ipv4_addr_cmp(&slot->addr, &ciaddr) && in dhcpv4_handle_release()
1361 slot->client_id.len == client_id.len && in dhcpv4_handle_release()
1362 memcmp(slot->client_id.buf, client_id.buf, in dhcpv4_handle_release()
1364 (slot->state == DHCPV4_SERVER_ADDR_RESERVED || in dhcpv4_handle_release()
1365 slot->state == DHCPV4_SERVER_ADDR_ALLOCATED)) { in dhcpv4_handle_release()
1367 net_sprint_ipv4_addr(&slot->addr)); in dhcpv4_handle_release()
1369 slot->state = DHCPV4_SERVER_ADDR_FREE; in dhcpv4_handle_release()
1370 slot->expiry = sys_timepoint_calc(K_FOREVER); in dhcpv4_handle_release()
1399 struct dhcpv4_addr_slot *slot = &ctx->addr_pool[i]; in dhcpv4_server_timeout() local
1401 if ((slot->state == DHCPV4_SERVER_ADDR_RESERVED || in dhcpv4_server_timeout()
1402 slot->state == DHCPV4_SERVER_ADDR_ALLOCATED) && in dhcpv4_server_timeout()
1403 sys_timepoint_expired(slot->expiry)) { in dhcpv4_server_timeout()
1404 if (slot->state == DHCPV4_SERVER_ADDR_RESERVED && in dhcpv4_server_timeout()
1405 dhcpv4_server_is_slot_probed(ctx, slot)) { in dhcpv4_server_timeout()
1406 dhcpv4_server_probe_timeout(ctx, slot); in dhcpv4_server_timeout()
1409 net_sprint_ipv4_addr(&slot->addr)); in dhcpv4_server_timeout()
1410 slot->state = DHCPV4_SERVER_ADDR_FREE; in dhcpv4_server_timeout()
1414 if (slot->state == DHCPV4_SERVER_ADDR_DECLINED && in dhcpv4_server_timeout()
1415 sys_timepoint_expired(slot->expiry)) { in dhcpv4_server_timeout()
1416 slot->state = DHCPV4_SERVER_ADDR_FREE; in dhcpv4_server_timeout()
1546 int ret, sock = -1, slot = -1; in net_dhcpv4_server_start() local
1588 if (slot < 0) { in net_dhcpv4_server_start()
1589 slot = i; in net_dhcpv4_server_start()
1594 if (slot < 0) { in net_dhcpv4_server_start()
1629 fds[slot].fd = sock; in net_dhcpv4_server_start()
1630 fds[slot].events = ZSOCK_POLLIN; in net_dhcpv4_server_start()
1632 server_ctx[slot].iface = iface; in net_dhcpv4_server_start()
1633 server_ctx[slot].sock = sock; in net_dhcpv4_server_start()
1634 server_ctx[slot].server_addr = *server_addr; in net_dhcpv4_server_start()
1635 server_ctx[slot].netmask = netmask; in net_dhcpv4_server_start()
1637 k_work_init_delayable(&server_ctx[slot].timeout_work, in net_dhcpv4_server_start()
1641 for (int i = 0; i < ARRAY_SIZE(server_ctx[slot].addr_pool); i++) { in net_dhcpv4_server_start()
1642 server_ctx[slot].addr_pool[i].state = DHCPV4_SERVER_ADDR_FREE; in net_dhcpv4_server_start()
1643 server_ctx[slot].addr_pool[i].addr.s_addr = in net_dhcpv4_server_start()
1648 &server_ctx[slot].addr_pool[i].addr)); in net_dhcpv4_server_start()
1651 ret = dhcpv4_server_probing_init(&server_ctx[slot]); in net_dhcpv4_server_start()
1661 dhcpv4_server_probing_deinit(&server_ctx[slot]); in net_dhcpv4_server_start()
1670 memset(&server_ctx[slot], 0, sizeof(server_ctx[slot])); in net_dhcpv4_server_start()
1671 fds[slot].fd = -1; in net_dhcpv4_server_start()
1686 int slot = -1; in net_dhcpv4_server_stop() local
1698 slot = i; in net_dhcpv4_server_stop()
1703 if (slot < 0) { in net_dhcpv4_server_stop()
1708 fds[slot].fd = -1; in net_dhcpv4_server_stop()
1709 (void)zsock_close(server_ctx[slot].sock); in net_dhcpv4_server_stop()
1711 dhcpv4_server_probing_deinit(&server_ctx[slot]); in net_dhcpv4_server_stop()
1712 k_work_cancel_delayable_sync(&server_ctx[slot].timeout_work, &sync); in net_dhcpv4_server_stop()
1714 memset(&server_ctx[slot], 0, sizeof(server_ctx[slot])); in net_dhcpv4_server_stop()
1753 int slot = -1; in net_dhcpv4_server_foreach_lease() local
1771 slot = i; in net_dhcpv4_server_foreach_lease()
1776 if (slot < 0) { in net_dhcpv4_server_foreach_lease()
1781 dhcpv4_server_foreach_lease_on_ctx(&server_ctx[slot], cb, user_data); in net_dhcpv4_server_foreach_lease()