home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / protocol / appletal / 3979 < prev    next >
Encoding:
Text File  |  1992-11-21  |  12.8 KB  |  382 lines

  1. Newsgroups: comp.protocols.appletalk
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!news.udel.edu!udel!princeton!ernie.Princeton.EDU!sproule
  3. From: sproule@ernie.Princeton.EDU (William J. Sproule)
  4. Subject: Re: SUMMARY:  Need AppleTalk Frame/Header Formats
  5. Message-ID: <1992Nov20.145841.13856@Princeton.EDU>
  6. Followup-To: comp.protocols.appletalk
  7. Originator: news@nimaster
  8. Keywords: phase2 decode
  9. Sender: news@Princeton.EDU (USENET News System)
  10. Nntp-Posting-Host: ernie.princeton.edu
  11. Organization: Princeton University
  12. References: <1992Nov17.204422.22482@eagle.lerc.nasa.gov> <1992Nov18.153244.18383@Princeton.EDU>
  13. Date: Fri, 20 Nov 1992 14:58:41 GMT
  14. Lines: 366
  15.  
  16.  
  17. In article <1992Nov18.153244.18383@Princeton.EDU>, sproule@ernie.Princeton.EDU (William J. Sproule) writes:
  18. |> I have a quick perl script that will break apart Phase2 ET so this 
  19. |> output from tcpdump:
  20.  
  21.  
  22. Sorry, the script did not post, here it is:
  23.  
  24. #!/usr/princeton/bin/perl
  25.  
  26. require "getopts.pl";
  27.  
  28. $opt_a = 0;
  29. $opt_p = 0;
  30. $opt_v = 0;
  31. $opt_f = "0";
  32. $VERBOSE = 0;
  33. $ASPFLAG = 0;
  34. $PAPFLAG = 0;
  35.  
  36. &Getopts('apvf:');
  37. OPTCASE: {
  38.    if ( (($opt_a == 1) && ($opt_p == 1)) ||
  39.         (($opt_a == 0) && ($opt_p == 0)) ) {
  40.       die "Usage: etdc -a|-p -v -f filename\n";
  41.    }
  42.    if ($opt_a == 1 ) {
  43.       $ASPFLAG = 1;
  44.       print "Decodeing ATP as ASP\n";
  45.       last OPTCASE;
  46.    }
  47.    if ($opt_p == 1 ) {
  48.       $PAPFLAG = 1;
  49.       print "Decodeing ATP as PAP\n";
  50.       last OPTCASE;
  51.    }
  52. }
  53. if ($opt_f eq "0") {
  54.    print "Reading from STDIN\n";
  55.    open(INPUT,"-")|| die "Can not open STDIN\n";
  56. }
  57. else {
  58.    open(INPUT, "$opt_f") || die "No such file: $opt_f\n";  
  59. }
  60. if ($opt_v == 1) {
  61.    $VERBOSE = 1;
  62.    print "Maximum Verbosity!\n";
  63. }  
  64.  
  65. $data="";
  66.  
  67.  
  68.  
  69. while (<INPUT>) {
  70.   chop;
  71.   s/\t//g;
  72.   if (length > 40 ) {
  73.      $pkthdr = $pktnew;
  74.      $pktnew = $_;
  75.      if ( length($data) > 0) {
  76.         $packed=pack("H*",$data);
  77.         ($header,$bhops,$msblngth,$lsblngth,$chksum,$dstnet,$srcnet,
  78.          $dstnode,$srcnode,$dstskt,$srcskt,$ddptype) = unpack("H16 B6 X B8 B8 H4 H4 H4 H2 H2 H2 H2 H2",$packed);
  79.         $bhops = "00".$bhops;
  80.         $thops = pack("B8",$bhops);
  81.         $hops = unpack("H2",$thops);
  82.         $msblngth = substr($msblngth,6,2);
  83.         $tmpl = "000000".$msblngth.$lsblngth;
  84.         $lngth = unpack("H4",pack("B16",$tmpl));  
  85.         print "\n\n",$pkthdr,"\n";
  86.         if ($VERBOSE) {
  87.            print $data,"\n";
  88.         }
  89.         CASELOOP: {
  90.            if ($header ne "aaaa03080007809b") {
  91.               print "Non-EtherTalk Packet.\n";
  92.               last CASELOOP;
  93.            }
  94.            else {
  95.               print "DDP HEADER:\n";
  96.               printf("Header: %s\tHops: %s\tLength: %s\tChkSum: %s\n",$header,$hops,$lngth,$chksum);
  97.               printf("Dest: %s.%s.%s Src: %s.%s.%s\t",$dstnet,$dstnode,$dstskt,$srcnet,$srcnode,$srcskt);
  98.               printf("DDPType: %s\n",$ddptype); 
  99.            }
  100. #
  101. # RTMP Packets
  102. #
  103.            if ($ddptype == 1) {
  104.               $rtmpoffset = 25;
  105.               $rtmplngth = hex($lngth) + 8;
  106.               ($rtmpnet,$idl,$rtmpsndr) = unpack("@21 H4 H2 H2",$packed);
  107.               printf("RTMP Header:\tNET: %s\tID Length: %s\tNode ID: %s\n",$rtmpnet,hex($idl),$rtmpsndr);
  108.               while ($rtmpoffset < $rtmplngth) {
  109.                  ($rs,$ds) = unpack("@$rtmpoffset H4 H2", $packed);
  110.                  $hopcnt = 0x1f & hex($ds);
  111.                  $rtmpoffset += 3;
  112.                  print "Range Start: ",$rs," Distance: ",$hopcnt;
  113.                  if ( (0x80 & hex($ds)) == 0x80) {   #extended network tuple
  114.                     ($re,$et) = unpack("@$rtmpoffset H4 H2 ", $packed);
  115.                     print " Range End: ",$re;
  116.                     $rtmpoffset += 3;
  117.                  }
  118.                  print "\n";
  119.               }
  120.               last CASELOOP;
  121.            }
  122. #
  123. # NBP Packets
  124. #
  125.            if ($ddptype == 2) {
  126.               $datalngth = (hex($lngth) *2) - 26 ;
  127.               print "NBP HEADER:\n";
  128.               ($nbpfunc,$tuplecnt,$nbpid) = unpack("@21 H1 @21 h1 H2",$packed);
  129.               NBPCASE:{
  130.                  if ($nbpfunc == 1 ) {
  131.                     print "FUNCTION: BrRq\t TUPLECNT: ",$tuplecnt,"\n";
  132.                     last NBPCASE;
  133.                  }
  134.                  if ($nbpfunc == 2 ) {
  135.                     print "FUNCTION: LkUp\t TUPLECNT: ",$tuplecnt,"\n";
  136.                     last NBPCASE;
  137.                  }
  138.                  if ($nbpfunc == 3 ) {
  139.                     print "FUNCTION: LkUp-Reply\t TUPLECNT: ",$tuplecnt,"\n";
  140.                     last NBPCASE;
  141.                  }
  142.                  print "Unknown NBP type: ",$nbpfunc,"\n";
  143.               }
  144.               $i=0;
  145.               $tupleoffset=28;
  146.               print "NBP DATA:\n";
  147.               ($nbpnetnum,$nbpnodeid,$nbpsktnum,$nbpenum) = unpack("@23 H4 H2 H2 H2",$packed);
  148.               printf("NetNum:%s\tNodeID:%s\tSktNum:%s\tEnumerator:%s\n",$nbpnetnum,$nbpnodeid,$nbpsktnum,$nbpenum);
  149.               while ( $i < $tuplecnt ) {
  150.                  $i++;
  151.                  $objlnth = hex(unpack("@$tupleoffset H2",$packed));
  152.                  $tupleoffset += 1;
  153.                  $nbpstr = "OBJECT: ".unpack("@$tupleoffset a$objlnth",$packed)."\t";
  154.                  $tupleoffset += $objlnth;
  155.                  $typelnth = hex(unpack("@$tupleoffset H2",$packed));
  156.                  $tupleoffset += 1;
  157.                  $nbpstr = $nbpstr."TYPE: ".unpack("@$tupleoffset a$typelnth",$packed)."\t";
  158.                  $tupleoffset += $typelnth;
  159.                  $zonelnth = hex(unpack("@$tupleoffset H2",$packed)); 
  160.                  $tupleoffset += 1;
  161.                  $nbpstr = $nbpstr."ZONE: ".unpack("@$tupleoffset a$zonelnth",$packed); 
  162.                  $tupleoffset += $zonelnth + 5;
  163.                  print $nbpstr,"\n";
  164.               }
  165.               last CASELOOP;
  166.            }
  167. #
  168. # ATP Packets - could be PAP or ASP
  169. #
  170.            if ($ddptype == 3) {           
  171.               $datalngth = (hex($lngth) *2) - 42 ;  
  172.               ($cntrlinfo,$seqnum,$tid) = unpack("@21 H2 H2 H4",$packed);
  173.               $cntrlstr = "";
  174.               $ctlpkd = hex($cntrlinfo);
  175.               ATPCNTRCASE: {
  176.                  if (($ctlpkd & 0xc0) == 0xc0) {
  177.                     $cntrlstr = "TREL";
  178.                     last ATPCNTRCASE;
  179.                  }
  180.                  if (($ctlpkd & 0x80) == 0x80) {
  181.                     $cntrlstr = "TRESP";
  182.                     last ATPCNTRCASE;
  183.                  }        
  184.                  if (($ctlpkd & 0x40) == 0x40) { 
  185.                     $cntrlstr = "TREQ";
  186.                     last ATPCNTRCASE;
  187.                  }
  188.               }
  189.               if (($ctlpkd & 0x20) == 0x20) {
  190.                  $cntrlstr = $cntrlstr." XO" ;
  191.               }
  192.               if (($ctlpkd & 0x10) == 0x10) {
  193.                  $cntrlstr = $cntrlstr." EOM" ;
  194.               }        
  195.               if (($ctlpkd & 0x08) == 0x08) { 
  196.                  $cntrlstr = $cntrlstr." STS" ;
  197.               }
  198.               printf("ATP HEADER:\tCONTRLINFO: %s\tSEQNUM: %s\tTID: %s\n",$cntrlstr,$seqnum,$tid);
  199.               if ($ASPFLAG){
  200.                  print "ASP HEADER: \t",unpack("@25 H8",$packed),"\n";
  201.                  print "ASP DATA:\n";
  202.                  print "ASCII: ",unpack("@29 a$datalngth",$packed),"\n";
  203.                  print "HEX: ",unpack("@29 H$datalngth",$packed),"\n";
  204.               }
  205.               if ($PAPFLAG) {
  206.                  print "PAP HEADER:\t";
  207.                  ($connid,$cmd,$usrbytes,$data) = unpack("@25 H2 H2 H4 a$datalngth ",$packed);
  208.                  print "ConnID: ",$connid,"\tCMD: ";
  209.                  PAPCASE: {
  210.                     if ($cmd == 1) {
  211.                        ($aparsn,$fq,$wt) = unpack("@29 H2 H2 H4",$packed);
  212.                        printf("OpenConn\tATPRSSN: %s\tFlowQuantum: %s\tWaitTime: %s\n",$aparsn,$fq,$wt);
  213.                        last PAPCASE;
  214.                     }
  215.                     if ($cmd == 2) {
  216.                        ($aparsn,$fq,$rslt) = unpack("@29 H2 H2 H4",$packed);
  217.                        printf("OpenConnReply\tATPRSSN: %s\tFlowQuantum: %s\tResult: %s\n",$aparsn,$fq,$rslt);
  218.                        $datalngth -= 16;
  219.                        $data = unpack("@33 a$datalngth",$packed);
  220.                        print "STATUS: ",$data,"\n";
  221.                        last PAPCASE;
  222.                     }
  223.                     if ($cmd == 3) {
  224.                        print "SendData\t PAP Seq Num: ",$usrbytes,"\n";
  225.                        last PAPCASE;
  226.                     }
  227.                     if ($cmd == 4) {
  228.                        print "Data\t EOF: ",$usrbytes,"\n";
  229.                        print "DATA: ",unpack("@29 a$datalngth",$packed);
  230.                        last PAPCASE;
  231.                     }
  232.                     if ($cmd == 5) {
  233.                        print "Tickle\n";
  234.                        last PAPCASE;
  235.                     }
  236.                     if ($cmd == 6) {
  237.                        print "CloseConn\n";
  238.                        last PAPCASE;
  239.                     }
  240.                     if ($cmd == 7) {
  241.                        print "CloseConnReply\n";
  242.                        last PAPCASE;
  243.                     }
  244.                     if ($cmd == 8) {
  245.                        print "SendStatus\n";
  246.                        last PAPCASE;
  247.                     }
  248.                     if ($cmd == 9) {
  249.                        print "Status\n";
  250.                        $datalngth -= 8;
  251.                        $data = unpack("@33 a$datalngth",$packed);
  252.                        print "STATUS: ",$data,"\n";
  253.                        last PAPCASE;
  254.                     }
  255.                  }
  256.               }
  257.               last CASELOOP;
  258.            }
  259. #
  260. # AEP
  261. #
  262.            if ($ddptype == 4) {
  263.               $aepcmd = hex(unpack("@21 H2",$packed));
  264.               AEPCASE: {
  265.                  if ($aepcmd == 1 ) {
  266.                     print "AEP Request\n";
  267.                     last AEPCASE;
  268.                  }
  269.                  if ($aepcmd == 2 ) {
  270.                     print "AEP Reply\n";
  271.                     last AEPCASE;
  272.                  }
  273.               }
  274.               print "AEP DATA:\n" , unpack("@22 H*",$packed),"\n";
  275.               last CASELOOP;
  276.            }
  277. #
  278. # RTMP Request
  279. #
  280.            if ($ddptype == 5) {
  281.               print "RDR HEADER:\n";
  282.               $rdrcmd = hex(unpack("@21 H2",$packed));
  283.               RDRCASE: {
  284.                  if ($rdrcmd == 1 ) {
  285.                     print "RDR Request\n";
  286.                     last RDRCASE;
  287.                  }
  288.                  if ($rdrcmd == 2 ) {
  289.                     print "RDR Route Data Request - Normal Split-Horizon\n";
  290.                     last RDRCASE;
  291.                  }
  292.                  if ($rdrcmd == 3 ) {
  293.                     print "RDR Route Data Request - Without Split-Horizon\n";
  294.                     last RDRCASE;
  295.                  }
  296.                  print "Unknown RDR Command\n";
  297.               }
  298.               print "RDR Data:\n" , unpack("@22 H*",$packed),"\n";
  299.               last CASELOOP;
  300.            }
  301. #
  302. # ZIP
  303. #
  304.            if ($ddptype == 6) {
  305.               print "ZIP HEADER:\n";
  306.               $zipcmd = hex(unpack("@21 H2",$packed));
  307.               ZIPCASE: {
  308.                  if ($zipcmd = 1) {
  309.                     print "ZIP Query:\n";
  310.                     last ZIPCASE;
  311.                  }
  312.                  if ($zipcmd = 2) {
  313.                     print "ZIP Reply:\n";
  314.                     last ZIPCASE;
  315.                  }
  316.                  if ($zipcmd = 3) {
  317.                     print "ZIP Takedown:\n";
  318.                     last ZIPCASE;
  319.                  }
  320.                  if ($zipcmd = 4) {
  321.                     print "ZIP Bringup:\n";
  322.                     last ZIPCASE;
  323.                  }
  324.                  if ($zipcmd = 5) {
  325.                     print "ZIP GetNetInfo:\n";
  326.                     last ZIPCASE;
  327.                  }
  328.                  if ($zipcmd = 6) {
  329.                     print "ZIP NetInfoReply:\n";
  330.                     last ZIPCASE;
  331.                  }
  332.                  if ($zipcmd = 7) {
  333.                     print "ZIP GetMyZone:\n";
  334.                     last ZIPCASE;
  335.                  }
  336.                  if ($zipcmd = 8) {
  337.                     print "ZIP GetZoneList:\n";
  338.                     last ZIPCASE;
  339.                  }
  340.               }
  341.               print "ZIP DATA:\n" , unpack("@22 H*",$packed),"\n";
  342.               last CASELOOP;
  343.            }
  344. #
  345. # ADSP
  346. #
  347.            if ($ddptype == 7) {
  348.               print "ADSP DATA:\n" , unpack("@21 H*",$packed),"\n";
  349.               last CASELOOP;
  350.            }
  351. #
  352. # AURP
  353. #
  354.            if ($ddptype == 8) {
  355.               print "AURP DATA:\n" , unpack("@21 H*",$packed),"\n";
  356.               last CASELOOP;
  357.            }
  358. #
  359. # MacIP
  360. #
  361.            if (hex($ddptype) == 0x16) {
  362.               print "MacIP DATA:\n" , unpack("@21 a*",$packed),"\n";
  363.               last CASELOOP;
  364.            }
  365.            print "Unknown AppleTalk protocol\n";
  366.         }
  367.      }
  368.      $data="";
  369.   }
  370.   else {
  371.      s/ //g;
  372.      s/\n//g;
  373.      $data = $data . $_;
  374.   }
  375. }
  376.  
  377. -- 
  378. William J. Sproule - Networking      Princeton University
  379. UUCP:         ...princeton!sproule    87 Prospect Ave.
  380. INTERNET:    sproule@Princeton.EDU    Princeton, NJ   08544
  381. BITNET:        SPROULE@PUCC        VOICE: 609-258-6089  FAX: 609-258-3943
  382.