• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 WIFI_DIRECT_LINK_INFO_H
17 #define WIFI_DIRECT_LINK_INFO_H
18 
19 #include "info_container.h"
20 #include <cJSON.h>
21 #include "common_list.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 enum LinkInfoKey {
28     LI_KEY_LOCAL_INTERFACE = 0,
29     LI_KEY_REMOTE_INTERFACE = 1,
30     LI_KEY_LOCAL_LINK_MODE = 2,
31     LI_KEY_REMOTE_LINK_MODE = 3,
32     LI_KEY_CENTER_20M = 4,
33     LI_KEY_CENTER_FREQUENCY1 = 5,
34     LI_KEY_CENTER_FREQUENCY2 = 6,
35     LI_KEY_BANDWIDTH = 7,
36     LI_KEY_SSID = 8,
37     LI_KEY_BSSID = 9,
38     LI_KEY_PSK = 10,
39     LI_KEY_IS_DHCP = 11,
40     LI_KEY_LOCAL_IPV4 = 12,
41     LI_KEY_REMOTE_IPV4 = 13,
42     LI_KEY_AUTH_PORT = 14,
43     LI_KEY_MAX_PHYSICAL_RATE = 15,
44     LI_KEY_REMOTE_DEVICE = 16,
45     LI_KEY_STATUS = 17,
46     LI_KEY_LOCAL_BASE_MAC = 18,
47     LI_KEY_REMOTE_BASE_MAC = 19,
48     LI_KEY_IS_CLIENT = 20,
49     LI_KEY_MAX,
50 };
51 
52 struct LinkInfo {
53     INFO_CONTAINER_BASE(LinkInfo, LI_KEY_MAX);
54 
55     cJSON* (*toJsonObject)(struct LinkInfo *self);
56     int32_t (*getLocalIpString)(struct LinkInfo *self, char *ipString, int32_t ipStringSize);
57     int32_t (*getRemoteIpString)(struct LinkInfo *self, char *ipString, int32_t ipStringSize);
58     void (*putLocalIpString)(struct LinkInfo *self, const char *ipString);
59     void (*putRemoteIpString)(struct LinkInfo *self, const char *ipString);
60 
61     ListNode node;
62 };
63 
64 void LinkInfoConstructor(struct LinkInfo* self);
65 void LinkInfoConstructorWithNameAndMode(struct LinkInfo* self, const char *localName, const char *remoteName,
66                                         uint32_t localMode, uint32_t remoteMod);
67 void LinkInfoDestructor(struct LinkInfo* self);
68 
69 struct LinkInfo* LinkInfoNew(void);
70 struct LinkInfo* LinkInfoNewWithNameAndMode(const char *localName, const char *remoteName,
71                                             uint32_t localMode, uint32_t remoteMod);
72 void LinkInfoDelete(struct LinkInfo* self);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 #endif