mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
ap: Forward DHCP events to AP event handler
This commit is contained in:
parent
42afc31cbe
commit
0e865a7028
36
src/ap.c
36
src/ap.c
@ -2044,6 +2044,28 @@ static void ap_start_failed(struct ap_state *ap, int err)
|
|||||||
l_free(ap);
|
l_free(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ap_dhcp_event_cb(struct l_dhcp_server *server,
|
||||||
|
enum l_dhcp_server_event event, void *user_data,
|
||||||
|
const struct l_dhcp_lease *lease)
|
||||||
|
{
|
||||||
|
struct ap_state *ap = user_data;
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case L_DHCP_SERVER_EVENT_NEW_LEASE:
|
||||||
|
ap->ops->handle_event(AP_EVENT_DHCP_NEW_LEASE, lease,
|
||||||
|
ap->user_data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case L_DHCP_SERVER_EVENT_LEASE_EXPIRED:
|
||||||
|
ap->ops->handle_event(AP_EVENT_DHCP_LEASE_EXPIRED, lease,
|
||||||
|
ap->user_data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ap_start_cb(struct l_genl_msg *msg, void *user_data)
|
static void ap_start_cb(struct l_genl_msg *msg, void *user_data)
|
||||||
{
|
{
|
||||||
struct ap_state *ap = user_data;
|
struct ap_state *ap = user_data;
|
||||||
@ -2056,12 +2078,22 @@ static void ap_start_cb(struct l_genl_msg *msg, void *user_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ap->netconfig_dhcp && !l_dhcp_server_start(ap->netconfig_dhcp)) {
|
if (ap->netconfig_dhcp) {
|
||||||
|
if (!l_dhcp_server_start(ap->netconfig_dhcp)) {
|
||||||
l_error("DHCP server failed to start");
|
l_error("DHCP server failed to start");
|
||||||
ap_start_failed(ap, -EINVAL);
|
ap_start_failed(ap, -EINVAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!l_dhcp_server_set_event_handler(ap->netconfig_dhcp,
|
||||||
|
ap_dhcp_event_cb,
|
||||||
|
ap, NULL)) {
|
||||||
|
l_error("l_dhcp_server_set_event_handler failed");
|
||||||
|
ap_start_failed(ap, -EIO);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ap->started = true;
|
ap->started = true;
|
||||||
ap->ops->handle_event(AP_EVENT_STARTED, NULL, ap->user_data);
|
ap->ops->handle_event(AP_EVENT_STARTED, NULL, ap->user_data);
|
||||||
}
|
}
|
||||||
@ -3200,6 +3232,8 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,
|
|||||||
case AP_EVENT_REGISTRATION_START:
|
case AP_EVENT_REGISTRATION_START:
|
||||||
case AP_EVENT_REGISTRATION_SUCCESS:
|
case AP_EVENT_REGISTRATION_SUCCESS:
|
||||||
case AP_EVENT_PBC_MODE_EXIT:
|
case AP_EVENT_PBC_MODE_EXIT:
|
||||||
|
case AP_EVENT_DHCP_NEW_LEASE:
|
||||||
|
case AP_EVENT_DHCP_LEASE_EXPIRED:
|
||||||
/* Ignored */
|
/* Ignored */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
2
src/ap.h
2
src/ap.h
@ -33,6 +33,8 @@ enum ap_event_type {
|
|||||||
AP_EVENT_REGISTRATION_START,
|
AP_EVENT_REGISTRATION_START,
|
||||||
AP_EVENT_REGISTRATION_SUCCESS,
|
AP_EVENT_REGISTRATION_SUCCESS,
|
||||||
AP_EVENT_PBC_MODE_EXIT,
|
AP_EVENT_PBC_MODE_EXIT,
|
||||||
|
AP_EVENT_DHCP_NEW_LEASE,
|
||||||
|
AP_EVENT_DHCP_LEASE_EXPIRED,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ap_event_start_failed_data {
|
struct ap_event_start_failed_data {
|
||||||
|
Loading…
Reference in New Issue
Block a user