diff --git a/Icmp/Factory.php b/Icmp/Factory.php index 710bf9a..769fd3f 100644 --- a/Icmp/Factory.php +++ b/Icmp/Factory.php @@ -30,6 +30,11 @@ public function createIcmp4() return new Icmp($this->loop, $this->socketFactory->createIcmp4()); } + public function createIcmp6() + { + return new Icmp($this->loop, $this->socketFactory->createIcmp6()); + } + public function getLoop() { return $this->loop; diff --git a/Icmp/Icmp.php b/Icmp/Icmp.php index 2c4b3f4..b562e6b 100644 --- a/Icmp/Icmp.php +++ b/Icmp/Icmp.php @@ -134,8 +134,13 @@ public function resume() public function handleMessage($message, $peer) { - $ip = substr($message, 0, 20); - $icmp = substr($message, 20); + if (strpos($peer, ':') === false) { + // skip IPv4 header for ICMP (v4) + $icmp = substr($message, 20); + } else { + // ICMPv6 uses a real IPv6 message payload + $icmp = $message; + } // echo 'received from ' . $peer . PHP_EOL; // $hex = new Hexdump(); diff --git a/Icmp/Message.php b/Icmp/Message.php index 4acdc8e..5ba5887 100644 --- a/Icmp/Message.php +++ b/Icmp/Message.php @@ -9,8 +9,8 @@ class Message { - const TYPE_ECHO_REQUEST = 8; - const TYPE_ECHO_REPLY = 0; + const TYPE_ECHO_REQUEST = 128; + const TYPE_ECHO_REPLY = 129; private $type; diff --git a/composer.json b/composer.json index e70503a..1c3596c 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "https://github.com/clue/icmp-react", "license": "MIT", "require": { - "clue/socket-react": "0.2.*", + "clue/socket-react": "0.2.*, >= 0.2.1", "e-butik/iodophor": "1.*" }, "autoload": { diff --git a/composer.lock b/composer.lock index 6610775..92878fd 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "fd304fe5953c036bee2b6ef582b3aa3e", + "hash": "5b260286f93b3f6887afa34200c844ef", "packages": [ { "name": "clue/datagram", @@ -96,16 +96,16 @@ }, { "name": "clue/socket-react", - "version": "v0.2.0", + "version": "v0.2.1", "source": { "type": "git", "url": "https://github.com/clue/socket-react.git", - "reference": "e48aa4d37dd2277e5cbff0486509fcdd982c67f6" + "reference": "65251dfebdf8b087772afe0169e11df478e65f51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/clue/socket-react/zipball/e48aa4d37dd2277e5cbff0486509fcdd982c67f6", - "reference": "e48aa4d37dd2277e5cbff0486509fcdd982c67f6", + "url": "https://api.github.com/repos/clue/socket-react/zipball/65251dfebdf8b087772afe0169e11df478e65f51", + "reference": "65251dfebdf8b087772afe0169e11df478e65f51", "shasum": "" }, "require": { @@ -142,7 +142,7 @@ "react", "sockets" ], - "time": "2014-03-04 01:41:03" + "time": "2014-03-04 18:53:44" }, { "name": "e-butik/iodophor",