• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LNN_LANE_LINK_STRUCT_H
17 #define LNN_LANE_LINK_STRUCT_H
18 
19 #include <stdint.h>
20 
21 #include "bus_center_info_key_struct.h"
22 #include "lnn_lane_def_struct.h"
23 #include "lnn_lane_link_conflict_struct.h"
24 #include "softbus_common.h"
25 #include "softbus_def.h"
26 #include "softbus_protocol_def.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #define COC_DIRECT_LATENCY      1200
33 #define BR_LATENCY              2500
34 #define WLAN_LATENCY            800
35 #define P2P_LATENCY             1600
36 #define BLE_LATENCY             1500
37 #define HML_LATENCY             1500
38 #define BR_REUSE_LATENCY        1000
39 #define USB_LATENCY             800
40 #define SLE_DIRECT_LATENCY      1200
41 #define SLE_LATENCY             1500
42 
43 typedef struct {
44     char peerNetworkId[NETWORK_ID_BUF_LEN];
45     bool networkDelegate;
46     bool p2pOnly;
47     //OldInfo
48     char peerBleMac[MAX_MAC_LEN];
49     char peerSleMac[MAX_MAC_LEN];
50     bool isSupportIpv6;
51     bool isVirtualLink;
52     bool isInnerCalled; // Indicates whether to select a link for TransOpenNetWorkingChannel
53     int32_t psm;
54     LaneTransType transType;
55     uint32_t actionAddr;
56 
57     LaneLinkType linkType;
58     ProtocolType acceptableProtocols;
59     int32_t pid;
60     uint32_t bandWidth;
61     uint64_t triggerLinkTime;
62     uint64_t availableLinkTime;
63 } LinkRequest;
64 
65 typedef struct {
66     int32_t channel;
67     LaneBandwidth bw;
68     WlanConnInfo connInfo;
69 } WlanLinkInfo;
70 
71 typedef struct {
72     int32_t channel;
73     LaneBandwidth bw;
74     UsbConnInfo connInfo;
75 } UsbLinkInfo;
76 
77 typedef struct {
78     int32_t channel;
79     LaneBandwidth bw;
80     P2pConnInfo connInfo;
81 } P2pLinkInfo;
82 
83 typedef struct {
84     char brMac[BT_MAC_LEN];
85 } BrLinkInfo;
86 
87 // 'GATT' and 'CoC' protocols under BLE use the same definitions
88 typedef struct {
89     char bleMac[BT_MAC_LEN];
90     char deviceIdHash[UDID_HASH_LEN];
91     BleProtocolType protoType;
92     int32_t psm;
93 } BleLinkInfo;
94 
95 // 'GATT' and 'CoC' protocols under BLE use the same definitions
96 typedef struct {
97     BleProtocolType protoType;
98     char networkId[NETWORK_ID_BUF_LEN];
99 } BleDirectInfo;
100 
101 typedef struct {
102     SleProtocolType protoType;
103     char networkId[NETWORK_ID_BUF_LEN];
104 } SleDirectInfo;
105 
106 typedef struct {
107     char sleMac[BT_MAC_LEN];
108     char deviceIdHash[UDID_HASH_LEN];
109     SleProtocolType protoType;
110 } SleLinkInfo;
111 
112 typedef struct {
113     char peerUdid[UDID_BUF_LEN];
114     char netifName[NET_IF_NAME_LEN];
115     LaneLinkType type;
116     union {
117         WlanLinkInfo wlan;
118         P2pLinkInfo p2p;
119         BrLinkInfo br;
120         BleLinkInfo ble;
121         BleDirectInfo bleDirect;
122         RawWifiDirectConnInfo rawWifiDirect;
123         UsbLinkInfo usb;
124         SleLinkInfo sle;
125         SleDirectInfo sleDirect;
126     } linkInfo;
127 } LaneLinkInfo;
128 
129 typedef struct {
130     bool isServerSide;
131     uint32_t laneScore;
132     uint32_t laneFload;
133     uint32_t clientRef;
134     LaneLinkInfo link;
135     ListNode node;
136     uint64_t laneId;
137 } LaneResource;
138 
139 typedef struct {
140     void (*onLaneLinkSuccess)(uint32_t reqId, LaneLinkType linkType, const LaneLinkInfo *linkInfo);
141     void (*onLaneLinkFail)(uint32_t reqId, int32_t reason, LaneLinkType linkType);
142 } LaneLinkCb;
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 #endif // LNN_LANE_LINK_STRUCT_H