/[RFID]/3m-810.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /3m-810.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 65 by dpavlin, Thu Feb 11 13:23:26 2010 UTC revision 68 by dpavlin, Thu Feb 11 15:10:39 2010 UTC
# Line 91  sub http_server { Line 91  sub http_server {
91                                  my $status = 501; # Not implementd                                  my $status = 501; # Not implementd
92    
93                                  foreach my $p ( keys %$param ) {                                  foreach my $p ( keys %$param ) {
94                                          next unless $p =~ m/^tag_(\S+)/;                                          next unless $p =~ m/^(E[0-9A-F]{15})$/;
95                                          my $tag = $1;                                          my $tag = $1;
96                                          my $content = "\x04\x11\x00\x01" . $param->{$p};                                          my $content = "\x04\x11\x00\x01" . $param->{$p};
97                                          $content = "\x00" if $param->{$p} eq 'blank';                                          $content = "\x00" if $param->{$p} eq 'blank';
# Line 99  sub http_server { Line 99  sub http_server {
99    
100                                          warn "PROGRAM $tag $content\n";                                          warn "PROGRAM $tag $content\n";
101                                          write_tag( $tag, $content );                                          write_tag( $tag, $content );
102                                            secure_tag_with( $tag, $param->{$p} =~ /^130/ ? 'DA' : 'D7' );
103                                    }
104    
105                                    print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n";
106    
107                            } elsif ( $method =~ m{/secure} ) {
108    
109                                    my $status = 501; # Not implementd
110    
111                                    foreach my $p ( keys %$param ) {
112                                            next unless $p =~ m/^(E[0-9A-F]{15})$/;
113                                            my $tag = $1;
114                                            my $data = $param->{$p};
115                                            $status = 302;
116    
117                                            warn "SECURE $tag $data\n";
118                                            secure_tag_with( $tag, $data );
119                                  }                                  }
120    
121                                  print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n";                                  print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n";
# Line 395  sub decode_tag { Line 412  sub decode_tag {
412          return $hash;          return $hash;
413  }  }
414    
415    sub forget_tag {
416            my $tag = shift;
417            delete $tags_data->{$tag};
418            delete $visible_tags->{$tag};
419    }
420    
421  sub read_tag {  sub read_tag {
422          my ( $tag ) = @_;          my ( $tag ) = @_;
423    
# Line 483  sub write_tag { Line 506  sub write_tag {
506          rename $path, $to;          rename $path, $to;
507          print ">> $to\n";          print ">> $to\n";
508    
509          # force re-read of tag          forget_tag $tag;
510          delete $tags_data->{$tag};  }
511          delete $visible_tags->{$tag};  
512    sub secure_tag_with {
513            my ( $tag, $data ) = @_;
514    
515            cmd(
516                    "d6 00  0c  09  $tag $data BEEF", "secure $tag -> $data",
517                    "d6 00  0c  09 00  $tag    BEEF", sub { assert() },
518            );
519    
520            forget_tag $tag;
521  }  }
522    
523  sub secure_tag {  sub secure_tag {
# Line 494  sub secure_tag { Line 526  sub secure_tag {
526          my $path = "$secure_path/$tag";          my $path = "$secure_path/$tag";
527          my $data = substr(read_file( $path ),0,2);          my $data = substr(read_file( $path ),0,2);
528    
529          cmd(          secure_tag_with( $tag, $data );
                 "d6 00  0c  09  $tag $data BEEF", "secure $tag -> $data",  
                 "d6 00  0c  09 00  $tag    BEEF", sub { assert() },  
         );  
530    
531          my $to = $path;          my $to = $path;
532          $to .= '.' . time();          $to .= '.' . time();

Legend:
Removed from v.65  
changed lines
  Added in v.68

  ViewVC Help
Powered by ViewVC 1.1.26