gnetworking.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2008-2011 Red Hat, Inc.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef __G_NETWORKING_H__
  21. #define __G_NETWORKING_H__
  22. #include <glib.h>
  23. #include <gio/gio-visibility.h>
  24. #ifdef G_OS_WIN32
  25. #include <winsock2.h>
  26. #include <ws2tcpip.h>
  27. #include <windns.h>
  28. #include <mswsock.h>
  29. #include <wspiapi.h>
  30. #include <iphlpapi.h>
  31. #undef interface
  32. #else /* !G_OS_WIN32 */
  33. #include <sys/types.h>
  34. #include <netdb.h>
  35. #include <netinet/in.h>
  36. #include <netinet/tcp.h>
  37. #include <resolv.h>
  38. #include <sys/socket.h>
  39. #include <sys/un.h>
  40. #include <net/if.h>
  41. #include <arpa/inet.h>
  42. #include <arpa/nameser.h>
  43. #ifndef __GI_SCANNER__
  44. #ifndef T_SRV
  45. #define T_SRV 33
  46. #endif
  47. #ifndef _PATH_RESCONF
  48. #define _PATH_RESCONF "/etc/resolv.conf"
  49. #endif
  50. #ifndef CMSG_LEN
  51. /* CMSG_LEN and CMSG_SPACE are defined by RFC 2292, but missing on
  52. * some older platforms.
  53. */
  54. #define CMSG_LEN(len) ((size_t)CMSG_DATA((struct cmsghdr *)NULL) + (len))
  55. /* CMSG_SPACE must add at least as much padding as CMSG_NXTHDR()
  56. * adds. We overestimate here.
  57. */
  58. #define GLIB_ALIGN_TO_SIZEOF(len, obj) (((len) + sizeof (obj) - 1) & ~(sizeof (obj) - 1))
  59. #define CMSG_SPACE(len) GLIB_ALIGN_TO_SIZEOF (CMSG_LEN (len), struct cmsghdr)
  60. #endif
  61. #endif
  62. #endif /* !__GI_SCANNER__ */
  63. G_BEGIN_DECLS
  64. GIO_AVAILABLE_IN_2_36
  65. void g_networking_init (void);
  66. G_END_DECLS
  67. #endif /* __G_NETWORKING_H__ */