Project

General

Profile

« Previous | Next » 

Revision b1b42a06

Added by Warren Baker almost 14 years ago

Combine is_subnet to check for both v4 and v6 subnets

View differences:

etc/inc/util.inc
502 502

  
503 503
}
504 504

  
505
/* returns true if $subnet is a valid subnet in CIDR format */
505
/* returns true if $subnet is a valid IPv4 or IPv6 subnet in CIDR format */
506 506
function is_subnet($subnet) {
507
	if(is_subnetv4($subnet)) {
508
		return true;
509
	}
510
	if(is_subnetv6($subnet)) {
511
		return true;
512
	}
513
	return false;
514
}
515

  
516
/* returns true if $subnet is a valid IPv4 subnet in CIDR format */
517
function is_subnetv4($subnet) {
507 518
	if (!is_string($subnet))
508 519
		return false;
509 520

  

Also available in: Unified diff