1 /* 2 * Copyright (c) 2025 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_NETWORK_MANAGER_STRUCT_H 17 #define LNN_NETWORK_MANAGER_STRUCT_H 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 22 #include "bus_center_info_key_struct.h" 23 #include "common_list.h" 24 #include "softbus_bus_center.h" 25 #include "softbus_conn_interface_struct.h" 26 #include "softbus_protocol_def.h" 27 28 #ifdef __cplusplus 29 #if __cplusplus 30 extern "C" { 31 #endif 32 #endif 33 34 #define LNN_LOOPBACK_IFNAME "lo" 35 36 // netif type 37 #define LNN_NETIF_TYPE_ETH (0x1) 38 #define LNN_NETIF_TYPE_WLAN (0x1 << 1) 39 #define LNN_NETIF_TYPE_BR (0x1 << 2) 40 #define LNN_NETIF_TYPE_BLE (0x1 << 3) 41 #define LNN_NETIF_TYPE_USB (0x1 << 4) 42 typedef uint16_t LnnNetIfType; 43 44 #define LNN_NETWORK_MAX_PROTOCOL_COUNT 4 45 46 typedef struct { 47 ListNode node; 48 LnnNetIfType type; 49 char ifName[NET_IF_NAME_LEN]; 50 } LnnNetIfMgr; 51 52 typedef LnnNetIfMgr *(*LnnNetIfManagerBuilder)(const char *ifName); 53 54 typedef enum { 55 CHOICE_VISIT_NEXT, 56 CHOICE_FINISH_VISITING 57 } VisitNextChoice; 58 59 typedef VisitNextChoice (*VisitNetifCallback)(const LnnNetIfMgr *, void *); 60 61 typedef enum { 62 LNN_LISTENER_MODE_PROXY, 63 LNN_LISTENER_MODE_DIRECT, 64 LNN_LISTENER_MODE_AUTH 65 } ListenerMode; 66 67 typedef struct LnnProtocolManager { 68 int32_t (*init)(struct LnnProtocolManager *self); 69 void (*deinit)(struct LnnProtocolManager *self); 70 int32_t (*enable)(struct LnnProtocolManager *self, LnnNetIfMgr *netifMgr); 71 int32_t (*disable)(struct LnnProtocolManager *self, LnnNetIfMgr *netifMgr); 72 ListenerModule (*getListenerModule)(ListenerMode mode); 73 ProtocolType id; 74 LnnNetIfType supportedNetif; 75 uint16_t pri; 76 } LnnProtocolManager; 77 78 typedef LnnNetIfMgr *(*LnnNetIfManagerBuilder)(const char *ifName); 79 80 typedef VisitNextChoice (*VisitNetifCallback)(const LnnNetIfMgr *, void *); 81 82 typedef VisitNextChoice (*VisitProtocolCallback)(const LnnProtocolManager *, void *); 83 84 #ifdef __cplusplus 85 #if __cplusplus 86 } 87 #endif /* __cplusplus */ 88 #endif /* __cplusplus */ 89 90 #endif /* LNN_NETWORK_MANAGER_STRUCT_H */