Пример #1
0
DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
{
	struct arphdr *arp = (struct arphdr*)packet;
	const char *source_hrd = NULL;
	const char *source_pro = NULL;
	const char *dest_hrd = NULL;
	const char *dest_pro = NULL;

	if (len < sizeof(struct arphdr)) {
		printf(" ARP: (Truncated)\n");
		return;
	}

	if (len >= sizeof(struct arphdr) + arp->ar_hln) 
		source_hrd = packet + sizeof(struct arphdr);
	if (len >= sizeof(struct arphdr) + arp->ar_hln + arp->ar_pln)
		source_pro = source_hrd + arp->ar_hln;
	if (len >= sizeof(struct arphdr) + arp->ar_hln * 2 + arp->ar_pln)
		dest_hrd = source_pro + arp->ar_pln;
	if (len >= sizeof(struct arphdr) + arp->ar_hln * 2 + arp->ar_pln * 2)
		dest_pro = dest_hrd + arp->ar_hln;

	switch(ntohs(arp->ar_op)) {
		case ARPOP_REQUEST:
			printf(" ARP: who-has %s", format_pro(arp, dest_pro));
			printf(" tell %s (%s)\n", format_pro(arp, source_pro),
					format_hrd(arp, source_hrd));
			break;
		case ARPOP_REPLY:
			printf(" ARP: reply %s", format_pro(arp, source_pro));
			printf(" is-at %s\n", format_hrd(arp, source_hrd));
			break;
		default:
			printf(" ARP: Unknown opcode (%i) from %s to %s\n",
					ntohs(arp->ar_op),
					format_pro(arp, source_pro),
					format_pro(arp, dest_pro));

			break;
	}
	return;
}
Пример #2
0
int FDD::read_pro()
{
   format_pro();

   for(unsigned c = 0; c < cyls; c++)
   {
      for (unsigned h = 0; h < 2; h++)
      {
         for (unsigned s = 0; s < 5; s++)
         {
            t.seek(this, c, h, LOAD_SECTORS);
            t.write_sector((c == 0 && h == 0) ? sn0[s] : sn[s], snbuf+(c*10 + h*5 + s)*1024);
         }
      }
   }
   return 1;
}