@@ -113,6 +113,11 @@ |
||
| 113 | 113 | */ |
| 114 | 114 | protected $hardwareBroadcastAddress; |
| 115 | 115 | |
| 116 | + /** |
|
| 117 | + * @param integer $interfaceIndex |
|
| 118 | + * @param string $interfaceName |
|
| 119 | + * @param string|null $interfaceMaster |
|
| 120 | + */ |
|
| 116 | 121 | public function __construct($interfaceIndex, $interfaceName, $interfaceMaster, $interfaceFlags, $interfaceProperties, $linkType, $physicalAddress, $hardwareBroadcastAddress) |
| 117 | 122 | { |
| 118 | 123 | $this->interfaceIndex = $interfaceIndex; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @param string $inet6Lines |
| 102 | 102 | * the line(s) to parse |
| 103 | - * @return InetAddress |
|
| 103 | + * @return Inet6Address |
|
| 104 | 104 | * the inet address defined in the output |
| 105 | 105 | */ |
| 106 | 106 | private static function fromString($inet6Lines) |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @param array|Traversable $inet6Lines |
| 117 | 117 | * the line(s) to parse |
| 118 | - * @return InetAddress |
|
| 118 | + * @return Inet6Address |
|
| 119 | 119 | * the inet address defined in the output |
| 120 | 120 | */ |
| 121 | 121 | private static function fromTraversable($inet6Lines) |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | * |
| 240 | 240 | * @param array $lines |
| 241 | 241 | * the 'ip addr' lines for the physical link |
| 242 | - * @return NetLink |
|
| 242 | + * @return \GanbaroDigital\OperatingSystem\NetInterfaces\Values\NetLink |
|
| 243 | 243 | * the value object extracted from the lines of output |
| 244 | 244 | */ |
| 245 | 245 | private static function convertToLink($lines) |
@@ -95,65 +95,65 @@ |
||
| 95 | 95 | * a list of the network interfaces extracted from the given |
| 96 | 96 | * command output |
| 97 | 97 | */ |
| 98 | - private static function fromTraversable($output) |
|
| 99 | - { |
|
| 100 | - // our return value |
|
| 101 | - $retval = []; |
|
| 102 | - |
|
| 103 | - try { |
|
| 104 | - // group the output into smaller chunks for parsing |
|
| 105 | - $groups = self::groupOutputIntoInterfaces($output); |
|
| 106 | - |
|
| 107 | - foreach($groups as $interfaceLines) { |
|
| 108 | - $interface = ParseNetInterface::from($interfaceLines); |
|
| 109 | - $retval[] = $interface; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - catch (E4xx_OperatingSystemException $e) { |
|
| 113 | - throw new E4xx_CannotParseIpAddrOutput($output, $e); |
|
| 114 | - } |
|
| 115 | - catch (E5xx_OperatingSystemException $e) { |
|
| 116 | - throw new E5xx_CannotParseIpAddrOutput($output, $e); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // all done |
|
| 120 | - return $retval; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * convert the output of the 'ip addr show' command into smaller groups |
|
| 125 | - * that are easier to parse |
|
| 126 | - * |
|
| 127 | - * @param array|Traversable $lines |
|
| 128 | - * the output to group |
|
| 129 | - * @return array |
|
| 130 | - * the grouped output |
|
| 131 | - */ |
|
| 132 | - private static function groupOutputIntoInterfaces($lines) |
|
| 133 | - { |
|
| 134 | - $interfaces=[]; |
|
| 135 | - |
|
| 136 | - // what do we have? |
|
| 137 | - foreach ($lines as $line) { |
|
| 138 | - // skip empty lines |
|
| 139 | - if (trim($line) === '') { |
|
| 140 | - continue; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // what do we have? |
|
| 144 | - $lineType = ClassifyIpAddrLine::from($line); |
|
| 145 | - switch ($lineType) { |
|
| 146 | - case ClassifyIpAddrLine::LINK_START: |
|
| 98 | + private static function fromTraversable($output) |
|
| 99 | + { |
|
| 100 | + // our return value |
|
| 101 | + $retval = []; |
|
| 102 | + |
|
| 103 | + try { |
|
| 104 | + // group the output into smaller chunks for parsing |
|
| 105 | + $groups = self::groupOutputIntoInterfaces($output); |
|
| 106 | + |
|
| 107 | + foreach($groups as $interfaceLines) { |
|
| 108 | + $interface = ParseNetInterface::from($interfaceLines); |
|
| 109 | + $retval[] = $interface; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + catch (E4xx_OperatingSystemException $e) { |
|
| 113 | + throw new E4xx_CannotParseIpAddrOutput($output, $e); |
|
| 114 | + } |
|
| 115 | + catch (E5xx_OperatingSystemException $e) { |
|
| 116 | + throw new E5xx_CannotParseIpAddrOutput($output, $e); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // all done |
|
| 120 | + return $retval; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * convert the output of the 'ip addr show' command into smaller groups |
|
| 125 | + * that are easier to parse |
|
| 126 | + * |
|
| 127 | + * @param array|Traversable $lines |
|
| 128 | + * the output to group |
|
| 129 | + * @return array |
|
| 130 | + * the grouped output |
|
| 131 | + */ |
|
| 132 | + private static function groupOutputIntoInterfaces($lines) |
|
| 133 | + { |
|
| 134 | + $interfaces=[]; |
|
| 135 | + |
|
| 136 | + // what do we have? |
|
| 137 | + foreach ($lines as $line) { |
|
| 138 | + // skip empty lines |
|
| 139 | + if (trim($line) === '') { |
|
| 140 | + continue; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // what do we have? |
|
| 144 | + $lineType = ClassifyIpAddrLine::from($line); |
|
| 145 | + switch ($lineType) { |
|
| 146 | + case ClassifyIpAddrLine::LINK_START: |
|
| 147 | 147 | $interfaces[] = [ $line ]; |
| 148 | - break; |
|
| 149 | - default: |
|
| 148 | + break; |
|
| 149 | + default: |
|
| 150 | 150 | $interfaces[count($interfaces) - 1][] = $line; |
| 151 | - } |
|
| 152 | - } |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - // all done |
|
| 155 | - return $interfaces; |
|
| 156 | - } |
|
| 154 | + // all done |
|
| 155 | + return $interfaces; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * parse the output of the 'ip addr show' command |