-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor packet layers from database into code
- Loading branch information
1 parent
2f959a9
commit 8570f36
Showing
15 changed files
with
140 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/libraries/Exceptions/PacketApplicationLayerNotFoundException.php
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
src/libraries/Exceptions/PacketDirectionInvalidException.php
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
src/libraries/Exceptions/PacketTransportLayerNotFoundException.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace BNETDocs\Libraries\Packet; | ||
|
||
use \BNETDocs\Libraries\Packet\Layer; | ||
use \OutOfBoundsException; | ||
|
||
class Application extends Layer { | ||
|
||
protected static $table = array( | ||
1 => array('Battle.net v1 TCP Messages', 'SID'), | ||
2 => array('Battle.net v1 UDP Messages', 'PKT'), | ||
3 => array('Realm Messages', 'MCP'), | ||
4 => array('D2GS Messages', 'D2GS'), | ||
5 => array('W3GS Messages', 'W3GS'), | ||
6 => array('BotNet Messages', 'PACKET'), | ||
7 => array('BNLS Messages', 'BNLS'), | ||
8 => array('SCGP Messages', 'SCGP'), | ||
9 => array('Battle.net v2 TCP Messages', 'SID2'), | ||
); | ||
|
||
protected function assign(int $id) { | ||
if (!isset(self::$table[$id])) { | ||
throw new OutOfBoundsException(sprintf( | ||
'application id: %d not found', $id | ||
)); | ||
} | ||
|
||
$this->id = $id; | ||
$this->label = self::$table[$id][0]; | ||
$this->tag = self::$table[$id][1]; | ||
} | ||
|
||
public static function getAllAsArray() { | ||
return self::$table; | ||
} | ||
|
||
public static function getAllAsObjects() { | ||
$r = array(); | ||
$k = array_keys(self::$table); | ||
foreach ($k as $id) { | ||
$r[] = new self($id); | ||
} | ||
return $r; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace BNETDocs\Libraries\Packet; | ||
|
||
abstract class Layer { | ||
|
||
protected $id; | ||
protected $label; | ||
protected $tag; | ||
|
||
public function __construct(int $id) { | ||
$this->assign($id); | ||
} | ||
|
||
protected abstract function assign(int $id); | ||
public abstract static function getAllAsArray(); | ||
public abstract static function getAllAsObjects(); | ||
|
||
public function getId() { | ||
return $this->id; | ||
} | ||
|
||
public function getLabel() { | ||
return $this->label; | ||
} | ||
|
||
public function getTag() { | ||
return $this->tag; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace BNETDocs\Libraries\Packet; | ||
|
||
use \BNETDocs\Libraries\Packet\Layer; | ||
use \OutOfBoundsException; | ||
|
||
class Transport extends Layer { | ||
|
||
protected static $table = array( | ||
1 => array('Transmission Control Protocol', 'TCP'), | ||
2 => array('User Datagram Protocol', 'UDP'), | ||
3 => array('Internet Control Message Protocol', 'ICMP'), | ||
); | ||
|
||
protected function assign(int $id) { | ||
if (!isset(self::$table[$id])) { | ||
throw new OutOfBoundsException(sprintf( | ||
'transport id: %d not found', $id | ||
)); | ||
} | ||
|
||
$this->id = $id; | ||
$this->label = self::$table[$id][0]; | ||
$this->tag = self::$table[$id][1]; | ||
} | ||
|
||
public static function getAllAsArray() { | ||
return self::$table; | ||
} | ||
|
||
public static function getAllAsObjects() { | ||
$r = array(); | ||
$k = array_keys(self::$table); | ||
foreach ($k as $id) { | ||
$r[] = new self($id); | ||
} | ||
return $r; | ||
} | ||
|
||
} |
Oops, something went wrong.