fspr_arch_networkio.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. 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 NETWORK_IO_H
  17. #define NETWORK_IO_H
  18. #include "fspr_network_io.h"
  19. #include "fspr_general.h"
  20. #include "fspr_poll.h"
  21. #ifdef _MSC_VER
  22. #undef MCAST_JOIN_SOURCE_GROUP
  23. #endif
  24. typedef struct sock_userdata_t sock_userdata_t;
  25. struct sock_userdata_t {
  26. sock_userdata_t *next;
  27. const char *key;
  28. void *data;
  29. };
  30. struct fspr_socket_t {
  31. fspr_pool_t *pool;
  32. SOCKET socketdes;
  33. int type; /* SOCK_STREAM, SOCK_DGRAM */
  34. int protocol;
  35. fspr_sockaddr_t *local_addr;
  36. fspr_sockaddr_t *remote_addr;
  37. int timeout_ms; /* MUST MATCH if timeout > 0 */
  38. fspr_interval_time_t timeout;
  39. fspr_int32_t disconnected;
  40. int local_port_unknown;
  41. int local_interface_unknown;
  42. int remote_addr_unknown;
  43. fspr_int32_t options;
  44. fspr_int32_t inherit;
  45. #if APR_HAS_SENDFILE
  46. /* As of 07.20.04, the overlapped structure is only used by
  47. * fspr_socket_sendfile and that's where it will be allocated
  48. * and initialized.
  49. */
  50. OVERLAPPED *overlapped;
  51. #endif
  52. sock_userdata_t *userdata;
  53. /* if there is a timeout set, then this pollset is used */
  54. fspr_pollset_t *pollset;
  55. };
  56. #ifdef _WIN32_WCE
  57. #ifndef WSABUF
  58. typedef struct _WSABUF {
  59. u_long len; /* the length of the buffer */
  60. char FAR * buf; /* the pointer to the buffer */
  61. } WSABUF, FAR * LPWSABUF;
  62. #endif
  63. #else
  64. /* Not sure if this is the right place to define this */
  65. #define HAVE_STRUCT_IPMREQ
  66. #endif
  67. fspr_status_t status_from_res_error(int);
  68. const char *fspr_inet_ntop(int af, const void *src, char *dst, fspr_size_t size);
  69. int fspr_inet_pton(int af, const char *src, void *dst);
  70. void fspr_sockaddr_vars_set(fspr_sockaddr_t *, int, fspr_port_t);
  71. #define fspr_is_option_set(skt, option) \
  72. (((skt)->options & (option)) == (option))
  73. #define fspr_set_option(skt, option, on) \
  74. do { \
  75. if (on) \
  76. (skt)->options |= (option); \
  77. else \
  78. (skt)->options &= ~(option); \
  79. } while (0)
  80. #endif /* ! NETWORK_IO_H */