p2sh 0.4.3

The p2sh Programming language interpreter
#!/usr/bin/env p2sh

if len(argv) < 2 {
  println("Usage: {} <pcap file>", argv[0]);
  exit(1);
}

let f = pcap_open(argv[1]);
if is_error(f) {
    puts(f);
    exit(1);
}

let pcap = null;

while pcap = pcap_read_next(f) {
   let sec = pcap.sec;
   let usec = pcap.usec;
   let eth = pcap.eth;

   let ipv4 = match eth.type {
     0x0800 => {
       eth.ipv4;
     }
     0x8100 => {
       match eth.vlan.type {
         0x8100 => {
           match eth.vlan.vlan.type {
             0x0800 => {
               eth.vlan.vlan.ipv4;
             }
           }
         }
         0x0800 => {
           eth.vlan.ipv4;
         }
       }
     }
   };
   // println("{}", pcap);
   println("[{}.{}] {}", sec, usec, eth);
}