ap.h (3250B)
1 /* 2 * 3 * Wireless daemon for Linux 4 * 5 * Copyright (C) 2020 Intel Corporation. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 */ 22 23 struct ap_state; 24 struct iovec; 25 enum mpdu_management_subtype; 26 27 enum ap_event_type { 28 AP_EVENT_START_FAILED, 29 AP_EVENT_STARTED, 30 AP_EVENT_STOPPING, 31 AP_EVENT_STATION_ADDED, 32 AP_EVENT_STATION_REMOVED, 33 AP_EVENT_REGISTRATION_START, 34 AP_EVENT_REGISTRATION_SUCCESS, 35 AP_EVENT_PBC_MODE_EXIT, 36 AP_EVENT_DHCP_NEW_LEASE, 37 AP_EVENT_DHCP_LEASE_EXPIRED, 38 }; 39 40 struct ap_event_start_failed_data { 41 int error; 42 }; 43 44 struct ap_event_station_added_data { 45 const uint8_t *mac; 46 const uint8_t *assoc_ies; 47 size_t assoc_ies_len; 48 }; 49 50 struct ap_event_station_removed_data { 51 const uint8_t *mac; 52 enum mmpdu_reason_code reason; 53 }; 54 55 struct ap_event_registration_start_data { 56 const uint8_t *mac; 57 const uint8_t *assoc_ies; 58 size_t assoc_ies_len; 59 }; 60 61 struct ap_event_registration_success_data { 62 const uint8_t *mac; 63 }; 64 65 typedef void (*ap_stopped_func_t)(void *user_data); 66 67 struct ap_ops { 68 void (*handle_event)(enum ap_event_type type, const void *event_data, 69 void *user_data); 70 /* 71 * If .write_extra_ies is provided, this callback must return an upper 72 * bound on the buffer space needed for the extra IEs to be sent in 73 * the frame of given type and, if it's not a beacon frame, in 74 * response to a given client frame. 75 */ 76 size_t (*get_extra_ies_len)(enum mpdu_management_subtype type, 77 const struct mmpdu_header *client_frame, 78 size_t client_frame_len, 79 void *user_data); 80 /* 81 * If not null, writes extra IEs to be added to the outgoing frame of 82 * given type and, if it's not a beacon frame, in response to a given 83 * client frame. May also react to the extra IEs in that frame. 84 * Returns the number of bytes written which must be less than or 85 * equal to the number returned by .get_extra_ies_len when called 86 * with the same parameters. 87 */ 88 size_t (*write_extra_ies)(enum mpdu_management_subtype type, 89 const struct mmpdu_header *client_frame, 90 size_t client_frame_len, 91 uint8_t *out_buf, void *user_data); 92 }; 93 94 struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config, 95 const struct ap_ops *ops, int *err, 96 void *user_data); 97 void ap_shutdown(struct ap_state *ap, ap_stopped_func_t stopped_func, 98 void *user_data); 99 void ap_free(struct ap_state *ap); 100 101 bool ap_station_disconnect(struct ap_state *ap, const uint8_t *mac, 102 enum mmpdu_reason_code reason); 103 104 bool ap_push_button(struct ap_state *ap); 105 void ap_update_beacon(struct ap_state *ap);