Lines Matching full:ctrl

25 	struct dpp_controller *ctrl;  member
141 struct dpp_relay_controller *ctrl; in dpp_relay_add_controller() local
147 ctrl = os_zalloc(sizeof(*ctrl)); in dpp_relay_add_controller()
148 if (!ctrl) in dpp_relay_add_controller()
150 dl_list_init(&ctrl->conn); in dpp_relay_add_controller()
151 ctrl->global = dpp; in dpp_relay_add_controller()
152 os_memcpy(&ctrl->ipaddr, config->ipaddr, sizeof(*config->ipaddr)); in dpp_relay_add_controller()
153 os_memcpy(ctrl->pkhash, config->pkhash, SHA256_MAC_LEN); in dpp_relay_add_controller()
154 ctrl->msg_ctx = config->msg_ctx; in dpp_relay_add_controller()
155 ctrl->cb_ctx = config->cb_ctx; in dpp_relay_add_controller()
156 ctrl->tx = config->tx; in dpp_relay_add_controller()
157 ctrl->gas_resp_tx = config->gas_resp_tx; in dpp_relay_add_controller()
159 hostapd_ip_txt(&ctrl->ipaddr, txt, sizeof(txt))); in dpp_relay_add_controller()
160 dl_list_add(&dpp->controllers, &ctrl->list); in dpp_relay_add_controller()
168 struct dpp_relay_controller *ctrl; in dpp_relay_controller_get() local
173 dl_list_for_each(ctrl, &dpp->controllers, struct dpp_relay_controller, in dpp_relay_controller_get()
175 if (os_memcmp(pkhash, ctrl->pkhash, SHA256_MAC_LEN) == 0) in dpp_relay_controller_get()
176 return ctrl; in dpp_relay_controller_get()
186 struct dpp_relay_controller *ctrl; in dpp_relay_controller_get_ctx() local
191 dl_list_for_each(ctrl, &dpp->controllers, struct dpp_relay_controller, in dpp_relay_controller_get_ctx()
193 if (cb_ctx == ctrl->cb_ctx) in dpp_relay_controller_get_ctx()
194 return ctrl; in dpp_relay_controller_get_ctx()
205 struct dpp_relay_controller *ctrl; in dpp_relay_controller_get_addr() local
210 dl_list_for_each(ctrl, &dpp->controllers, struct dpp_relay_controller, in dpp_relay_controller_get_addr()
212 if (ctrl->ipaddr.af == AF_INET && in dpp_relay_controller_get_addr()
213 addr->sin_addr.s_addr == ctrl->ipaddr.u.v4.s_addr) in dpp_relay_controller_get_addr()
214 return ctrl; in dpp_relay_controller_get_addr()
305 } else if (conn->auth && (conn->ctrl || conn->auth->configurator) && in dpp_tcp_send()
449 dpp_relay_new_conn(struct dpp_relay_controller *ctrl, const u8 *src, in dpp_relay_new_conn() argument
457 if (dl_list_len(&ctrl->conn) >= 15) { in dpp_relay_new_conn()
464 &ctrl->ipaddr, DPP_TCP_PORT) < 0) in dpp_relay_new_conn()
471 conn->global = ctrl->global; in dpp_relay_new_conn()
472 conn->relay = ctrl; in dpp_relay_new_conn()
473 conn->msg_ctx = ctrl->msg_ctx; in dpp_relay_new_conn()
474 conn->cb_ctx = ctrl->global->cb_ctx; in dpp_relay_new_conn()
482 conn->sock, hostapd_ip_txt(&ctrl->ipaddr, txt, sizeof(txt))); in dpp_relay_new_conn()
511 dl_list_add(&ctrl->conn, &conn->list); in dpp_relay_new_conn()
560 dpp_relay_match_ctrl(struct dpp_relay_controller *ctrl, const u8 *src, in dpp_relay_match_ctrl() argument
565 dl_list_for_each(conn, &ctrl->conn, struct dpp_connection, list) { in dpp_relay_match_ctrl()
589 struct dpp_relay_controller *ctrl; in dpp_relay_rx_action() local
600 dl_list_for_each(ctrl, &dpp->controllers, in dpp_relay_rx_action()
602 conn = dpp_relay_match_ctrl(ctrl, src, freq, type); in dpp_relay_rx_action()
619 ctrl = dpp_relay_controller_get_ctx(dpp, cb_ctx); in dpp_relay_rx_action()
621 ctrl = dpp_relay_controller_get_ctx(dpp, cb_ctx); in dpp_relay_rx_action()
625 ctrl = dpp_relay_controller_get(dpp, r_bootstrap); in dpp_relay_rx_action()
627 if (!ctrl) in dpp_relay_rx_action()
632 conn = dpp_relay_match_ctrl(ctrl, src, freq, type); in dpp_relay_rx_action()
643 conn = dpp_relay_new_conn(ctrl, src, freq); in dpp_relay_rx_action()
659 dpp_relay_find_conn(struct dpp_relay_controller *ctrl, const u8 *src) in dpp_relay_find_conn() argument
663 dl_list_for_each(conn, &ctrl->conn, struct dpp_connection, list) { in dpp_relay_find_conn()
675 struct dpp_relay_controller *ctrl; in dpp_relay_rx_gas_req() local
682 dl_list_for_each(ctrl, &dpp->controllers, in dpp_relay_rx_gas_req()
684 conn = dpp_relay_find_conn(ctrl, src); in dpp_relay_rx_gas_req()
717 static void dpp_controller_free(struct dpp_controller *ctrl) in dpp_controller_free() argument
721 if (!ctrl) in dpp_controller_free()
724 dl_list_for_each_safe(conn, tmp, &ctrl->conn, struct dpp_connection, in dpp_controller_free()
728 if (ctrl->sock >= 0) { in dpp_controller_free()
729 close(ctrl->sock); in dpp_controller_free()
730 eloop_unregister_sock(ctrl->sock, EVENT_TYPE_READ); in dpp_controller_free()
732 os_free(ctrl->configurator_params); in dpp_controller_free()
733 os_free(ctrl->pkex_code); in dpp_controller_free()
734 os_free(ctrl->pkex_identifier); in dpp_controller_free()
735 os_free(ctrl); in dpp_controller_free()
746 if (!conn->ctrl) in dpp_controller_rx_auth_req()
773 dpp_bootstrap_find_pair(conn->ctrl->global, i_bootstrap, r_bootstrap, in dpp_controller_rx_auth_req()
787 conn->auth = dpp_auth_req_rx(conn->ctrl->global, conn->msg_ctx, in dpp_controller_rx_auth_req()
788 conn->ctrl->allowed_roles, in dpp_controller_rx_auth_req()
789 conn->ctrl->qr_mutual, in dpp_controller_rx_auth_req()
797 conn->ctrl->configurator_params) < 0) in dpp_controller_rx_auth_req()
881 if (!conn->ctrl && (!auth || !auth->configurator)) in dpp_controller_rx_conf_result()
926 if (!conn->ctrl) in dpp_controller_rx_conn_status_result()
956 struct dpp_global *dpp = conn->ctrl->global; in dpp_controller_rx_presence_announcement()
986 if (dpp_set_configurator(auth, conn->ctrl->configurator_params) < 0) { in dpp_controller_rx_presence_announcement()
1003 struct dpp_global *dpp = conn->ctrl->global; in dpp_controller_rx_reconfig_announcement()
1048 if (dpp_set_configurator(auth, conn->ctrl->configurator_params) < 0) { in dpp_controller_rx_reconfig_announcement()
1088 struct dpp_controller *ctrl = conn->ctrl; in dpp_controller_rx_pkex_exchange_req() local
1090 if (!ctrl) in dpp_controller_rx_pkex_exchange_req()
1098 if (!ctrl->pkex_code || !ctrl->pkex_bi) { in dpp_controller_rx_pkex_exchange_req()
1110 conn->pkex = dpp_pkex_rx_exchange_req(conn->msg_ctx, ctrl->pkex_bi, in dpp_controller_rx_pkex_exchange_req()
1112 ctrl->pkex_identifier, in dpp_controller_rx_pkex_exchange_req()
1113 ctrl->pkex_code, in dpp_controller_rx_pkex_exchange_req()
1114 os_strlen(ctrl->pkex_code), in dpp_controller_rx_pkex_exchange_req()
1399 if (!auth || (!conn->ctrl && !auth->configurator) || in dpp_controller_rx_gas_req()
1505 if (!auth || (!conn->ctrl && !auth->configurator) || in dpp_controller_rx_gas_comeback_req()
1723 (!conn->ctrl || (conn->ctrl->allowed_roles & DPP_CAPAB_ENROLLEE))) in dpp_rx_gas_resp()
1861 struct dpp_controller *ctrl = eloop_ctx; in dpp_controller_tcp_cb() local
1869 fd = accept(ctrl->sock, (struct sockaddr *) &addr, &addr_len); in dpp_controller_tcp_cb()
1883 conn->global = ctrl->global; in dpp_controller_tcp_cb()
1884 conn->ctrl = ctrl; in dpp_controller_tcp_cb()
1885 conn->msg_ctx = ctrl->msg_ctx; in dpp_controller_tcp_cb()
1886 conn->cb_ctx = ctrl->cb_ctx; in dpp_controller_tcp_cb()
1887 conn->process_conf_obj = ctrl->process_conf_obj; in dpp_controller_tcp_cb()
1888 conn->tcp_msg_sent = ctrl->tcp_msg_sent; in dpp_controller_tcp_cb()
1890 conn->netrole = ctrl->netrole; in dpp_controller_tcp_cb()
1905 dl_list_add(&ctrl->conn, &conn->list); in dpp_controller_tcp_cb()
2133 struct dpp_controller *ctrl; in dpp_controller_start() local
2141 ctrl = os_zalloc(sizeof(*ctrl)); in dpp_controller_start()
2142 if (!ctrl) in dpp_controller_start()
2144 ctrl->global = dpp; in dpp_controller_start()
2146 ctrl->configurator_params = in dpp_controller_start()
2148 dl_list_init(&ctrl->conn); in dpp_controller_start()
2149 ctrl->allowed_roles = config->allowed_roles; in dpp_controller_start()
2150 ctrl->qr_mutual = config->qr_mutual; in dpp_controller_start()
2151 ctrl->netrole = config->netrole; in dpp_controller_start()
2152 ctrl->msg_ctx = config->msg_ctx; in dpp_controller_start()
2153 ctrl->cb_ctx = config->cb_ctx; in dpp_controller_start()
2154 ctrl->process_conf_obj = config->process_conf_obj; in dpp_controller_start()
2155 ctrl->tcp_msg_sent = config->tcp_msg_sent; in dpp_controller_start()
2157 ctrl->sock = socket(AF_INET, SOCK_STREAM, 0); in dpp_controller_start()
2158 if (ctrl->sock < 0) in dpp_controller_start()
2161 if (setsockopt(ctrl->sock, SOL_SOCKET, SO_REUSEADDR, in dpp_controller_start()
2169 if (fcntl(ctrl->sock, F_SETFL, O_NONBLOCK) < 0) { in dpp_controller_start()
2181 if (bind(ctrl->sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { in dpp_controller_start()
2187 if (listen(ctrl->sock, 10 /* max backlog */) < 0 || in dpp_controller_start()
2188 fcntl(ctrl->sock, F_SETFL, O_NONBLOCK) < 0 || in dpp_controller_start()
2189 eloop_register_sock(ctrl->sock, EVENT_TYPE_READ, in dpp_controller_start()
2190 dpp_controller_tcp_cb, ctrl, NULL)) in dpp_controller_start()
2193 dpp->controller = ctrl; in dpp_controller_start()
2197 dpp_controller_free(ctrl); in dpp_controller_start()
2267 struct dpp_controller *ctrl = dpp->controller; in dpp_controller_get_auth() local
2270 if (!ctrl) in dpp_controller_get_auth()
2273 dl_list_for_each(conn, &ctrl->conn, struct dpp_connection, list) { in dpp_controller_get_auth()
2285 struct dpp_controller *ctrl = dpp->controller; in dpp_controller_new_qr_code() local
2288 if (!ctrl) in dpp_controller_new_qr_code()
2291 dl_list_for_each(conn, &ctrl->conn, struct dpp_connection, list) { in dpp_controller_new_qr_code()
2308 struct dpp_controller *ctrl = dpp->controller; in dpp_controller_pkex_add() local
2310 if (!ctrl) in dpp_controller_pkex_add()
2313 ctrl->pkex_bi = bi; in dpp_controller_pkex_add()
2314 os_free(ctrl->pkex_code); in dpp_controller_pkex_add()
2315 ctrl->pkex_code = code ? os_strdup(code) : NULL; in dpp_controller_pkex_add()
2316 os_free(ctrl->pkex_identifier); in dpp_controller_pkex_add()
2317 ctrl->pkex_identifier = identifier ? os_strdup(identifier) : NULL; in dpp_controller_pkex_add()
2360 static void dpp_relay_controller_free(struct dpp_relay_controller *ctrl) in dpp_relay_controller_free() argument
2366 hostapd_ip_txt(&ctrl->ipaddr, txt, sizeof(txt))); in dpp_relay_controller_free()
2368 dl_list_for_each_safe(conn, tmp, &ctrl->conn, struct dpp_connection, in dpp_relay_controller_free()
2371 os_free(ctrl); in dpp_relay_controller_free()
2377 struct dpp_relay_controller *ctrl, *tmp; in dpp_relay_flush_controllers() local
2382 dl_list_for_each_safe(ctrl, tmp, &dpp->controllers, in dpp_relay_flush_controllers()
2384 dl_list_del(&ctrl->list); in dpp_relay_flush_controllers()
2385 dpp_relay_controller_free(ctrl); in dpp_relay_flush_controllers()
2398 struct dpp_relay_controller *ctrl; in dpp_relay_remove_controller() local
2403 dl_list_for_each(ctrl, &dpp->controllers, struct dpp_relay_controller, in dpp_relay_remove_controller()
2405 if (hostapd_ip_equal(&ctrl->ipaddr, addr)) { in dpp_relay_remove_controller()
2406 dl_list_del(&ctrl->list); in dpp_relay_remove_controller()
2407 dpp_relay_controller_free(ctrl); in dpp_relay_remove_controller()
2426 struct dpp_relay_controller *ctrl; in dpp_relay_tcp_cb() local
2441 ctrl = dpp_relay_controller_get_addr(dpp, &addr); in dpp_relay_tcp_cb()
2442 if (!ctrl && dpp->tmp_controller && in dpp_relay_tcp_cb()
2453 if (!ctrl && !dpp->tmp_controller) { in dpp_relay_tcp_cb()
2455 ctrl = os_zalloc(sizeof(*ctrl)); in dpp_relay_tcp_cb()
2456 if (!ctrl) in dpp_relay_tcp_cb()
2458 dl_list_init(&ctrl->conn); in dpp_relay_tcp_cb()
2459 ctrl->global = dpp; in dpp_relay_tcp_cb()
2460 ctrl->ipaddr.af = AF_INET; in dpp_relay_tcp_cb()
2461 ctrl->ipaddr.u.v4.s_addr = addr.sin_addr.s_addr; in dpp_relay_tcp_cb()
2462 ctrl->msg_ctx = dpp->relay_msg_ctx; in dpp_relay_tcp_cb()
2463 ctrl->cb_ctx = dpp->relay_cb_ctx; in dpp_relay_tcp_cb()
2464 ctrl->tx = dpp->relay_tx; in dpp_relay_tcp_cb()
2465 ctrl->gas_resp_tx = dpp->relay_gas_resp_tx; in dpp_relay_tcp_cb()
2466 dpp->tmp_controller = ctrl; in dpp_relay_tcp_cb()
2468 if (!ctrl) { in dpp_relay_tcp_cb()
2474 if (dl_list_len(&ctrl->conn) >= 15) { in dpp_relay_tcp_cb()
2484 conn->global = ctrl->global; in dpp_relay_tcp_cb()
2485 conn->relay = ctrl; in dpp_relay_tcp_cb()
2486 conn->msg_ctx = ctrl->msg_ctx; in dpp_relay_tcp_cb()
2487 conn->cb_ctx = ctrl->global->cb_ctx; in dpp_relay_tcp_cb()
2504 dl_list_add(&ctrl->conn, &conn->list); in dpp_relay_tcp_cb()