6 char errbuf[PCAP_ERRBUF_SIZE];
10 typedef struct netwatch_frame {
13 unsigned short whatthefuck;
14 unsigned short ethertype;
15 unsigned short buf_offset;
16 unsigned short buf_window;
20 void out(char *buf, unsigned short start)
25 for (y = 0; y < 25; y++)
27 for (x = 0; x < 80; x++)
37 case 0: printf("30;"); break;
38 case 1: printf("34;"); break;
39 case 2: printf("32;"); break;
40 case 3: printf("36;"); break;
41 case 4: printf("31;"); break;
42 case 5: printf("35;"); break;
43 case 6: printf("33;"); break;
44 case 7: printf("37;"); break;
50 switch ((col >> 4) & 0x7)
52 case 0: printf("40"); break;
53 case 1: printf("44"); break;
54 case 2: printf("42"); break;
55 case 3: printf("46"); break;
56 case 4: printf("41"); break;
57 case 5: printf("45"); break;
58 case 6: printf("43"); break;
59 case 7: printf("47"); break;
68 void handler (u_char * user, const struct pcap_pkthdr *h, const u_char *bytes)
70 netwatch_frame * f = (netwatch_frame *) bytes;
72 int data_len = h->caplen - sizeof(netwatch_frame);
74 if (data_len < 0) return;
76 if (ntohs(f->ethertype) != 0x1337) return;
78 if (data_len > sizeof(buf)) return;
80 if (f->buf_offset + data_len > sizeof(buf))
82 int wrap_pos = sizeof(buf) - f->buf_offset;
83 memcpy(buf + f->buf_offset, f->data, wrap_pos);
84 memcpy(buf, f->data + wrap_pos, data_len - wrap_pos);
86 memcpy(buf + f->buf_offset, f->data, data_len);
89 out(buf, f->buf_window);
95 pcap = pcap_open_live(NULL, 65535, 1, 0, errbuf);
99 printf("pcap_open_live: %s\n", errbuf);
103 pcap_loop(pcap, -1, handler, NULL);