Revize 18ac9009
Přidáno uživatelem Ondřej Fibich před asi 9 roky(ů)
application/models/subnet.php | ||
---|---|---|
* Returns all subnets by device
|
||
*
|
||
* @author Michal Kliment
|
||
* @param type $device_id
|
||
* @return type
|
||
* @param type $device_id ID of device
|
||
* @param type $gateway Returns only subnet where device is gateway
|
||
* @param type $dhcp Returns only subnet where DHCP server is runnning
|
||
* @return MySQL_Result object
|
||
*/
|
||
public function get_all_subnets_by_device ($device_id = NULL, $gateway = FALSE)
|
||
public function get_all_subnets_by_device ($device_id = NULL, $gateway = FALSE, $dhcp = FALSE)
|
||
{
|
||
if (!$device_id)
|
||
$device_id = $this->id;
|
||
... | ... | |
if ($gateway)
|
||
$where .= ' AND gateway = 1';
|
||
|
||
if ($dhcp)
|
||
$where .= ' AND s.dhcp = 1';
|
||
|
||
return $this->db->query("
|
||
SELECT
|
||
s.*, ip.gateway,
|
||
s.*, s.name AS subnet_name, ip.subnet_id, ip.gateway,
|
||
32-log2((~inet_aton(netmask) & 0xffffffff) + 1) AS subnet_range,
|
||
ip.ip_address, INET_NTOA(INET_ATON(ip.ip_address)+1) AS subnet_range_start,
|
||
INET_NTOA(INET_ATON(ip.ip_address)+(~inet_aton(netmask) & 0xffffffff)-2) AS subnet_range_end,
|
||
INET_NTOA(INET_ATON(ip.ip_address)+(~inet_aton(netmask) & 0xffffffff)-1) AS broadcast,
|
||
i.name AS iface
|
||
i.name AS iface, i.id AS iface_id, i.name AS iface_name
|
||
FROM ip_addresses ip
|
||
JOIN subnets s ON s.id = ip.subnet_id
|
||
JOIN ifaces i ON i.id = ip.iface_id
|
Také k dispozici: Unified diff
Fix merge issue that removed all staff from developer branch :-).