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 "lnn_event.h"
18 
19 #include "softbus_event.h"
20 
LnnEventInner(int32_t scene,int32_t stage,const char * func,int32_t line,LnnEventExtra * extra)21 void LnnEventInner(int32_t scene, int32_t stage, const char *func, int32_t line, LnnEventExtra *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 = LNN_EVENT_NAME,
29         .scene = scene,
30         .stage = stage,
31         .func = func,
32         .line = line,
33         .lnnExtra = extra,
34     };
35     SoftbusEventInner(EVENT_MODULE_LNN, &form);
36 }
37 
LnnAlarmInner(int32_t scene,int32_t type,const char * func,int32_t line,LnnAlarmExtra * extra)38 void LnnAlarmInner(int32_t scene, int32_t type, const char *func, int32_t line, LnnAlarmExtra *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         .lnnAlarmExtra = extra,
47     };
48     SoftbusEventInner(EVENT_MODULE_LNN_ALARM, &form);
49 }
50 
LnnAuditInner(int32_t scene,const char * func,int32_t line,LnnAuditExtra * extra)51 void LnnAuditInner(int32_t scene, const char *func, int32_t line, LnnAuditExtra *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 = LNN_AUDIT_NAME,
59         .scene = scene,
60         .func = func,
61         .line = line,
62         .lnnAuditExtra = extra,
63     };
64     SoftbusAuditInner(EVENT_MODULE_LNN, &form);
65 }
66 
LnnEventExtraInit(LnnEventExtra * extra)67 void LnnEventExtraInit(LnnEventExtra *extra)
68 {
69     extra->peerDeviceInfo = NULL;
70     extra->peerIp = NULL;
71     extra->peerBrMac = NULL;
72     extra->peerBleMac = NULL;
73     extra->peerWifiMac = NULL;
74     extra->peerPort = NULL;
75     extra->peerUdid = NULL;
76     extra->peerNetworkId = NULL;
77     extra->localDeviceType = NULL;
78     extra->peerDeviceType = NULL;
79     extra->localUdidHash = NULL;
80     extra->peerUdidHash = NULL;
81     extra->callerPkg = NULL;
82     extra->calleePkg = NULL;
83 }