Freeside:4:Documentation:Developer/FS/addr range

From Freeside
< Freeside:4:Documentation:Developer‎ | FS
Revision as of 08:16, 18 November 2015 by Jeremyd (talk | contribs) (Edit via perl MediaWiki framework (1.13))

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

NAME

FS::addr_range - Object methods for addr_range records

SYNOPSIS

 use FS::addr_range;

 $record = new FS::addr_range \%hash;
 $record = new FS::addr_range { 'column' => 'value' };

 $error = $record->insert;

 $error = $new_record->replace($old_record);

 $error = $record->delete;

 $error = $record->check;

DESCRIPTION

An FS::addr_range object represents a contiguous range of IP addresses assigned to a certain purpose. Unlike FS::addr_block, this isn't a routing block; the range doesn't have to be aligned on a subnet boundary, and doesn't have a gateway or broadcast address. It's just a range.

rangenum - primary key; start - starting address of the range, as a dotted quad; length - number of addresses in the range, including start; status - what to do with the addresses in this range; currently can only be "unavailable", which makes the addresses unavailable for assignment to any kind of service.

METHODS

new HASHREF
Creates a new range. To add the example to the database, see "insert".
Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the hash method.
insert
Adds this record to the database. If there is an error, returns the error, otherwise returns false.
delete
Delete this record from the database.
replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
check
Checks all fields to make sure this is a valid example. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
end [ IPADDR ]
Get/set the end IP address in the range. This isn't actually part of the record but it's convenient.
contains IPADDR
Checks whether IPADDR (a dotted-quad IPv4 address) is within the range.
as_string
Returns a readable string showing the address range.
desc
Returns a semi-friendly description of the block status.
allow_use
Returns true if addresses in this range can be used by services, etc.

CLASS METHODS

Returns all address ranges that contain IPADDR.

DEVELOPER NOTE

NetAddr::IP objects have netmasks. They also have overloaded operators for addition and subtraction, but those have range limitations when comparing addresses. (An IPv4 address is effectively a uint32; the difference between two IPv4 addresses is the same range, but signed.) In later versions of the library the bigint method can be used as a workaround, but otherwise it's not safe to subtract two addresses that might differ in the first bit of the first octet.

BUGS

SEE ALSO

FS::svc_IP_Mixin, FS::Record, schema.html from the base documentation.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 234:
Unknown directive: =sub