summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorvishal <vishal@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-09-01 01:39:11 +0000
committervishal <vishal@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-09-01 01:39:11 +0000
commit8085b7de05683c0330794e57732deedb571281a9 (patch)
tree6452e1857a6ef8e3c27024cbe91a5bbd4372bfb4 /examples
parent965d9b9ccee4c87b4b4de2bcea084654dc1548f6 (diff)
downloadATCD-8085b7de05683c0330794e57732deedb571281a9.tar.gz
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r--examples/QOS/server.cpp219
1 files changed, 109 insertions, 110 deletions
diff --git a/examples/QOS/server.cpp b/examples/QOS/server.cpp
index 5de2a42b1f5..cb48878c21f 100644
--- a/examples/QOS/server.cpp
+++ b/examples/QOS/server.cpp
@@ -6,8 +6,7 @@
#include "ace/OS.h"
#include "qosevent.h"
-#include "QOS_Event_Handler.h"
-#include "Read_Handler.h"
+#include "Receiver_QOS_Event_Handler.h"
static BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions);
static VOID PrintOptions(OPTIONS *pOptions);
@@ -42,17 +41,17 @@ static VOID FillQosFlowspecDefault(
pQos->SendingFlowspec = default_g711;
pQos->ReceivingFlowspec = default_notraffic;
}
-
+
ACE_DEBUG ((LM_DEBUG,
"Enabling the QOS Signalling for the receiver.\n"));
-
+
// Enable the QOS signalling.
pQos->ReceivingFlowspec.ServiceType &= ~(SERVICE_NO_QOS_SIGNALING);
-
+
pQos->ProviderSpecific.len = 0;
pQos->ProviderSpecific.buf = NULL;
*cbQosLen = sizeof(QOS) + pQos->ProviderSpecific.len;
-
+
return;
}
@@ -76,8 +75,8 @@ fill_ace_qos_flowspec_default (ACE_QoS *pQos,
25, // TTL. ACE specific. Not used on NT.
1 // Priority. ACE specific. Not used on NT.
);
-
-
+
+
ACE_Flow_Spec ace_default_notraffic (QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
@@ -98,12 +97,12 @@ fill_ace_qos_flowspec_default (ACE_QoS *pQos,
pQos->sending_flowspec (ace_default_g711);
pQos->receiving_flowspec (ace_default_notraffic);
}
-
+
const iovec iov = {0, NULL};
-
+
pQos->provider_specific (iov);
*cbQosLen = sizeof(QOS) + pQos->provider_specific ().iov_len;
-
+
return;
}
@@ -115,9 +114,9 @@ BOOL SetQos(
DWORD *cbQosLen
)
{
-
+
BOOL bError = FALSE;
-
+
// fill in default values
if (stricmp(pQosOptions->szTemplate, QOS_DEFAULTNAME) == 0)
{
@@ -125,11 +124,11 @@ BOOL SetQos(
}
else
{
-
+
ACE_DEBUG ((LM_DEBUG,
"Run the program with -q:default option\n"));
}
-
+
return(!bError);
}
@@ -148,7 +147,7 @@ FillQoSTraffic (ACE_Flow_Spec &afc)
afc.service_type (default_g711.ServiceType);
afc.max_sdu_size (default_g711.MaxSduSize); /* In Bytes */
afc.minimum_policed_size (default_g711.MinimumPolicedSize); /* In Bytes */
-
+
return 0;
}
@@ -167,7 +166,7 @@ FillQoSNoTraffic (ACE_Flow_Spec &afc)
afc.service_type (default_notraffic.ServiceType);
afc.max_sdu_size (default_notraffic.MaxSduSize); /* In Bytes */
afc.minimum_policed_size (default_notraffic.MinimumPolicedSize); /* In Bytes */
-
+
return 0;
}
@@ -184,7 +183,7 @@ FillQoSParams (ACE_QoS_Params &qos_params,
qos_params.socket_qos (qos);
qos_params.group_socket_qos (NULL);
qos_params.flags (JL_BOTH);
-
+
return 0;
}
@@ -194,7 +193,7 @@ main (int argc, char * argv[])
{
WSADATA WSAData;
ACE_Protocol_Info protocol_info;
-
+
OPTIONS options;
if (!ValidOptions(argv, argc, &options))
{
@@ -202,12 +201,12 @@ main (int argc, char * argv[])
"Error in ValidOptions\n"),
-1);
}
-
+
if (WSAStartup ( MAKEWORD(2,2), &WSAData) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Error in WSAStartup\n"),
-1);
-
+
if (FindServiceProvider (options.spOptions.iProtocol,
options.spOptions.bQos,
options.spOptions.bMulticast,
@@ -215,9 +214,9 @@ main (int argc, char * argv[])
ACE_ERROR_RETURN ((LM_ERROR,
"Error in FindServiceProvider\n"),
-1);
-
+
#define MAXCLIENTS 4
-
+
typedef struct _RECV_INFO
{
ACE_HANDLE sd[MAXCLIENTS+1];
@@ -225,22 +224,22 @@ main (int argc, char * argv[])
CHAR * recvbuf;
int nTotalClients;
} RECV_INFO;
-
+
RECV_INFO RecvInfo;
-
+
printf("Receiver\n");
for (int i=0; i<MAXCLIENTS+1; i++)
RecvInfo.sd[i] = ACE_INVALID_HANDLE;
-
+
ACE_QoS qos;
QOS *pQos;
DWORD cbQosLen;
-
+
// By default the QOS is set as QOS_IOCTL_SET_BEFORE. I do not
// override this option in the commandline parameters. Is that
// the right thing to do.
-
+
pQos = NULL;
if (options.spOptions.bQos)
{
@@ -252,17 +251,17 @@ main (int argc, char * argv[])
}
else if (QOS_IOCTL_SET_QOS == options.qosOptions.qosIoctlSet)
{
-
+
// The following was the original comment in the windows code. But
// this does not fall in my path of execution.
-
+
// "this one is tricky. The intent is to send the RESV after
// receiving FD_QOS notification. However, unless we somehow
// inform the GQOSSP that we are interested in QOS, it will not
// send us FD_QOS when receiving a RESV. However, we do not want to
// send out a RESV until we explicitedly set QOS. We therefore do not
// want QOS signalling (i.e. RSVP messages) to be sent."
-
+
options.qosOptions.bDisableSignalling = TRUE;
if (SetQos(RecvInfo.sd[0], &options.qosOptions, TRUE, &qos, &cbQosLen))
{
@@ -275,28 +274,28 @@ main (int argc, char * argv[])
}
else
pQos = NULL;
-
+
// Opeing a new Multicast Datagram with the QoS socket opened previously.
-
+
ACE_SOCK_Dgram_Mcast dgram_mcast;
-
+
SOCKADDR_IN addr;
-
+
ZeroMemory((PVOID)&addr, sizeof(addr));
- addr.sin_family = PF_INET; //protocol_info.iAddressFamily;
- addr.sin_addr.s_addr = inet_addr("234.5.6.7"); //options.szHostname);
- addr.sin_port = htons(5001); //options.port);
-
+ addr.sin_family = PF_INET; //protocol_info.iAddressFamily;
+ addr.sin_addr.s_addr = inet_addr("234.5.6.7"); //options.szHostname);
+ addr.sin_port = htons(5001); //options.port);
+
ACE_INET_Addr mult_addr (&addr, sizeof (addr));
-
+
// Fill the ACE_QoS_Params to be passed to the ACE_OS::join_leaf ()
// through subscribe.
ACE_QoS_Params qos_params;
FillQoSParams (qos_params, NULL, &qos);
-
+
// The following call opens the Dgram_Mcast and calls the join_leaf ()
// with the qos_params supplied here.
-
+
if (dgram_mcast.subscribe (mult_addr,
qos_params,
1,
@@ -313,99 +312,99 @@ main (int argc, char * argv[])
else
ACE_DEBUG ((LM_DEBUG,
"Dgram_Mcast subscribe succeeds \n"));
-
-
+
+
int nIP_TTL = 25;
char achInBuf [BUFSIZ];
DWORD dwBytes;
-
+
// Set IP TTL
if (ACE_OS::ioctl (dgram_mcast.get_handle (), // Socket.
- SIO_MULTICAST_SCOPE, // IO control code.
- &nIP_TTL, // In buffer.
- sizeof (nIP_TTL), // Length of in buffer.
- achInBuf, // Out buffer.
- BUFSIZ, // Length of Out buffer.
- &dwBytes, // bytes returned.
- NULL, // Overlapped.
- NULL) == SOCKET_ERROR) // Func.
+ SIO_MULTICAST_SCOPE, // IO control code.
+ &nIP_TTL, // In buffer.
+ sizeof (nIP_TTL), // Length of in buffer.
+ achInBuf, // Out buffer.
+ BUFSIZ, // Length of Out buffer.
+ &dwBytes, // bytes returned.
+ NULL, // Overlapped.
+ NULL) == SOCKET_ERROR) // Func.
ACE_ERROR ((LM_ERROR,
"Error in Multicast scope ACE_OS::ioctl() \n"));
else
ACE_DEBUG ((LM_DEBUG,
"Setting TTL with Multicast scope ACE_OS::ioctl call succeeds \n"));
-
+
BOOL bFlag = FALSE;
-
+
// Disable LoopBack.
if (ACE_OS::ioctl (dgram_mcast.get_handle (), // Socket.
- SIO_MULTIPOINT_LOOPBACK, // IO control code.
- &bFlag, // In buffer.
- sizeof (bFlag), // Length of in buffer.
- achInBuf, // Out buffer.
- BUFSIZ, // Length of Out buffer.
- &dwBytes, // bytes returned.
- NULL, // Overlapped.
- NULL) == SOCKET_ERROR) // Func.
+ SIO_MULTIPOINT_LOOPBACK, // IO control code.
+ &bFlag, // In buffer.
+ sizeof (bFlag), // Length of in buffer.
+ achInBuf, // Out buffer.
+ BUFSIZ, // Length of Out buffer.
+ &dwBytes, // bytes returned.
+ NULL, // Overlapped.
+ NULL) == SOCKET_ERROR) // Func.
ACE_ERROR ((LM_ERROR,
"Error in Loopback ACE_OS::ioctl() \n"));
else
ACE_DEBUG ((LM_DEBUG,
"Disable Loopback with ACE_OS::ioctl call succeeds \n"));
-
-
+
+
// Fill up a Windows QOS to be passed to ACE_OS::ioctl () later.
QOS win_qos;
FillQosFlowspecDefault (&win_qos, &cbQosLen, &options.qosOptions);
-
+
// Set the QOS for the socket.
if (ACE_OS::ioctl (dgram_mcast.get_handle (), // Socket.
- SIO_SET_QOS, // IO control code.
- (LPVOID) &win_qos, // In buffer.
- cbQosLen, // Length of in buffer.
+ SIO_SET_QOS, // IO control code.
+ (LPVOID) &win_qos, // In buffer.
+ cbQosLen, // Length of in buffer.
NULL,
0,
- &dwBytes, // bytes returned.
- NULL, // Overlapped.
- NULL) == SOCKET_ERROR) // Func.
+ &dwBytes, // bytes returned.
+ NULL, // Overlapped.
+ NULL) == SOCKET_ERROR) // Func.
ACE_ERROR ((LM_ERROR,
"Error in Qos set ACE_OS::ioctl() %d\n",
dwBytes));
else
ACE_DEBUG ((LM_DEBUG,
"Setting Default QOS with ACE_OS::ioctl succeeds \n"));
-
+
// Instantiate a QOS Event Handler and pass the Dgram_Mcast into it.
ACE_QOS_Event_Handler qos_event_handler (dgram_mcast);
-
+
// Register the QOS Handler with the Reactor.
if (ACE_Reactor::instance ()->register_handler (&qos_event_handler,
- ACE_Event_Handler::QOS_MASK) == -1)
+ ACE_Event_Handler::QOS_MASK | ACE_Event_Handler::READ_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"Error in registering QOS Handler\n"),
-1);
-
+
/*
ACE_Read_Handler qos_read_handler;
-
+
ACE_DEBUG ((LM_DEBUG,
"REgistering the Read Handler\n"));
-
+
qos_read_handler.dgram_mcast (dgram_mcast);
-
+
if (ACE_Reactor::instance ()->register_handler (&qos_read_handler,
ACE_Event_Handler::READ_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"Error in registering Read Handler\n"),
-1);
*/
-
+
// Start the event loop.
ACE_DEBUG ((LM_DEBUG,
"Running the Event Loop ... \n"));
-
+
ACE_Reactor::instance ()->run_event_loop ();
-
+
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) shutting down server logging daemon\n"));
return 0;
@@ -425,8 +424,8 @@ BOOL FindServiceProvider(
DWORD dwBufLen = 0;
DWORD dwErr;
BOOL bProtocolFound = FALSE;
-
-
+
+
// first have WSAEnumProtocols tell us how big a buffer is needed
nRet = WSAEnumProtocols(NULL, lpProtocolBuf, &dwBufLen);
if (SOCKET_ERROR != nRet)
@@ -511,10 +510,10 @@ BOOL FindServiceProvider(
free(lpProtocolBuf);
} // lpProtocolBuf
} // WSAEnumProtocols
-
+
if (bProtocolFound)
printf(" Using service provider <%s>\n\n", pProtocolInfo->szProtocol);
-
+
return(bProtocolFound);
}
@@ -523,9 +522,9 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
{
BOOL bValidOptions = TRUE;
OSVERSIONINFO verInfo = {0};
-
+
*pOptions = default_options;
-
+
for (int i=1; i<argc; i++)
{
if ((argv[i][0] == '-') || (argv[i][0] == '/') )
@@ -536,21 +535,21 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
if (strlen(argv[i]) > 3)
pOptions->nBufSize = 1024*atoi(&argv[i][3]);
break;
-
+
case 'c' :
pOptions->qosOptions.bAlternateQos = TRUE;
break;
-
+
case 'd' :
if (strlen(argv[i]) > 3)
pOptions->fillchar = argv[i][3];
break;
-
+
case 'e' :
if (strlen(argv[i]) > 3)
pOptions->port = atoi(&argv[i][3]);
break;
-
+
case 'i' :
if (strlen(argv[i]) > 3)
{
@@ -566,12 +565,12 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_BEFORE;
}
break;
-
+
case 'l' :
if (strlen(argv[i]) > 3)
pOptions->nRepeat = atoi(&argv[i][3]);
break;
-
+
case 'm' :
pOptions->spOptions.bMulticast = TRUE;
if (strlen(argv[i]) > 3)
@@ -579,7 +578,7 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
else
strcpy(pOptions->szHostname, DEFAULT_MULTICASTGROUP);
break;
-
+
case 'n' :
pOptions->qosOptions.bReceiver = FALSE;
// multicast group overrides hostname on -n
@@ -589,7 +588,7 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
strcpy(pOptions->szHostname, &argv[i][3]);
}
break;
-
+
case 'p' :
if (strlen(argv[i]) > 3)
{
@@ -601,13 +600,13 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
pOptions->spOptions.iProtocol = IPPROTO_TCP;
}
break;
-
+
case 'q' :
pOptions->spOptions.bQos = TRUE;
if (strlen(argv[i]) > 3)
strcpy(pOptions->qosOptions.szTemplate, &argv[i][3]);
break;
-
+
case 'r' :
if (strlen(argv[i]) > 3)
{
@@ -629,17 +628,17 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
}
}
break;
-
+
case 's' :
if (strlen(argv[i]) > 3)
pOptions->dwSleep = atoi(&argv[i][3]);
break;
-
+
case '?' :
Usage(argv[0], &default_options);
return(FALSE);
break;
-
+
default:
printf(" unknown options flag %s\n", argv[i]);
Usage(argv[0], &default_options);
@@ -654,17 +653,17 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
return(FALSE);
}
}
-
-
+
+
if (pOptions->qosOptions.bReceiver)
pOptions->fillchar = 0;
-
+
if (pOptions->spOptions.bMulticast)
{
pOptions->spOptions.iProtocol = IPPROTO_UDP;
pOptions->qosOptions.bSetDestaddr = FALSE;
}
-
+
if (IPPROTO_TCP == pOptions->spOptions.iProtocol)
{
pOptions->spOptions.bMulticast = FALSE;
@@ -672,25 +671,25 @@ BOOL ValidOptions(char *argv[], int argc, OPTIONS *pOptions)
}
else if (!pOptions->spOptions.bMulticast)
pOptions->qosOptions.bSetDestaddr = TRUE;
-
+
if (pOptions->spOptions.bQos)
{
if (pOptions->qosOptions.bReceiver && pOptions->qosOptions.bWaitToSend)
pOptions->qosOptions.bWaitToSend = FALSE; // not a valid receiver option
-
+
if (!pOptions->qosOptions.bReceiver && pOptions->qosOptions.bConfirmResv)
pOptions->qosOptions.bWaitToSend = FALSE; // not a valid sender option
-
+
if (pOptions->qosOptions.bAlternateQos)
pOptions->nRepeat = 0; // override repeat count to continuous mode
-
+
if ((IPPROTO_UDP == pOptions->spOptions.iProtocol) &&
(!pOptions->spOptions.bMulticast))
{
// using UDP, there WSAAccept will not be called, therefore do not wait to set qos
pOptions->qosOptions.qosIoctlSet = QOS_IOCTL_SET_BEFORE;
}
-
+
verInfo.dwOSVersionInfoSize = sizeof(verInfo);
GetVersionEx(&verInfo);
switch (verInfo.dwPlatformId)