static void count(u_char *user,const struct pcap_pkthdr *packet_header,const u_char *packet)
{
	int index = (int)(*user);
	__u32 src_ip,dst_ip;
	__u16 src_port,dst_port;
	
	get_ips_ports(packet+IPHDR_OFFSET,&src_ip,&dst_ip,&src_port,&dst_port);
	
	packets_per_port[index]++;
	bytes_per_port[index] += packet_header->len;
	
#ifdef BENCH_DEBUG
	//print_packet(packet,packet_header->len);
	print_quad(src_ip,dst_ip,src_port,dst_port);
#endif	
}
Example #2
0
void godob::handle_serial(void)
{
  unsigned long t0;
  int ch;
  starpos_s mount;
  unsigned RAq;
  int Decq;
  
    if (Serial.available() > 0) {
        // read the incoming byte:
        ch = Serial.read();
        switch(ch){
	case 'e':
	  Connected = true;
	  connect_time = 0;
	  mount.az = ItoRad(ENCAz->lastpos());
	  mount.alt = ItoRad(ENCAlt->lastpos());
	  mount.GMST = AST->get_GMST(now());
	  AST->horz_to_eq(mount);
	  print_quad(RadToI(mount.RA));
	  Serial.print("0000,");
	  print_quad(RadToI(mount.dec));
	  Serial.print("0000#");
	  break;
	case 'r':
	  RAq = read_quad();
	  read_quad(); /* ignore the 16 LSBs */
	  while(Serial.read()<1); /* drop comma */
	  Decq = read_quad();
	  read_quad();
	  Serial.print("#");
	  LCD->clear();
	  LCD->print(" RA:");
	  //LCD->print(RAq);
	  show_hms(ItoRad(RAq));
	  LCD->setCursor(0, 1);
	  LCD->print("Dec:");
	  //LCD->print(Decq);
	  show_dms(ItoRad(Decq));
	  delay(2000);
	  if(!reqPending){
	    star[1] = star[0];
	  }
	  star[0].RA = ItoRad(RAq);
	  star[0].dec = ItoRad(Decq);
	  reqPending = true;
	  dstat = ds_targ;
	  break;
	default: /* display anything else on the LCD */
	  LCD->clear();
	  LCD->write(ch);
	  t0 = millis();
	  do{
	    if(Serial.available()){
	      ch = Serial.read();
	      LCD->write(ch);
	      t0 = millis();
	    }
	  }while(millis()-t0<100);
	  Serial.print("#");
	  delay(2000);
	  break;
        }
    }
}