raw_os.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifndef RAW_OS_H_
  17. #define RAW_OS_H_
  18. #include <sys/socket.h>
  19. #include <sys/types.h>
  20. #include <time.h>
  21. #include "android-base/macros.h"
  22. #include "wifilogd/local_utils.h"
  23. namespace android {
  24. namespace wifilogd {
  25. // Enables interposing on operating system calls.
  26. class RawOs {
  27. public:
  28. RawOs();
  29. virtual ~RawOs();
  30. // See clock_gettime().
  31. virtual int ClockGettime(clockid_t clock_id,
  32. NONNULL struct timespec* tspec) const;
  33. // See android_get_control_socket().
  34. virtual int GetControlSocket(const char* socket_name);
  35. // See nanosleep().
  36. virtual int Nanosleep(NONNULL const struct timespec* req,
  37. struct timespec* rem);
  38. // See recv().
  39. virtual ssize_t Recv(int sockfd, void* buf, size_t buflen, int flags);
  40. // See write().
  41. virtual ssize_t Write(int fd, const void* buf, size_t buflen);
  42. private:
  43. DISALLOW_COPY_AND_ASSIGN(RawOs);
  44. };
  45. } // namespace wifilogd
  46. } // namespace android
  47. #endif // RAW_OS_H_