home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ibmtool.zip
/
mactest.c
< prev
next >
Wrap
Text File
|
1997-11-07
|
6KB
|
212 lines
#define INCL_SUB
#define INCL_BASE
#define INCL_DOS
#include <os2.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "ndis.h"
#include "ioctl.h"
#include "ibmtool.h"
#include "intrface.h"
int MTMulticast ()
{
char *AddTokenCmd = "ADDMC C0 00 80 01 02 01";
char *AddEthCmd = "ADDMC 01 02 03 04 05 01";
char *RxCmd = "SRVTX 1 100 100 1 ";
char cmd[80];
BYTE MCAddr[ADDR_LEN];
USHORT retval = SUCCESS;
int i;
TTClearMac ();
GetTable (MMC);
// open adapter - if supported
if (MACMSC.MscService & OPEN_ADAPTER_SUPP)
{
ParseCommand ("OPEN");
if (LastStatus != SUCCESS)
{
PrintMsg ("OpenAdapter failed - exiting MACTEST");
return GENERAL_FAILURE;
}
}
// set filter to 3
ParseCommand ("FILTER 3");
if (LastStatus != SUCCESS)
{
PrintMsg ("SePacketFilter 3 failed - exiting MACTEST");
return GENERAL_FAILURE;
}
// identify the server
ParseCommand ("WKSTA");
if (LastStatus != SUCCESS)
{
PrintMsg ("Unable to identify the server - exiting MACTEST");
return GENERAL_FAILURE;
}
// Test 1 - check that Multicast and Functional/Group bits are not both set
if ((MACMSC.MscService & MULTICAST_SUPP &&
(MACMSC.MscService & FUNC_GROUP_ADDR_SUPP))
{
PrintMsg ("Multicast Address and Functional/Group bits are both set.");
PrintMsg ("MULTICASTADDRESS Test 1 FAIL");
retval = GENERAL_FAILURE;
}
else
{
PrintMsg ("Multicast Address and Functional/Group bits are not both set.");
PrintMsg ("MULTICASTADDRESS Test 1 PASS");
}
// see if Multicast Addresses are supported
if (!(MACMSC.MscService & MULTICAST_SUPP))
{
PrintMsg ("Service-Specific Characteristics Tables says");
PrintMsg (" Multicast Addresses are not supported - ");
// Test 2 - verify AddMulticastAddress returns NOT_SUPPORTED
if (TokenRing)
ParseCommand (AddTokenCmd);
else
ParseCommand (AddEthCmd);
if (LastStatus == NOT_SUPPORTED)
{
PrintMsg ("AddMulticastAddress returned NOT_SUPPORTED");
PrintMsg ("ADDMULTICASTADDRESS Test 2 PASS");
return SUCCESS;
}
else
{
PrintMsg ("AddMulticastAddress did not return NOT_SUPPORTED");
PrintMsg ("ADDMULTICASTADDRESS Test 2 FAIL");
retval = GENERAL_FAILURE;
} /* endif */
}
// Test 3 - add invalid Multicast Address
ParseCommand ("ADDMC 00 00 00 00 00 00");
if (LastStatus == INVALID_PARAMETER)
{
PrintMsg ("Addition of invalid Multicast Address returned INVALID_PARAMETER");
PrintMsg ("ADDMULTICASTADDRESS Test 3 PASS");
}
else
{
PrintMsg ("Addition of invalid Multicast Address did not return INVALID_PARAMETER");
PrintMsg ("ADDMULTICASTADDRESS Test 3 FAIL");
}
// Test 4 - Attempt to add the maximum number of Multicast Addresses and
// receive a frame sent to each one.
for (i=1; i<MACMCBuff.McbMax + 1; ++i)
{
if (TokenRing)
strcpy (cmd, AddTokenCmd);
else
strcpy (cmd, AddEthCmd);
sprintf (cmd + 21, "%02X", &i);
ParseCommand (cmd);
if (LastStatus == SUCCESS)
PrintMsg ("Added Multicast Address %d", i);
else
{
PrintMsg ("Addition of Multicast Address %d Failed", i);
return GENERAL_FAILURE;
} /* endif */
GetTable (MMC);
if (MACMCBuff.McbCnt != i)
{
PrintMsg ("Multicast Address count != %d, i);
retval = GENERAL_FAILURE;
}
// Receive to the Multicast Address
IndicationCount = 0;
strcpy (cmd, "SRVTX 1 100 100 1 ");
if (TokenRing)
strcat (cmd, AddTokenCmd + 6);
else
strcat (cmd, AddEthCmd + 6);
ParseCommand (cmd);
DosSleep (2000);
if (IndicationCount == 2)
PrintMsg ("Receive to Multicast Address %d Passed", i);
else
{
PrintMsg ("Receive to Multicast Address %d Failed", i);
retval = GENERAL_FAILURE;
} /* endif */
} /* endfor */
if (retval == SUCCESS)
{
PrintMsg ("Addition of all Multicast Addresses succeeded.");
PrintMsg ("ADDMULTICASTADDRESS Test 4 PASS");
}
else
{
PrintMsg ("Addition of all Multicast Addresses failed.");
PrintMsg ("ADDMULTICASTADDRESS Test 4 FAIL");
return retval;
} /* endif */
// Test 5 - Attempt to add an extra Multicast Address
if (TokenRing)
strcpy (cmd, AddTokenCmd);
else
strcpy (cmd, AddEthCmd);
sprintf (cmd + 21, "%02X", &i);
ParseCommand (cmd);
if (LastStatus != INVALID_FUNCTION)
{
PrintMsg ("Addition of extra Multicast Address succeeded - Failure");
PrintMsg ("ADDMULTICASTADDRESS Test 5 FAIL");
retval = GENERAL_FAILURE;
} /* endif */
GetTable (MMC);
if (MACMCBuff.McbCnt != MACMCBuff.McbMax)
{
PrintMsg ("Multicast Address count != maximum");
PrintMsg ("ADDMULTICASTADDRESS Test 5 FAIL");
retval = GENERAL_FAILURE;
}
// Receive to the extra Multicast Address
IndicationCount = 0;
strcpy (cmd, "SRVTX 1 100 100 1 ");
if (TokenRing)
strcat (cmd, AddTokenCmd + 6);
else
strcat (cmd, AddEthCmd + 6);
ParseCommand (cmd);
DosSleep (2000);
if (IndicationCount > 1)
{
PrintMsg ("Receive to extra Multicast Address succeeded - Failure");
PrintMsg ("ADDMULTICASTADDRESS Test 5 FAIL");
retval = GENERAL_FAILURE;
} /* endif */
// Test 6 - Attempt to add a previously added Multicast Address
if (TokenRing)
strcpy (cmd, AddTokenCmd);
else
strcpy (cmd, AddEthCmd);
strcat (cmd, "01");
ParseCommand (cmd);
if (LastStatus != INVALID_PARAMETER)
{
PrintMsg ("Addition of extra Multicast Address succeeded - Failure");
PrintMsg ("ADDMULTICASTADDRESS Test 6 FAIL");
retval = GENERAL_FAILURE;
} /* endif */
return retval;
}