diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index 837f2a1..925ccea 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -26,6 +26,9 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable protected const PACKED_MSG_LEAD = "\02\00"; protected const PACKED_END = "\00\00"; + public const MSG_TYPE2 = 1<<0; + public const MSG_TYPE4 = 1<<2; + // @todo Rename this regex to something more descriptive, ie: FILENAME_REGEX public const regex = '([[:xdigit:]]{4})(?:-(\d{4,10}))?-(.+)'; @@ -242,10 +245,12 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable case 'tftn': return parent::__get($key); + case 'product': + return Arr::get($this->header,'prodcode-hi')<<8|Arr::get($this->header,'prodcode-lo'); + case 'software': - $code = Arr::get($this->header,'prodcode-hi')<<8|Arr::get($this->header,'prodcode-lo'); Software::unguard(); - $o = Software::singleOrNew(['code'=>$code,'type'=>Software::SOFTWARE_TOSSER]); + $o = Software::singleOrNew(['code'=>$this->product,'type'=>Software::SOFTWARE_TOSSER]); Software::reguard(); return $o; diff --git a/app/Classes/FTN/Packet/FSC39.php b/app/Classes/FTN/Packet/FSC39.php index 82a0155..f7014b8 100644 --- a/app/Classes/FTN/Packet/FSC39.php +++ b/app/Classes/FTN/Packet/FSC39.php @@ -37,7 +37,7 @@ final class FSC39 extends Packet 'capvalid' => [0x28,'n',2], // fsc-0039.004 (copy of 0x2c) 'prodcode-hi' => [0x2a,'C',1], // Product Code Hi 'prodrev-min' => [0x2b,'C',1], // Product Version Minor - 'capword' => [0x2c,'v',2], // Capability Word + 'capword' => [0x2c,'v',2], // Capability Word fsc-0039.004/fsc-0048.002 'dozone' => [0x2e,'v',2], // Orig Zone 'ddzone' => [0x30,'v',2], // Dest Zone 'opoint' => [0x32,'v',2], // Orig Point @@ -46,6 +46,7 @@ final class FSC39 extends Packet ]; public const TYPE = '2e'; + public const VERS = self::MSG_TYPE2; //|self::MSG_TYPE4; public function __get($key) { @@ -85,10 +86,10 @@ final class FSC39 extends Packet $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone '', // Reserved - Arr::get($this->header,'capvalid',1<<0), // fsc-0039.004 (copy of 0x2c) + static::VERS, // fsc-0039.004 (copy of 0x2c) ((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi Setup::PRODUCT_VERSION_MIN, // Product Version Minor - 1<<0, // Capability Word + static::VERS, // Capability Word $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone $this->fftn_p->point_id, // Orig Point diff --git a/app/Classes/FTN/Packet/FSC45.php b/app/Classes/FTN/Packet/FSC45.php index 3df7951..7aabe07 100644 --- a/app/Classes/FTN/Packet/FSC45.php +++ b/app/Classes/FTN/Packet/FSC45.php @@ -37,6 +37,20 @@ final class FSC45 extends Packet public const TYPE = '2.2'; + public function __get($key) + { + switch ($key) { + case 'product': + return Arr::get($this->header,'prodcode'); + + case 'software_ver': + return Arr::get($this->header,'prodrev-maj'); + + default: + return parent::__get($key); + } + } + /** * Create our message packet header */ diff --git a/app/Classes/FTN/Packet/FSC48.php b/app/Classes/FTN/Packet/FSC48.php index 558f8f6..d13f23b 100644 --- a/app/Classes/FTN/Packet/FSC48.php +++ b/app/Classes/FTN/Packet/FSC48.php @@ -11,6 +11,7 @@ use App\Models\Setup; * FSC-0048 http://ftsc.org/docs/fsc-0048.002 * * Commonly known as Type 2+ packets, based on FSC-0039 with improved support for FTS-0001 + * @note: These packets will be detected as FSC-0039 packets unless it is addressed to a point */ final class FSC48 extends Packet { @@ -36,7 +37,7 @@ final class FSC48 extends Packet 'capvalid' => [0x28,'n',2], // fsc-0039.004 (copy of 0x2c) 'prodcode-hi' => [0x2a,'C',1], // Product Code Hi 'prodrev-min' => [0x2b,'C',1], // Product Version Minor - 'capword' => [0x2c,'v',2], // Capability Word + 'capword' => [0x2c,'v',2], // Capability Word fsc-0039.004/fsc-0048.002 'dozone' => [0x2e,'v',2], // Orig Zone 'ddzone' => [0x30,'v',2], // Dest Zone 'opoint' => [0x32,'v',2], // Orig Point @@ -45,6 +46,7 @@ final class FSC48 extends Packet ]; public const TYPE = '2+'; + public const VERS = self::MSG_TYPE2; //|self::MSG_TYPE4; public function __get($key) { @@ -84,10 +86,10 @@ final class FSC48 extends Packet $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone $this->fftn_p->point_id ? $this->fftn_p->host_id : 0x00, // Aux Net - 1<<0, // fsc-0039.004 (copy of 0x2c) + static::VERS, // fsc-0039.004 (copy of 0x2c) ((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi Setup::PRODUCT_VERSION_MIN, // Product Version Minor - 1<<0, // Capability Word + static::VERS, // Capability Word $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone $this->fftn_p->point_id, // Orig Point diff --git a/app/Classes/FTN/Packet/FTS1.php b/app/Classes/FTN/Packet/FTS1.php index 9cb58ab..c94bf28 100644 --- a/app/Classes/FTN/Packet/FTS1.php +++ b/app/Classes/FTN/Packet/FTS1.php @@ -38,6 +38,20 @@ final class FTS1 extends Packet public const TYPE = '2'; + public function __get($key) + { + switch ($key) { + case 'product': + return Arr::get($this->header,'prodcode'); + + case 'software_ver': + return 'N/A'; + + default: + return parent::__get($key); + } + } + /** * Create our message packet header */ diff --git a/app/Console/Commands/PacketInfo.php b/app/Console/Commands/PacketInfo.php index 83cb83b..dad84fe 100644 --- a/app/Console/Commands/PacketInfo.php +++ b/app/Console/Commands/PacketInfo.php @@ -59,8 +59,8 @@ class PacketInfo extends Command $this->info(sprintf('Dated : %s (%s) [%s]',$pkt->date,$pkt->date->timestamp,$pkt->date->tz->toOffsetName())); $this->info(sprintf('Password : %s (%s)',$pkt->password ?: '-',$pkt->password ? 'SET' : 'NOT set')); $this->info(sprintf('Messages : %d',$pkt->count())); - $this->info(sprintf('Tosser : %d (%s) version %s',$pkt->software->code,$pkt->software->name,$pkt->software_ver)); - $this->info(sprintf('Capabilities: %x',$pkt->capability)); + $this->info(sprintf('Tosser : %d (%s) version %s (%x)',$pkt->software->code,$pkt->software->name,$pkt->software_ver,$pkt->product)); + $this->info(sprintf('Capabilities: %s',$pkt->capability)); $this->info(sprintf('Has Errors : %s',$pkt->errors->count() ? 'YES' : 'No')); $this->info(sprintf('Messages : %d',$pkt->count()));