1 /*
2 * Copyright (c) 2024 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 #ifdef OHOS_SOCKET_HOOK_ENABLE
17 #include "musl_socket.h"
18 #include <sys/socket.h>
19 #include "common_def.h"
20 #include "musl_socket_preinit_common.h"
21
socket(int domain,int type,int protocol)22 int socket(int domain, int type, int protocol)
23 {
24 volatile const struct SocketDispatchType* dispatch = get_socket_dispatch();
25 if (__predict_false(dispatch != NULL)) {
26 int ret = dispatch->socket(domain, type, protocol);
27 return ret;
28 }
29 int result = MuslSocket(socket)(domain, type, protocol);
30 return result;
31 }
32
33 #endif
34