1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef RAW_OS_H_
18 #define RAW_OS_H_
19 
20 #include <sys/socket.h>
21 #include <sys/types.h>
22 #include <time.h>
23 
24 #include "android-base/macros.h"
25 
26 #include "wifilogd/local_utils.h"
27 
28 namespace android {
29 namespace wifilogd {
30 
31 // Enables interposing on operating system calls.
32 class RawOs {
33  public:
34   RawOs();
35   virtual ~RawOs();
36 
37   // See clock_gettime().
38   virtual int ClockGettime(clockid_t clock_id,
39                            NONNULL struct timespec* tspec) const;
40 
41   // See android_get_control_socket().
42   virtual int GetControlSocket(const char* socket_name);
43 
44   // See nanosleep().
45   virtual int Nanosleep(NONNULL const struct timespec* req,
46                         struct timespec* rem);
47 
48   // See recv().
49   virtual ssize_t Recv(int sockfd, void* buf, size_t buflen, int flags);
50 
51   // See write().
52   virtual ssize_t Write(int fd, const void* buf, size_t buflen);
53 
54  private:
55   DISALLOW_COPY_AND_ASSIGN(RawOs);
56 };
57 
58 }  // namespace wifilogd
59 }  // namespace android
60 
61 #endif  // RAW_OS_H_
62