1f1549183Sopenharmony_ci/* 2f1549183Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3f1549183Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4f1549183Sopenharmony_ci * you may not use this file except in compliance with the License. 5f1549183Sopenharmony_ci * You may obtain a copy of the License at 6f1549183Sopenharmony_ci * 7f1549183Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8f1549183Sopenharmony_ci * 9f1549183Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10f1549183Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11f1549183Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12f1549183Sopenharmony_ci * See the License for the specific language governing permissions and 13f1549183Sopenharmony_ci * limitations under the License. 14f1549183Sopenharmony_ci */ 15f1549183Sopenharmony_ci 16f1549183Sopenharmony_ci#ifndef OHOS_C_P2P_CONFIG_H 17f1549183Sopenharmony_ci#define OHOS_C_P2P_CONFIG_H 18f1549183Sopenharmony_ci 19f1549183Sopenharmony_ci#ifdef __cplusplus 20f1549183Sopenharmony_ciextern "C" { 21f1549183Sopenharmony_ci#endif 22f1549183Sopenharmony_ci 23f1549183Sopenharmony_ci#ifndef COMMON_MAC_LEN 24f1549183Sopenharmony_ci#define COMMON_MAC_LEN 6 25f1549183Sopenharmony_ci#endif 26f1549183Sopenharmony_ci 27f1549183Sopenharmony_ci#define PASSPHRASE_LENGTH 64 28f1549183Sopenharmony_ci#define P2P_NAME_LENGTH 33 29f1549183Sopenharmony_ci#define INTERFACE_LENGTH 16 30f1549183Sopenharmony_ci#define DEVICE_TYPE_LENGTH 128 31f1549183Sopenharmony_ci#define MAX_DEVICES_NUM 256 32f1549183Sopenharmony_ci#define IP_ADDR_STR_LEN 16 33f1549183Sopenharmony_ci 34f1549183Sopenharmony_citypedef enum GroupOwnerBand { 35f1549183Sopenharmony_ci GO_BAND_AUTO, 36f1549183Sopenharmony_ci GO_BAND_2GHZ, 37f1549183Sopenharmony_ci GO_BAND_5GHZ 38f1549183Sopenharmony_ci} GroupOwnerBand; 39f1549183Sopenharmony_ci 40f1549183Sopenharmony_citypedef struct WifiP2pConfig { 41f1549183Sopenharmony_ci unsigned char devAddr[COMMON_MAC_LEN]; /* the device MAC address */ 42f1549183Sopenharmony_ci int bssidType; /* bssid type */ 43f1549183Sopenharmony_ci GroupOwnerBand goBand; 44f1549183Sopenharmony_ci int netId; /* network id, when -2 means persistent and -1 means temporary, else need >= 0 */ 45f1549183Sopenharmony_ci char passphrase[PASSPHRASE_LENGTH]; /* the value ranges from 8 to 63. */ 46f1549183Sopenharmony_ci int groupOwnerIntent; /* the value is -1.(A value of -1 indicates the system can choose an appropriate value.) */ 47f1549183Sopenharmony_ci char groupName[P2P_NAME_LENGTH]; /* the value ranges from 1 to 32. */ 48f1549183Sopenharmony_ci} WifiP2pConfig; 49f1549183Sopenharmony_ci 50f1549183Sopenharmony_citypedef enum P2pGroupStatus { 51f1549183Sopenharmony_ci GS_CREATING, 52f1549183Sopenharmony_ci GS_CREATED, 53f1549183Sopenharmony_ci GS_STARTED, 54f1549183Sopenharmony_ci GS_REMOVING, 55f1549183Sopenharmony_ci GS_INVALID 56f1549183Sopenharmony_ci} P2pGroupStatus; 57f1549183Sopenharmony_ci 58f1549183Sopenharmony_citypedef enum P2pDeviceStatus { 59f1549183Sopenharmony_ci PDS_CONNECTED, 60f1549183Sopenharmony_ci PDS_INVITED, 61f1549183Sopenharmony_ci PDS_FAILED, 62f1549183Sopenharmony_ci PDS_AVAILABLE, 63f1549183Sopenharmony_ci PDS_UNAVAILABLE 64f1549183Sopenharmony_ci} P2pDeviceStatus; 65f1549183Sopenharmony_ci 66f1549183Sopenharmony_citypedef enum P2pState { 67f1549183Sopenharmony_ci P2P_STATE_NONE = 0, 68f1549183Sopenharmony_ci P2P_STATE_IDLE, 69f1549183Sopenharmony_ci P2P_STATE_STARTING, 70f1549183Sopenharmony_ci P2P_STATE_STARTED, 71f1549183Sopenharmony_ci P2P_STATE_CLOSING, 72f1549183Sopenharmony_ci P2P_STATE_CLOSED, 73f1549183Sopenharmony_ci} P2pState; 74f1549183Sopenharmony_ci 75f1549183Sopenharmony_citypedef enum P2pConnectionState { 76f1549183Sopenharmony_ci P2P_DISCONNECTED = 0, 77f1549183Sopenharmony_ci P2P_CONNECTED, 78f1549183Sopenharmony_ci} P2pConnectionState; 79f1549183Sopenharmony_ci 80f1549183Sopenharmony_citypedef struct WifiP2pWfdInfo { 81f1549183Sopenharmony_ci int wfdEnabled; /* 0: false, 1: true */ 82f1549183Sopenharmony_ci int deviceInfo; 83f1549183Sopenharmony_ci int ctrlPort; 84f1549183Sopenharmony_ci int maxThroughput; 85f1549183Sopenharmony_ci} WifiP2pWfdInfo; 86f1549183Sopenharmony_ci 87f1549183Sopenharmony_citypedef struct WifiP2pDevice { 88f1549183Sopenharmony_ci char deviceName[P2P_NAME_LENGTH]; /* the value range is 0 to 32 characters. */ 89f1549183Sopenharmony_ci unsigned char devAddr[COMMON_MAC_LEN]; /* the device MAC address */ 90f1549183Sopenharmony_ci unsigned char randomDevAddr[COMMON_MAC_LEN]; /* the device MAC address */ 91f1549183Sopenharmony_ci int bssidType; /* bssid type. */ 92f1549183Sopenharmony_ci char primaryDeviceType[DEVICE_TYPE_LENGTH]; 93f1549183Sopenharmony_ci char secondaryDeviceType[DEVICE_TYPE_LENGTH]; 94f1549183Sopenharmony_ci P2pDeviceStatus status; 95f1549183Sopenharmony_ci WifiP2pWfdInfo wfdInfo; 96f1549183Sopenharmony_ci unsigned int supportWpsConfigMethods; 97f1549183Sopenharmony_ci int deviceCapabilitys; 98f1549183Sopenharmony_ci int groupCapabilitys; 99f1549183Sopenharmony_ci} WifiP2pDevice; 100f1549183Sopenharmony_ci 101f1549183Sopenharmony_citypedef struct WifiP2pGroupInfo { 102f1549183Sopenharmony_ci WifiP2pDevice owner; 103f1549183Sopenharmony_ci int isP2pGroupOwner; /* 0: false, 1: true */ 104f1549183Sopenharmony_ci char passphrase[PASSPHRASE_LENGTH]; /* the value ranges from 8 to 63. */ 105f1549183Sopenharmony_ci char interface[INTERFACE_LENGTH]; 106f1549183Sopenharmony_ci char groupName[P2P_NAME_LENGTH]; 107f1549183Sopenharmony_ci int networkId; 108f1549183Sopenharmony_ci int frequency; /* for example : freq=2412 to select 2.4 GHz channel 1.(Based on 2.4 GHz or 5 GHz) */ 109f1549183Sopenharmony_ci int isP2pPersistent; /* 0: false, 1: true */ 110f1549183Sopenharmony_ci P2pGroupStatus groupStatus; 111f1549183Sopenharmony_ci WifiP2pDevice clientDevices[MAX_DEVICES_NUM]; 112f1549183Sopenharmony_ci int clientDevicesSize; /* the true size of clientDevices array */ 113f1549183Sopenharmony_ci char goIpAddress[IP_ADDR_STR_LEN]; 114f1549183Sopenharmony_ci} WifiP2pGroupInfo; 115f1549183Sopenharmony_ci 116f1549183Sopenharmony_citypedef struct WifiP2pLinkedInfo { 117f1549183Sopenharmony_ci P2pConnectionState connectState; 118f1549183Sopenharmony_ci int isP2pGroupOwner; 119f1549183Sopenharmony_ci unsigned char groupOwnerAddress[COMMON_MAC_LEN]; 120f1549183Sopenharmony_ci} WifiP2pLinkedInfo; 121f1549183Sopenharmony_ci#ifdef __cplusplus 122f1549183Sopenharmony_ci} 123f1549183Sopenharmony_ci#endif 124f1549183Sopenharmony_ci 125f1549183Sopenharmony_ci#endif 126