Click to See Complete Forum and Search --> : Limiting Internet Access


DHillard
November 14th, 2003, 03:15 PM
I've been trying to come up with a relatively secure way to have an application "disable" an ethernet card, thus disabling Internet access to an unattended/unsupervised PC.

This is intended to limit internet access by children when parents are away from the house or working late shifts.

I know that hardware firewalls will allow filtering and time of day access to the internet, but need to write an application that will accumulate time, for instance 2 hrs per day of internet access.

This cannot work by limiting applications such as IE because there may be internet client application making direct connection to chat servers, etc.

I need some facility to programmatically disable the internet interface, or the IP protocol, but have it relatively easy for the controlling application to "reverse" this to allow internet access for the adults.

Does anyone have any suggestions on this? I would prefer a Win32 api or C solution. I don't like or do MFC, .NET, Java, VB etc.

Thanks in advance for your thoughts/suggestions.

David

abcowherd2003
November 17th, 2003, 07:20 PM
All you have to do is use my hangup internet code (below), and get the system date/time (below). You may also have to use a log that will keep track of the times the the users got on or off. Just use a IF statement to see if the current time is equal to the limit time. Hope this helps.

Hangup Internet Code:
////////////////////////////////////////////////////////////////////////////////////
#include <ras.h>
#include <rasapi32.lib>


bool DisconnectRas()
{
bool bOk = false;
RASCONN ras[20];
DWORD dSize,dNumber,dCount;

ras[0].dwSize = sizeof(RASCONN);
dSize = sizeof( ras );

// Get active RAS - Connection
if( RasEnumConnections( ras, &dSize, &dNumber ) == 0 )
{
bOk = true;

for( dCount = 0; dCount < dNumber; dCount++ )
{
// Hang up that connection
if( RasHangUp(ras[dCount].hrasconn) != 0 )
{
bOk = false;
break;
}
}
}
return bOk;
}
////////////////////////////////////////////////////////////////////////////////////

Get system Date/Time:
////////////////////////////////////////////////////////////////////////////////////
Include: Windows.h
Kernel32.lib

Syntax: void GetSystemTime(
LPSYSTEMTIME lpSystemTime
);

Parameters:
lpSystemTime- Pointer to a SYSTEMTIME structure to receive the current system date and time. They are below:
wYear- Year
wMonth- 1 - 12
wDayOfWeek- 0 - 6
wDay- Day
wHour- Hour
wMinute- Minute
wSecond- Second
wMilliseconds- Milliseconds

Return:
This function does not return a value.
////////////////////////////////////////////////////////////////////////////////////