9
3

my_net.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
  12. /*
  13. This file is also used to make handling of sockets and ioctl()
  14. portable accross systems.
  15. */
  16. #ifndef _my_net_h
  17. #define _my_net_h
  18. #include "my_global.h" /* C_MODE_START, C_MODE_END */
  19. C_MODE_START
  20. #include <errno.h>
  21. #ifdef HAVE_SYS_SOCKET_H
  22. #include <sys/socket.h>
  23. #endif
  24. #ifdef HAVE_NETINET_IN_H
  25. #include <netinet/in.h>
  26. #endif
  27. #ifdef HAVE_ARPA_INET_H
  28. #include <arpa/inet.h>
  29. #endif
  30. #if defined(HAVE_POLL_H)
  31. #include <poll.h>
  32. #elif defined(HAVE_SYS_POLL_H)
  33. #include <sys/poll.h>
  34. #endif /* defined(HAVE_POLL_H) */
  35. #ifdef HAVE_SYS_IOCTL_H
  36. #include <sys/ioctl.h>
  37. #endif
  38. #if !defined(__WIN__)
  39. #include <netinet/in_systm.h>
  40. #include <netinet/in.h>
  41. #include <netinet/ip.h>
  42. #if !defined(alpha_linux_port)
  43. #include <netinet/tcp.h>
  44. #endif
  45. #endif
  46. #if defined(__WIN__)
  47. #define O_NONBLOCK 1 /* For emulation of fcntl() */
  48. /*
  49. SHUT_RDWR is called SD_BOTH in windows and
  50. is defined to 2 in winsock2.h
  51. #define SD_BOTH 0x02
  52. */
  53. #define SHUT_RDWR 0x02
  54. #else
  55. #include <netdb.h> /* getaddrinfo() & co */
  56. #endif
  57. /*
  58. On OSes which don't have the in_addr_t, we guess that using uint32
  59. is the best possible choice. We guess this from the fact that on
  60. HP-UX64bit & FreeBSD64bit & Solaris64bit, in_addr_t is equivalent to
  61. uint32. And on Linux32bit too.
  62. */
  63. #ifndef HAVE_IN_ADDR_T
  64. #define in_addr_t uint32
  65. #endif
  66. C_MODE_END
  67. #endif