- return 0 unless $magic == 0xadbccbda && $schema >= 0 && $schema <= 3 && $type >= 0 && $type <= 32; # 32 to allow for expansion
-
- no strict 'refs';
- my $h = "decode$type";
- if ($self->can($h)) {
- my $a = unpack "H*", $data;
- $a =~ s/f{8}/00000000/g;
- $data = pack 'H*', $a;
- dbgdump('udp', "UDP process lth: $lth", $data);
- $self->$h($type, substr($data, 12)) if $self->{"h_$type"};
- } else {
- dbg("decode $type not implemented");
- }
-
-
- return 1;
-
-}
-
-sub decode0
-{
- my ($self, $type, $data) = @_;
-
- my %r;
- $r{type} = $type;
-
- ($r{id}, $r{schema}, $r{version}, $r{revision}) = eval {unpack 'l>/a N l>/a l>/a', $data};
- if ($@) {
- dbg($@);
- } else {
- my $j = $json->encode(\%r);
- dbg($j);
- }
-
-}
-
-sub decode1
-{
- my ($self, $type, $data) = @_;
-
- my %r;
- $r{type} = $type;
-
- (
- $r{id}, $r{qrg}, $r{mode}, $r{dxcall}, $r{report}, $r{txmode},
- $r{txenabled}, $r{txing}, $r{decoding}, $r{rxdf}, $r{txdf},
- $r{decall}, $r{degrid}, $r{dxgrid}, $r{txwatch}, $r{som},
- $r{fast}, $r{qrgtol}, $r{trperiod}, $r{confname}
-
- ) = eval {unpack 'l>/a Q> l>/a l>/a l>/a l>/a C C C l> l> l>/a l>/a l>/a C l>/a c l> l> l>/a', $data};
- if ($@) {
- dbg($@);
- } else {
- my $j = $json->encode(\%r);
- dbg($j);
- }
-}
-
-sub decode2
-{
- my ($self, $type, $data) = @_;
-
- my %r;
- $r{type} = $type;