Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Icmp/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions Icmp/Icmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Icmp/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.