00001
00002
00003 #include "ace/OS_NS_stropts.h"
00004
00005 ACE_RCSID(ace, OS_NS_stropts, "OS_NS_stropts.cpp,v 1.6 2006/02/28 00:23:12 shuston Exp")
00006
00007 #if !defined (ACE_HAS_INLINED_OSCALLS)
00008 # include "ace/OS_NS_stropts.inl"
00009 #endif
00010
00011 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00012
00013 int
00014 ACE_OS::ioctl (ACE_HANDLE socket,
00015 unsigned long io_control_code,
00016 void *in_buffer_p,
00017 unsigned long in_buffer,
00018 void *out_buffer_p,
00019 unsigned long out_buffer,
00020 unsigned long *bytes_returned,
00021 ACE_OVERLAPPED *overlapped,
00022 ACE_OVERLAPPED_COMPLETION_FUNC func)
00023 {
00024 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00025 ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
00026 io_control_code,
00027 in_buffer_p,
00028 in_buffer,
00029 out_buffer_p,
00030 out_buffer,
00031 bytes_returned,
00032 (WSAOVERLAPPED *) overlapped,
00033 func),
00034 int,
00035 SOCKET_ERROR);
00036 # else
00037 ACE_UNUSED_ARG (socket);
00038 ACE_UNUSED_ARG (io_control_code);
00039 ACE_UNUSED_ARG (in_buffer_p);
00040 ACE_UNUSED_ARG (in_buffer);
00041 ACE_UNUSED_ARG (out_buffer_p);
00042 ACE_UNUSED_ARG (out_buffer);
00043 ACE_UNUSED_ARG (bytes_returned);
00044 ACE_UNUSED_ARG (overlapped);
00045 ACE_UNUSED_ARG (func);
00046 ACE_NOTSUP_RETURN (-1);
00047 # endif
00048 }
00049
00050 #if !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500))
00051 int
00052 ACE_OS::ioctl (ACE_HANDLE socket,
00053 unsigned long io_control_code,
00054 ACE_QoS &ace_qos,
00055 unsigned long *bytes_returned,
00056 void *buffer_p,
00057 unsigned long buffer,
00058 ACE_OVERLAPPED *overlapped,
00059 ACE_OVERLAPPED_COMPLETION_FUNC func)
00060 {
00061 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00062
00063 QOS qos;
00064 unsigned long qos_len = sizeof (QOS);
00065
00066 if (io_control_code == SIO_SET_QOS)
00067 {
00068 qos.SendingFlowspec = *(ace_qos.sending_flowspec ());
00069 qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ());
00070 qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific ();
00071
00072 qos_len += ace_qos.provider_specific ().iov_len;
00073
00074 ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
00075 io_control_code,
00076 &qos,
00077 qos_len,
00078 buffer_p,
00079 buffer,
00080 bytes_returned,
00081 (WSAOVERLAPPED *) overlapped,
00082 func),
00083 int,
00084 SOCKET_ERROR);
00085 }
00086 else
00087 {
00088 unsigned long dwBufferLen = 0;
00089
00090
00091 int result = ::WSAIoctl ((ACE_SOCKET) socket,
00092 io_control_code,
00093 NULL,
00094 0,
00095 &dwBufferLen,
00096 sizeof (dwBufferLen),
00097 bytes_returned,
00098 NULL,
00099 NULL);
00100
00101
00102 if (result == SOCKET_ERROR)
00103 {
00104 unsigned long dwErr = ::WSAGetLastError ();
00105
00106 if (dwErr == WSAEWOULDBLOCK)
00107 {
00108 errno = dwErr;
00109 return -1;
00110 }
00111 else
00112 if (dwErr != WSAENOBUFS)
00113 {
00114 errno = dwErr;
00115 return -1;
00116 }
00117 }
00118
00119 char *qos_buf;
00120 ACE_NEW_RETURN (qos_buf,
00121 char [dwBufferLen],
00122 -1);
00123
00124 QOS *qos = reinterpret_cast<QOS*> (qos_buf);
00125
00126 result = ::WSAIoctl ((ACE_SOCKET) socket,
00127 io_control_code,
00128 NULL,
00129 0,
00130 qos,
00131 dwBufferLen,
00132 bytes_returned,
00133 NULL,
00134 NULL);
00135
00136 if (result == SOCKET_ERROR)
00137 return result;
00138
00139 ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate,
00140 qos->SendingFlowspec.TokenBucketSize,
00141 qos->SendingFlowspec.PeakBandwidth,
00142 qos->SendingFlowspec.Latency,
00143 qos->SendingFlowspec.DelayVariation,
00144 # if defined(ACE_HAS_WINSOCK2_GQOS)
00145 qos->SendingFlowspec.ServiceType,
00146 qos->SendingFlowspec.MaxSduSize,
00147 qos->SendingFlowspec.MinimumPolicedSize,
00148 # else
00149 0,
00150 0,
00151 0,
00152 # endif
00153 0,
00154 0);
00155
00156 ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate,
00157 qos->ReceivingFlowspec.TokenBucketSize,
00158 qos->ReceivingFlowspec.PeakBandwidth,
00159 qos->ReceivingFlowspec.Latency,
00160 qos->ReceivingFlowspec.DelayVariation,
00161 # if defined(ACE_HAS_WINSOCK2_GQOS)
00162 qos->ReceivingFlowspec.ServiceType,
00163 qos->ReceivingFlowspec.MaxSduSize,
00164 qos->ReceivingFlowspec.MinimumPolicedSize,
00165 # else
00166 0,
00167 0,
00168 0,
00169 # endif
00170 0,
00171 0);
00172
00173 ace_qos.sending_flowspec (&sending_flowspec);
00174 ace_qos.receiving_flowspec (&receiving_flowspec);
00175 ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific)));
00176
00177
00178 return result;
00179 }
00180
00181 # else
00182 ACE_UNUSED_ARG (socket);
00183 ACE_UNUSED_ARG (io_control_code);
00184 ACE_UNUSED_ARG (ace_qos);
00185 ACE_UNUSED_ARG (bytes_returned);
00186 ACE_UNUSED_ARG (buffer_p);
00187 ACE_UNUSED_ARG (buffer);
00188 ACE_UNUSED_ARG (overlapped);
00189 ACE_UNUSED_ARG (func);
00190 ACE_NOTSUP_RETURN (-1);
00191 # endif
00192 }
00193 #endif
00194
00195 ACE_END_VERSIONED_NAMESPACE_DECL