Creating Rules Based on Time (Windows CE 5.0)
The following table shows an example of how to create rules based on time. In this case, outbound traffic from the specified host is allowed between 9:00 PM and 8:00 AM.
dwFlags | wHourStart | wHourEnd |
---|---|---|
FWF_BLOCK | FWF_OUTBOUND | ||
FWF_ALLOW | FWF_OUTBOUND | 21 | 8 |
Registry entries for the rule
The following registry example shows the registry entries for this rule.
[HKEY_LOCAL_MACHINE\COMM\Firewall\Rules\BlockOutbound]
"Mask"=dword:0 ;
"Flags"=dword:11 ; FWF_BLOCK | FWF_OUTBOUND
"PrivateHost"=hex:02,00 ; AF_INET
[HKEY_LOCAL_MACHINE\COMM\Firewall\Rules\AllowOutbound9p8a]
"Mask"=dword:80 ; FWM_TIME_OF_DAY
"Flags"=dword:12 ; FWF_ALLOW | FWF_OUTBOUND
"PrivateHost"=hex:02,00 ; AF_INET
"HourStart"=dword:15 ; 9 PM
"HourEnd"=dword:8 ; 8 AM
Code example to create the rule
The following code example shows this rule.
FW_RULE BlockOutbound;
// The following fields must always be set.
BlockOutbound.dwSize = sizeof(FW_RULE);
BlockOutbound.dwFlags = FWF_BLOCK | FWF_OUTBOUND;
BlockOutbound.dwMask = 0;
BlockOutbound.PrivateHost.Family = AF_INET;
BlockOutbound.wszDescription = L"Block outbound traffic";
// Create a persistent rule.
FirewallCreateRule(&BlockOutbound, TRUE);
FW_RULE AllowOutbound9p8a;
// The following fields must always be set.
AllowOutbound9p8a.dwSize = sizeof(FW_RULE);
AllowOutbound9p8a.dwFlags = FWF_ALLOW | FWF_OUTBOUND;
AllowOutbound9p8a.dwMask = FWM_TIME_OF_DAY;
AllowOutbound9p8a.PrivateHost.Family = AF_INET;
AllowOutbound9p8a.wszDescription = L"Allow outbound traffic from the specified host between the 9 PM and 8 AM";
// Time of day.
AllowOutbound9p8a.wHourStart = 21;
AllowOutbound9p8a.wHourEnd = 8;
// Create a persistent rule.
FirewallCreateRule(&AllowOutbound9p8a, TRUE);
See Also
General Firewall Rule Examples | Default IP Firewall Rules | FW_RULE
Send Feedback on this topic to the authors