IsInSubnet()
The IsInSubnet(); rule determines whether
a specified IP address is in a given subnet, based on the subnet mask.
Syntax
The IsInSubnet(); statement
uses following syntax.
IsInSubnet( ip , subnet , mask );The rule returns an integer where 0 indicates that the IP address is not in the subnet and 1 indicates that the IP address is in the subnet.
Arguments
The following table lists the properties of the arguments of this stitcher rule.| Argument | Description | Accepts constants | Accepts variables | Accepts eval clauses |
|---|---|---|---|---|
ip |
Textual IP address (dot notation for IPv4; colon notation for IPv6). | Yes | Yes | No |
subnet |
Textual subnet (dot notation for IPv4; colon notation for IPv6). | Yes | Yes | No |
mask |
This argument can be specified as a string in the same format as the subnet/IP or as a numerical integer mask. | Yes | Yes | No |
Example
The following example shows how
the ExecuteSQL() rule is used to test whether an
IPv4 address passed as an argument is within the scope of a specified
Class C subnet.
int inScope = 0;
text ip = eval(text, '$ARG_2');
inScope = IsInSubnet( ip, "10.10.10.0", 24 )