-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkNode.php
More file actions
116 lines (104 loc) · 2.42 KB
/
NetworkNode.php
File metadata and controls
116 lines (104 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php // vim:ts=3:sts=3:sw=3:et:
/**
* Network node model
*
* PHP Version 5
*
* @category PHP
* @package MindFrame2
* @author Bryan C. Geraghty <bryan@ravensight.org>
* @copyright 2005-2011 Bryan C. Geraghty
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LGPL
* @link https://github.com/archwisp/MindFrame2
*/
/**
* Network node model
*
* @category PHP
* @package MindFrame2
* @author Bryan C. Geraghty <bryan@ravensight.org>
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LGPL
* @link https://github.com/archwisp/MindFrame2
*/
class MindFrame2_NetworkNode extends MindFrame2_Object
{
const STATE_DOWN = 0;
const STATE_NORMAL = 1;
/**
* @var string
*/
protected $node_id;
/**
* @var string
*/
protected $ip_address;
/**
* @var int
*/
protected $state;
/**
* Model construct
*
* @param string $node_id Physical address
* @param string $ip_address IPv4 address
* @param int $state The node's state
*
* @throws InvalidArgumentException If node id is not a valid MAC address
* @throws InvalidArgumentException If ip address is not a valid IP address
* @throws InvalidArgumentException If state is not an integer value
*/
public function __construct($node_id, $ip_address, $state)
{
if (!MindFrame2_Validate::isValidMacAddress($node_id))
{
throw new InvalidArgumentException(
'Expected valid MAC address for argument #1 (node id)');
}
if (!MindFrame2_Validate::isValidIPv4Address($ip_address))
{
throw new InvalidArgumentException(
'Expected valid IP address for argument #2 (ip address)');
}
$this->node_id = $node_id;
$this->ip_address = $ip_address;
$this->state = $state;
}
/**
* Fetches the node's ID (physical address).
*
* @return string
*/
public function getNodeId()
{
return $this->node_id;
}
/**
* Fetches the node's IP address.
*
* @return string
*/
public function getIpAddress()
{
return $this->ip_address;
}
/**
* Returns the node's state
*
* @return int
*/
public function getState()
{
return $this->state;
}
/**
* Sets the node's state
*
* @param string $state Node's state
*
* @return void
*/
public function setState($state)
{
$this->state = $state;
}
}