/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.wifi.supplicant@1.2;

import @1.0::SupplicantStatus;
import @1.1::ISupplicantStaIface;
import @1.2::ISupplicantStaIfaceCallback;
import @1.2::ISupplicantStaNetwork;

/**
 * Interface exposed by the supplicant for each station mode network
 * interface (e.g wlan0) it controls.
 */
interface ISupplicantStaIface extends @1.1::ISupplicantStaIface {
    /**
     * Register for callbacks from this interface.
     *
     * These callbacks are invoked for events that are specific to this interface.
     * Registration of multiple callback objects is supported. These objects must
     * be automatically deleted when the corresponding client process is dead or
     * if this interface is removed.
     *
     * @param callback An instance of the |ISupplicantStaIfaceCallback| HIDL
     *        interface object.
     * @return status Status of the operation.
     *         Possible status codes:
     *         |SupplicantStatusCode.SUCCESS|,
     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
     *         |SupplicantStatusCode.FAILURE_IFACE_INVALID|
     */
    registerCallback_1_2(ISupplicantStaIfaceCallback callback)
        generates (SupplicantStatus status);

    /**
     * Get Key management capabilities of the device
     *
     * @return status Status of the operation, and a bitmap of key management mask.
     *         Possible status codes:
     *         |SupplicantStatusCode.SUCCESS|,
     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
     */
    getKeyMgmtCapabilities()
        generates (SupplicantStatus status, bitfield<KeyMgmtMask> keyMgmtMask);

    /**
     * Add a DPP peer URI. URI is acquired externally, e.g. by scanning a QR code
     *
     * @param uri Peer's DPP URI.
     * @return status Status of the operation, and an ID for the URI.
     *         Possible status codes:
     *         |SupplicantStatusCode.SUCCESS|,
     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
     */
    addDppPeerUri(string uri)
        generates (SupplicantStatus status, uint32_t id);

    /**
     * Remove a DPP peer URI.
     *
     * @param id The ID of the URI, as returned by |addDppPeerUri|.
     * @return status Status of the operation.
     *         Possible status codes:
     *         |SupplicantStatusCode.SUCCESS|,
     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
     */
    removeDppUri(uint32_t id)
        generates (SupplicantStatus status);

    /**
     * Start DPP in Configurator-Initiator mode.
     *
     * @param peerBootstrapId Peer device's URI ID.
     * @param ownBootstrapId Local device's URI ID (0 for none, optional).
     * @param ssid Network SSID to send to peer (SAE/PSK mode).
     * @param password Network password to send to peer (SAE/PSK mode).
     * @param psk Network PSK to send to peer (PSK mode only). Either password or psk should be set.
     * @param netRole Role to configure the peer, |DppNetRole.DPP_NET_ROLE_STA| or
     *        |DppNetRole.DPP_NET_ROLE_AP|.
     * @param securityAkm Security AKM to use (See DppAkm).
     * @return status Status of the operation.
     *         Possible status codes:
     *         |SupplicantStatusCode.SUCCESS|,
     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
     */
    startDppConfiguratorInitiator(uint32_t peerBootstrapId,
        uint32_t ownBootstrapId, string ssid, string password,
        string psk, DppNetRole netRole, DppAkm securityAkm)
        generates (SupplicantStatus status);

    /**
     * Start DPP in Enrollee-Initiator mode.
     *
     * @param peerBootstrapId Peer device's URI ID.
     * @param ownBootstrapId Local device's URI ID (0 for none, optional).
     * @return status Status of the operation.
     *         Possible status codes:
     *         |SupplicantStatusCode.SUCCESS|,
     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
     */
    startDppEnrolleeInitiator(uint32_t peerBootstrapId,
        uint32_t ownBootstrapId)
        generates (SupplicantStatus status);

    /**
     * Stop DPP Initiator operation.
     *
     * @return status Status of the operation.
     *         Possible status codes:
     *         |SupplicantStatusCode.SUCCESS|,
     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
     */
     stopDppInitiator()
        generates (SupplicantStatus status);
};
