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 #include "comm_log.h"
17 #include "disc_event.h"
18 
19 #include "softbus_event.h"
20 
DiscEventInner(int32_t scene,int32_t stage,const char * func,int32_t line,DiscEventExtra * extra)21 void DiscEventInner(int32_t scene, int32_t stage, const char *func, int32_t line, DiscEventExtra *extra)
22 {
23     if (func == NULL || extra == NULL) {
24         COMM_LOGE(COMM_DFX, "func or extra is NUll");
25         return;
26     }
27     SoftbusEventForm form = {
28         .eventName = DISC_EVENT_NAME,
29         .scene = scene,
30         .stage = stage,
31         .func = func,
32         .line = line,
33         .discExtra = extra,
34     };
35     SoftbusEventInner(EVENT_MODULE_DISC, &form);
36 }
37 
DiscAlarmInner(int32_t scene,int32_t type,const char * func,int32_t line,DiscAlarmExtra * extra)38 void DiscAlarmInner(int32_t scene, int32_t type, const char *func, int32_t line, DiscAlarmExtra *extra)
39 {
40     SoftbusEventForm form = {
41         .eventName = (type == MANAGE_ALARM_TYPE) ? MANAGE_ALARM_EVENT_NAME : CONTROL_ALARM_EVENT_NAME,
42         .scene = scene,
43         .stage = SOFTBUS_DEFAULT_STAGE,
44         .func = func,
45         .line = line,
46         .discAlarmExtra = extra,
47     };
48     SoftbusEventInner(EVENT_MODULE_DISC_ALARM, &form);
49 }
50 
DiscAuditInner(int32_t scene,const char * func,int32_t line,DiscAuditExtra * extra)51 void DiscAuditInner(int32_t scene, const char *func, int32_t line, DiscAuditExtra *extra)
52 {
53     if (func == NULL || extra == NULL) {
54         COMM_LOGE(COMM_DFX, "func or extra is NUll");
55         return;
56     }
57     SoftbusEventForm form = {
58         .eventName = DISC_AUDIT_NAME,
59         .scene = scene,
60         .func = func,
61         .line = line,
62         .discAuditExtra = extra,
63     };
64     SoftbusAuditInner(EVENT_MODULE_DISC, &form);
65 }
66 
DiscEventExtraInit(DiscEventExtra * extra)67 void DiscEventExtraInit(DiscEventExtra *extra)
68 {
69     extra->capabilityData = NULL;
70     extra->scanCycle = NULL;
71     extra->localNetworkId = NULL;
72     extra->peerIp = NULL;
73     extra->peerBrMac = NULL;
74     extra->peerBleMac = NULL;
75     extra->peerWifiMac = NULL;
76     extra->peerPort = NULL;
77     extra->peerNetworkId = NULL;
78     extra->peerDeviceType = NULL;
79     extra->callerPkg = NULL;
80 }