updated on Wed Jan 11 00:07:16 UTC 2012
[aur-mirror.git] / iptraf-ipv6 / iptraf-3.0.1-ipv6.patch
blob40e839a6b6fba62dafa5dd11ed19d6f5aae43e94
1 --- ./iptraf-3.0.0.orig/src/attrs.h 2005-09-13 08:42:54.000000000 +0200
2 +++ ./iptraf-3.0.0/src/attrs.h 2006-01-08 05:11:43.000000000 +0100
3 @@ -29,3 +29,5 @@
4 extern int GREATTR;
5 extern int UNKNIPATTR;
6 extern int UNKNATTR;
7 +extern int IPV6ATTR;
8 +extern int ICMPV6ATTR;
9 --- ./iptraf-3.0.0.orig/src/deskman.c 2005-09-13 08:42:54.000000000 +0200
10 +++ ./iptraf-3.0.0/src/deskman.c 2006-01-08 05:32:03.000000000 +0100
11 @@ -56,7 +56,8 @@
12 int ARPATTR;
13 int UNKNIPATTR;
14 int UNKNATTR;
16 +int IPV6ATTR;
17 +int ICMPV6ATTR;
19 /* draw the basic desktop common to my screen-oriented programs */
21 @@ -89,7 +90,8 @@
22 PANEL *panel;
23 int ch;
25 - win = newwin(15, 50, (LINES - 15) / 2, (COLS - 50) / 2);
26 + win = newwin(18, 62, (LINES - 17) / 2, (COLS - 62) / 2);
28 panel = new_panel(win);
30 tx_stdwinset(win);
31 @@ -108,9 +110,12 @@
32 mvwprintw(win, 10, 2,
33 "Public License Version 2 or any later version.");
34 mvwprintw(win, 11, 2, "See the included LICENSE file for details.");
35 + mvwprintw(win, 13, 2, "IPv6 support by Markus Ullmann <mail@markus-ullmann.de>");
36 + mvwprintw(win, 14, 2, "inspired by 2.7.0 diff by Guy Martin <gmsoft@tuxicoman.be>");
38 wattrset(win, HIGHATTR);
39 - mvwprintw(win, 13, 2, ANYKEY_MSG);
41 + mvwprintw(win, 16, 2, ANYKEY_MSG);
43 update_panels();
44 doupdate();
45 @@ -252,6 +257,8 @@
46 ARPATTR = COLOR_PAIR(5) | A_BOLD;
47 GREATTR = COLOR_PAIR(1);
48 UNKNIPATTR = COLOR_PAIR(19) | A_BOLD;
49 + ICMPV6ATTR = COLOR_PAIR(19) | A_BOLD;
50 + IPV6ATTR = COLOR_PAIR(19);
51 UNKNATTR = COLOR_PAIR(4) | A_BOLD;
52 } else {
53 STDATTR = A_REVERSE;
54 @@ -281,6 +288,7 @@
55 ARPATTR = A_BOLD;
56 GREATTR = A_BOLD;
57 UNKNIPATTR = A_BOLD;
58 + ICMPV6ATTR = A_REVERSE;
59 UNKNATTR = A_BOLD;
62 --- ./iptraf-3.0.0.orig/src/ifstats.c 2005-09-13 08:42:54.000000000 +0200
63 +++ ./iptraf-3.0.0/src/ifstats.c 2006-01-08 05:29:30.000000000 +0100
64 @@ -1,4 +1,3 @@
66 /***
68 ifstats.c - the interface statistics module
69 @@ -34,6 +33,7 @@
70 #include <linux/if_packet.h>
71 #include <net/if.h>
72 #include <netinet/ip.h>
73 +#include <netinet/ip6.h>
74 #include <netinet/tcp.h>
75 #include <netinet/udp.h>
76 #include <linux/if_ether.h>
77 @@ -252,7 +252,7 @@
79 wattrset(table->statwin, HIGHATTR);
80 do {
81 - wmove(table->statwin, ptmp->index - idx, 52 * COLS / 80);
82 + wmove(table->statwin, ptmp->index - idx, 60 * COLS / 80);
83 if (unit == KBITS) {
84 ptmp->rate =
85 ((float) (ptmp->spanbr * 8 / 1000)) /
86 @@ -286,13 +286,15 @@
87 wmove(win, target_row, 1);
88 wprintw(win, "%s", ptmp->ifname);
89 wattrset(win, HIGHATTR);
90 - wmove(win, target_row, 12 * COLS / 80);
91 + wmove(win, target_row, 9 * COLS / 80);
92 printlargenum(ptmp->total, win);
93 - wmove(win, target_row, 22 * COLS / 80);
94 + wmove(win, target_row, 19 * COLS / 80);
95 printlargenum(ptmp->iptotal, win);
96 - wmove(win, target_row, 32 * COLS / 80);
97 + wmove(win, target_row, 29 * COLS / 80);
98 + printlargenum(ptmp->ip6total, win);
99 + wmove(win, target_row, 39 * COLS / 80);
100 printlargenum(ptmp->noniptotal, win);
101 - wmove(win, target_row, 42 * COLS / 80);
102 + wmove(win, target_row, 29 * COLS / 80);
103 wprintw(win, "%8lu", ptmp->badtotal);
106 @@ -320,15 +322,19 @@
108 wmove(win, 0, 1);
109 wprintw(win, " Iface ");
110 - wmove(win, 0, 16 * COLS / 80);
111 + wmove(win, 0, 12 * COLS / 80);
112 wprintw(win, " Total ");
113 - wmove(win, 0, 29 * COLS / 80);
114 + wmove(win, 0, 22 * COLS / 80);
115 + wprintw(win, " IPv4 ");
116 + wmove(win, 0, 32 * COLS / 80);
117 + wprintw(win, " IPv6 ");
118 + wmove(win, 0, 42 * COLS / 80);
119 wprintw(win, " IP ");
120 wmove(win, 0, 36 * COLS / 80);
121 wprintw(win, " NonIP ");
122 - wmove(win, 0, 45 * COLS / 80);
123 + wmove(win, 0, 51 * COLS / 80);
124 wprintw(win, " BadIP ");
125 - wmove(win, 0, 55 * COLS / 80);
126 + wmove(win, 0, 65 * COLS / 80);
127 wprintw(win, " Activity ");
130 @@ -422,6 +428,8 @@
131 char *packet;
132 int pkt_result = 0;
134 + unsigned int iphlen;
136 struct sockaddr_ll fromaddr;
137 unsigned short linktype;
139 @@ -590,6 +598,18 @@
140 && pkt_result != MORE_FRAGMENTS)
141 continue;
143 + if ((options->v6inv4asv6) && (fromaddr.sll_protocol == ETH_P_IP)
144 + && ((struct iphdr *) packet)->protocol == IPPROTO_IPV6 ) {
145 + iphlen = ((struct iphdr *) packet)->ihl * 4;
146 + fromaddr.sll_protocol = htons(ETH_P_IPV6);
147 + memmove(buf, buf + iphlen, MAX_PACKET_SIZE - iphlen);
148 + // Reprocess the IPv6 packet
149 + pkt_result = processpacket(buf, &packet, &br, NULL, NULL, NULL,
150 + &fromaddr, &linktype, ofilter, MATCH_OPPOSITE_USECONFIG, ifname, NULL);
151 + if (pkt_result != PACKET_OK
152 + && pkt_result != MORE_FRAGMENTS)
153 + continue;
155 positionptr(&table, &ptmp, ifname);
157 ptmp->total++;
158 @@ -604,6 +624,8 @@
159 (ptmp->badtotal)++;
160 continue;
162 + } else if (fromaddr.sll_protocol == ETH_P_IPV6) {
163 + ptmp->ip6total++;
164 } else {
165 (ptmp->noniptotal)++;
167 @@ -654,19 +676,20 @@
168 "Packets Bytes Packets Bytes Packets Bytes");
169 wattrset(win, STDATTR);
170 mvwprintw(win, 4, 2, "Total:");
171 - mvwprintw(win, 5, 2, "IP:");
172 - mvwprintw(win, 6, 2, "TCP:");
173 - mvwprintw(win, 7, 2, "UDP:");
174 - mvwprintw(win, 8, 2, "ICMP:");
175 - mvwprintw(win, 9, 2, "Other IP:");
176 - mvwprintw(win, 10, 2, "Non-IP:");
177 - mvwprintw(win, 13, 2, "Total rates:");
178 - mvwprintw(win, 16, 2, "Incoming rates:");
179 - mvwprintw(win, 19, 2, "Outgoing rates:");
181 - mvwprintw(win, 13, 45, "Broadcast packets:");
182 - mvwprintw(win, 14, 45, "Broadcast bytes:");
183 - mvwprintw(win, 18, 45, "IP checksum errors:");
184 + mvwprintw(win, 5, 2, "IPv4:");
185 + mvwprintw(win, 6, 2, "IPv6:");
186 + mvwprintw(win, 7, 2, "TCP:");
187 + mvwprintw(win, 8, 2, "UDP:");
188 + mvwprintw(win, 9, 2, "ICMP:");
189 + mvwprintw(win, 10, 2, "Other IP:");
190 + mvwprintw(win, 11, 2, "Non-IP:");
191 + mvwprintw(win, 14, 2, "Total rates:");
192 + mvwprintw(win, 17, 2, "Incoming rates:");
193 + mvwprintw(win, 20, 2, "Outgoing rates:");
195 + mvwprintw(win, 14, 45, "Broadcast packets:");
196 + mvwprintw(win, 15, 45, "Broadcast bytes:");
197 + mvwprintw(win, 19, 45, "IP checksum errors:");
199 update_panels();
200 doupdate();
201 @@ -707,38 +730,41 @@
202 totals->iptotal_in, totals->ipbtotal_in,
203 totals->iptotal_out, totals->ipbtotal_out);
205 - printstatrow(win, 6, totals->tcptotal, totals->tcpbtotal,
206 + printstatrow(win, 6, totals->ip6total, totals->ip6btotal,
207 + totals->ip6total_in, totals->ip6btotal_in,
208 + totals->ip6total_out, totals->ip6btotal_out);
210 + printstatrow(win, 7, totals->tcptotal, totals->tcpbtotal,
211 totals->tcptotal_in, totals->tcpbtotal_in,
212 - totals->tcptotal_out, totals->tcpbtotal_out);
213 + totals->tcptotal_out, totals->tcpbtotal_out);
215 - printstatrow(win, 7, totals->udptotal, totals->udpbtotal,
216 + printstatrow(win, 8, totals->udptotal, totals->udpbtotal,
217 totals->udptotal_in, totals->udpbtotal_in,
218 totals->udptotal_out, totals->udpbtotal_out);
220 - printstatrow(win, 8, totals->icmptotal, totals->icmpbtotal,
221 + printstatrow(win, 9, totals->icmptotal, totals->icmpbtotal,
222 totals->icmptotal_in, totals->icmpbtotal_in,
223 totals->icmptotal_out, totals->icmpbtotal_out);
225 - printstatrow(win, 9, totals->othtotal, totals->othbtotal,
226 + printstatrow(win, 10, totals->othtotal, totals->othbtotal,
227 totals->othtotal_in, totals->othbtotal_in,
228 totals->othtotal_out, totals->othbtotal_out);
230 /* Print non-IP totals */
232 - printstatrow(win, 10, totals->noniptotal, totals->nonipbtotal,
233 + printstatrow(win, 11, totals->noniptotal, totals->nonipbtotal,
234 totals->noniptotal_in, totals->nonipbtotal_in,
235 totals->noniptotal_out, totals->nonipbtotal_out);
237 /* Broadcast totals */
239 - wmove(win, 13, 67);
240 - printlargenum(totals->bcast, win);
241 wmove(win, 14, 67);
242 + printlargenum(totals->bcast, win);
243 + wmove(win, 15, 67);
244 printlargenum(totals->bcastbytes, win);
246 /* Bad packet count */
248 - mvwprintw(win, 18, 68, "%8lu", totals->badtotal);
249 + mvwprintw(win, 19, 68, "%8lu", totals->badtotal);
253 @@ -757,6 +783,7 @@
254 char buf[MAX_PACKET_SIZE];
255 char *packet;
256 struct iphdr *ipacket = NULL;
257 + struct ip6_hdr *ip6packet = NULL;
258 char *tpacket;
259 unsigned int iphlen;
261 @@ -962,15 +989,15 @@
262 starttime = now;
264 wattrset(statwin, HIGHATTR);
265 - mvwprintw(statwin, 13, 19, "%8.1f %s/sec", activity,
266 + mvwprintw(statwin, 14, 19, "%8.1f %s/sec", activity,
267 unitstring);
268 - mvwprintw(statwin, 14, 19, "%8.1f packets/sec", pps);
269 - mvwprintw(statwin, 16, 19, "%8.1f %s/sec", activity_in,
270 + mvwprintw(statwin, 15, 19, "%8.1f packets/sec", pps);
271 + mvwprintw(statwin, 17, 19, "%8.1f %s/sec", activity_in,
272 unitstring);
273 - mvwprintw(statwin, 17, 19, "%8.1f packets/sec", pps_in);
274 - mvwprintw(statwin, 19, 19, "%8.1f %s/sec", activity_out,
275 + mvwprintw(statwin, 18, 19, "%8.1f packets/sec", pps_in);
276 + mvwprintw(statwin, 20, 19, "%8.1f %s/sec", activity_out,
277 unitstring);
278 - mvwprintw(statwin, 20, 19, "%8.1f packets/sec", pps_out);
279 + mvwprintw(statwin, 21, 19, "%8.1f packets/sec", pps_out);
281 if (activity > peakactivity)
282 peakactivity = activity;
283 @@ -1077,6 +1104,18 @@
284 if (pkt_result != PACKET_OK && pkt_result != MORE_FRAGMENTS)
285 continue;
287 + if ((options->v6inv4asv6) && (fromaddr.sll_protocol == ETH_P_IP)
288 + && ((struct iphdr *) packet)->protocol == IPPROTO_IPV6 ) {
289 + iphlen = ((struct iphdr *) packet)->ihl * 4;
290 + fromaddr.sll_protocol = htons(ETH_P_IPV6);
291 + memmove(buf, buf + iphlen, MAX_PACKET_SIZE - iphlen);
292 + // Reprocess the IPv6 packet
293 + pkt_result = processpacket(buf, &packet, &br, NULL, NULL, NULL,
294 + &fromaddr, &linktype, ofilter, MATCH_OPPOSITE_USECONFIG, ifname, NULL);
295 + if (pkt_result != PACKET_OK && pkt_result != MORE_FRAGMENTS)
296 + continue;
299 totals.total++;
300 totals.bytestotal += framelen;
302 @@ -1185,8 +1224,73 @@
304 break;
306 + } else if (fromaddr.sll_protocol == ETH_P_IPV6) {
308 + ip6packet = (struct ip6_hdr *) packet;
309 + iplen = ntohs(ip6packet->ip6_plen);
311 + totals.ip6total++;
312 + totals.ip6btotal += iplen;
314 + if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
315 + totals.ip6total_out++;
316 + totals.ip6btotal_out += iplen;
317 + } else {
318 + totals.ip6total_in++;
319 + totals.ip6btotal_in += iplen;
322 + switch (ip6packet->ip6_nxt) {
323 + case IPPROTO_TCP:
324 + totals.tcptotal++;
325 + totals.tcpbtotal += iplen;
327 + if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
328 + totals.tcptotal_out++;
329 + totals.tcpbtotal_out += iplen;
330 + } else {
331 + totals.tcptotal_in++;
332 + totals.tcpbtotal_in += iplen;
334 + break;
335 + case IPPROTO_UDP:
336 + totals.udptotal++;
337 + totals.udpbtotal += iplen;
339 + if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
340 + totals.udptotal_out++;
341 + totals.udpbtotal_out += iplen;
342 + } else {
343 + totals.udptotal_in++;
344 + totals.udpbtotal_in += iplen;
346 + break;
347 + case IPPROTO_ICMPV6:
348 + totals.icmptotal++;
349 + totals.icmpbtotal += iplen;
350 + if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
351 + totals.icmptotal_out++;
352 + totals.icmpbtotal_out += iplen;
353 + } else {
354 + totals.icmptotal_in++;
355 + totals.icmpbtotal_in += iplen;
357 + break;
358 + default:
359 + totals.othtotal++;
360 + totals.othbtotal += iplen;
362 + if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
363 + totals.othtotal_out++;
364 + totals.othbtotal_out += iplen;
365 + } else {
366 + totals.othtotal_in++;
367 + totals.othbtotal_in += iplen;
369 + break;
371 } else {
372 - totals.noniptotal++;
373 + totals.noniptotal++;
374 totals.nonipbtotal += br;
376 if (fromaddr.sll_pkttype == PACKET_OUTGOING) {
377 --- ./iptraf-3.0.0.orig/src/ifstats.h 2005-09-13 08:42:54.000000000 +0200
378 +++ ./iptraf-3.0.0/src/ifstats.h 2006-01-08 05:17:07.000000000 +0100
379 @@ -9,6 +9,7 @@
380 char ifname[8];
381 unsigned int encap;
382 unsigned long long iptotal;
383 + unsigned long long ip6total;
384 unsigned long badtotal;
385 unsigned long long noniptotal;
386 unsigned long long total;
387 @@ -49,6 +50,13 @@
388 unsigned long long ipbtotal_in;
389 unsigned long long ipbtotal_out;
391 + unsigned long long ip6total;
392 + unsigned long long ip6btotal;
393 + unsigned long long ip6total_in;
394 + unsigned long long ip6total_out;
395 + unsigned long long ip6btotal_in;
396 + unsigned long long ip6btotal_out;
398 unsigned long long noniptotal;
399 unsigned long long nonipbtotal;
400 unsigned long long noniptotal_in;
401 --- ./iptraf-3.0.0.orig/src/itrafmon.c 2005-09-13 08:42:54.000000000 +0200
402 +++ ./iptraf-3.0.0/src/itrafmon.c 2006-01-08 05:20:49.000000000 +0100
403 @@ -23,6 +23,8 @@
404 #include <ctype.h>
405 #include <winops.h>
406 #include <labels.h>
407 +#include <netinet/ip6.h>
408 +#include <netinet/icmp6.h>
409 #include "options.h"
410 #include "tcptable.h"
411 #include "othptab.h"
412 @@ -578,6 +580,9 @@
413 char tpacket[MAX_PACKET_SIZE]; /* raw packet data */
414 char *packet = NULL; /* network packet ptr */
415 struct iphdr *ippacket;
416 + struct ip6_hdr *ip6packet;
417 + unsigned int protocol;
418 + unsigned int frag_off;
419 struct tcphdr *transpacket; /* IP-encapsulated packet */
420 unsigned int sport = 0, dport = 0; /* TCP/UDP port values */
421 char sp_buf[10];
422 @@ -1046,9 +1051,9 @@
423 if (pkt_result != PACKET_OK)
424 continue;
426 - if (fromaddr.sll_protocol != ETH_P_IP) {
427 + if ((fromaddr.sll_protocol != ETH_P_IP) && (fromaddr.sll_protocol != ETH_P_IPV6)) {
428 othpent = add_othp_entry(&othptbl, &table,
429 - 0, 0, NOT_IP,
430 + 0, 0, NULL, NULL, NOT_IP,
431 fromaddr.sll_protocol,
432 linktype, (char *) tpacket,
433 (char *) packet, br, ifname, 0, 0,
434 @@ -1056,23 +1061,52 @@
435 options->servnames, 0, &nomem);
436 continue;
437 } else {
438 + if ((options->v6inv4asv6) && (fromaddr.sll_protocol == ETH_P_IP)
439 + && ((struct iphdr *) packet)->protocol == IPPROTO_IPV6 ) {
440 + iphlen = ((struct iphdr *) packet)->ihl * 4;
441 + fromaddr.sll_protocol = htons(ETH_P_IPV6);
442 + memmove(tpacket, tpacket + iphlen, MAX_PACKET_SIZE - iphlen);
443 + // Reprocess the ipv6 packet
444 + pkt_result = processpacket((char *) tpacket, &packet, &readlen,
445 + &br, &sport, &dport, &fromaddr,
446 + &linktype, ofilter, MATCH_OPPOSITE_ALWAYS, ifname, ifptr);
447 + if (pkt_result != PACKET_OK)
448 + continue;
450 + if (fromaddr.sll_protocol == ETH_P_IP) {
451 ippacket = (struct iphdr *) packet;
452 iphlen = ippacket->ihl * 4;
453 + ip6packet = NULL;
454 + protocol = ippacket->protocol;
455 + frag_off = ippacket->frag_off;
456 + } else {
457 + ip6packet = (struct ip6_hdr *) packet;
458 + iphlen = 40;
459 + ippacket = NULL;
460 + protocol = ip6packet->ip6_nxt;
461 + frag_off = 0;
463 transpacket = (struct tcphdr *) (packet + iphlen);
465 - if (ippacket->protocol == IPPROTO_TCP) {
466 + if (protocol == IPPROTO_TCP) {
468 + if (ippacket != NULL)
469 tcpentry =
470 in_table(&table, ippacket->saddr, ippacket->daddr,
471 - ntohs(sport), ntohs(dport), ifname,
472 - logging, logfile, &nomem, options);
473 + NULL , NULL,
474 + ntohs(sport), ntohs(dport), ifname,
475 + logging, logfile, &nomem, options);
476 + else
477 + tcpentry = in_table(&table, 0, 0, (uint8_t*)(&ip6packet->ip6_src.s6_addr), (uint8_t*)(&ip6packet->ip6_dst.s6_addr),
478 + ntohs(sport), ntohs(dport), ifname,
479 + logging, logfile, &nomem, options);
482 * Add a new entry if it doesn't exist, and,
483 * to reduce the chances of stales, not a FIN.
486 - if ((ntohs(ippacket->frag_off) & 0x3fff) == 0) { /* first frag only */
487 + if ((ntohs(frag_off) & 0x3fff) == 0) { /* first frag only */
488 totalhlen = iphlen + transpacket->doff * 4;
490 if ((tcpentry == NULL) && (!(transpacket->fin))) {
491 @@ -1084,17 +1118,26 @@
493 if (!nomem) {
494 wasempty = (table.head == NULL);
495 + if (ippacket != NULL)
496 tcpentry = addentry(&table, (unsigned long)
497 ippacket->saddr,
498 (unsigned long)
499 - ippacket->daddr, sport,
500 + ippacket->daddr,
501 + NULL, NULL, sport,
502 dport,
503 ippacket->protocol,
504 ifname, &revlook,
505 rvnfd,
506 options->servnames,
507 &nomem);
509 + else
510 + tcpentry = addentry(&table, 0, 0,
511 + (uint8_t*)(&ip6packet->ip6_src.s6_addr),
512 + (uint8_t*)(&ip6packet->ip6_dst.s6_addr),
513 + sport, dport, ip6packet->ip6_nxt,
514 + ifname, &revlook,
515 + rvnfd, options->servnames,
516 + &nomem);
517 if (tcpentry != NULL) {
518 printentry(&table,
519 tcpentry->oth_connection,
520 @@ -1152,12 +1195,18 @@
521 p_sstat = tcpentry->s_fstat;
522 p_dstat = tcpentry->d_fstat;
524 + if (ippacket != NULL)
525 updateentry(&table, tcpentry, transpacket,
526 tpacket, linktype, readlen, br,
527 ippacket->frag_off, logging,
528 &revlook, rvnfd, options, logfile,
529 &nomem);
531 + else
532 + updateentry(&table, tcpentry, transpacket, tpacket,
533 + linktype, readlen,
534 + readlen, 0, logging,
535 + &revlook, rvnfd, options, logfile,
536 + &nomem);
538 * Log first packet of a TCP connection except if
539 * it's a RST, which was already logged earlier in
540 @@ -1213,7 +1262,7 @@
541 screen_idx, mode);
544 - } else { /* now for the other IP protocols */
545 + } else if (ippacket != NULL) {
546 fragment = ((ntohs(ippacket->frag_off) & 0x1fff) != 0);
548 if (ippacket->protocol == IPPROTO_ICMP) {
549 @@ -1234,7 +1283,7 @@
551 othpent =
552 add_othp_entry(&othptbl, &table, ippacket->saddr,
553 - ippacket->daddr, IS_IP,
554 + ippacket->daddr, NULL, NULL, IS_IP,
555 ippacket->protocol, linktype,
556 (char *) tpacket,
557 (char *) transpacket, readlen,
558 @@ -1242,6 +1291,21 @@
559 options->timeout, logging, logfile,
560 options->servnames, fragment,
561 &nomem);
563 + } else {
564 + if (ip6packet->ip6_nxt == IPPROTO_ICMPV6) {
565 + if (((struct icmp6_hdr *) transpacket)->icmp6_type == ICMP6_DST_UNREACH)
566 + process_dest_unreach(&table, (char *) transpacket,
567 + ifname, &nomem);
569 + othpent =
570 + add_othp_entry(&othptbl, &table, 0, 0, &ip6packet->ip6_src,
571 + &ip6packet->ip6_dst, IS_IP,
572 + ip6packet->ip6_nxt, linktype,
573 + (char *) tpacket, (char *) transpacket,
574 + readlen, ifname, &revlook,
575 + rvnfd, options->timeout, logging, logfile,
576 + options->servnames, fragment, &nomem);
580 --- ./iptraf-3.0.0.orig/src/landesc.c 2005-09-13 08:42:54.000000000 +0200
581 +++ ./iptraf-3.0.0/src/landesc.c 2006-01-08 05:21:02.000000000 +0100
582 @@ -208,7 +208,7 @@
583 else if (linktype == LINK_FDDI)
584 fd = fopen(FDDIFILE, "w");
586 - if (fd < 0) {
587 + if (fd <= 0) {
588 etherr();
589 return;
591 --- ./iptraf-3.0.0.orig/src/options.c 2005-09-13 08:42:54.000000000 +0200
592 +++ ./iptraf-3.0.0/src/options.c 2006-01-08 05:34:56.000000000 +0100
593 @@ -41,7 +41,7 @@
595 void makeoptionmenu(struct MENU *menu)
597 - tx_initmenu(menu, 19, 40, (LINES - 19) / 2 - 1, (COLS - 40) / 16,
598 + tx_initmenu(menu, 20, 40, (LINES - 19) / 2 - 1, (COLS - 40) / 16,
599 BOXATTR, STDATTR, HIGHATTR, BARSTDATTR, BARHIGHATTR,
600 DESCATTR);
601 tx_additem(menu, " ^R^everse DNS lookups",
602 @@ -58,6 +58,8 @@
603 "Toggles activity indicators between kbits/s and kbytes/s");
604 tx_additem(menu, " Source ^M^AC addrs in traffic monitor",
605 "Toggles display of source MAC addresses in the IP Traffic Monitor");
606 + tx_additem(menu, " ^S^how v6-in-v4 traffic as IPv6",
607 + "Toggled display of IPv6 tunnel in IPv4 as IPv6 traffic");
608 tx_additem(menu, NULL, NULL);
609 tx_additem(menu, " ^T^imers...", "Configures timeouts and intervals");
610 tx_additem(menu, NULL, NULL);
611 @@ -131,6 +133,8 @@
612 case 7:
613 printoptonoff(options->mac, win);
614 break;
615 + case 8:
616 + printoptonoff(options->v6inv4asv6, win);
620 @@ -168,6 +172,7 @@
621 options->logspan = 3600;
622 options->updrate = 0;
623 options->closedint = 0;
624 + options->v6inv4asv6 = 1;
627 void loadoptions(struct OPTIONS *options)
628 @@ -189,17 +194,17 @@
629 void updatetimes(struct OPTIONS *options, WINDOW * win)
631 wattrset(win, HIGHATTR);
632 - mvwprintw(win, 9, 25, "%3u mins", options->timeout);
633 - mvwprintw(win, 10, 25, "%3u mins", options->logspan / 60);
634 - mvwprintw(win, 11, 25, "%3u secs", options->updrate);
635 - mvwprintw(win, 12, 25, "%3u mins", options->closedint);
636 + mvwprintw(win, 10, 25, "%3u mins", options->timeout);
637 + mvwprintw(win, 11, 25, "%3u mins", options->logspan / 60);
638 + mvwprintw(win, 12, 25, "%3u secs", options->updrate);
639 + mvwprintw(win, 13, 25, "%3u mins", options->closedint);
642 void showoptions(struct OPTIONS *options, WINDOW * win)
644 int i;
646 - for (i = 1; i <= 7; i++)
647 + for (i = 1; i <= 8; i++)
648 indicatesetting(i, options, win);
650 updatetimes(options, win);
651 @@ -272,13 +277,13 @@
653 makeoptionmenu(&menu);
655 - statwin = newwin(14, 35, (LINES - 19) / 2 - 1, (COLS - 40) / 16 + 40);
656 + statwin = newwin(15, 35, (LINES - 19) / 2 - 1, (COLS - 40) / 16 + 40);
657 statpanel = new_panel(statwin);
659 wattrset(statwin, BOXATTR);
660 tx_colorwin(statwin);
661 tx_box(statwin, ACS_VLINE, ACS_HLINE);
662 - wmove(statwin, 8, 1);
663 + wmove(statwin, 9, 1);
664 whline(statwin, ACS_HLINE, 33);
665 mvwprintw(statwin, 0, 1, " Current Settings ");
666 wattrset(statwin, STDATTR);
667 @@ -289,10 +294,11 @@
668 mvwprintw(statwin, 5, 2, "Logging:");
669 mvwprintw(statwin, 6, 2, "Activity mode:");
670 mvwprintw(statwin, 7, 2, "MAC addresses:");
671 - mvwprintw(statwin, 9, 2, "TCP timeout:");
672 - mvwprintw(statwin, 10, 2, "Log interval:");
673 - mvwprintw(statwin, 11, 2, "Update interval:");
674 - mvwprintw(statwin, 12, 2, "Closed/idle persist:");
675 + mvwprintw(statwin, 8, 2, "v6-in-v4 as IPv6:");
676 + mvwprintw(statwin, 10, 2, "TCP timeout:");
677 + mvwprintw(statwin, 11, 2, "Log interval:");
678 + mvwprintw(statwin, 12, 2, "Update interval:");
679 + mvwprintw(statwin, 13, 2, "Closed/idle persist:");
680 showoptions(options, statwin);
682 do {
683 @@ -321,7 +327,10 @@
684 case 7:
685 options->mac = ~(options->mac);
686 break;
687 - case 9:
688 + case 8:
689 + options->v6inv4asv6 = ~(options->v6inv4asv6);
690 + break;
691 + case 10:
692 maketimermenu(&timermenu);
693 trow = 1;
694 do {
695 @@ -362,22 +371,22 @@
696 update_panels();
697 doupdate();
698 break;
699 - case 11:
700 + case 12:
701 addmoreports(ports);
702 break;
703 - case 12:
704 + case 13:
705 removeaport(ports);
706 break;
707 - case 14:
708 + case 15:
709 ethdescmgr(LINK_ETHERNET);
710 break;
711 - case 15:
712 + case 16:
713 ethdescmgr(LINK_FDDI);
714 break;
717 indicatesetting(row, options, statwin);
718 - } while (row != 17);
719 + } while (row != 18);
721 tx_destroymenu(&menu);
722 del_panel(statpanel);
723 --- ./iptraf-3.0.0.orig/src/options.h 2005-09-13 08:42:54.000000000 +0200
724 +++ ./iptraf-3.0.0/src/options.h 2006-01-08 05:22:16.000000000 +0100
725 @@ -2,7 +2,7 @@
726 struct OPTIONS {
727 unsigned int color:1,
728 logging:1,
729 - revlook:1, servnames:1, promisc:1, actmode:1, mac:1, dummy:9;
730 + revlook:1, servnames:1, promisc:1, actmode:1, mac:1, v6inv4asv6:1, dummy:8;
731 unsigned int timeout;
732 unsigned int logspan;
733 unsigned int updrate;
734 --- ./iptraf-3.0.0.orig/src/othptab.c 2006-01-07 23:27:48.000000000 +0100
735 +++ ./iptraf-3.0.0/src/othptab.c 2006-01-08 05:23:13.000000000 +0100
736 @@ -18,6 +18,8 @@
738 #include <linux/netdevice.h>
739 #include <linux/if_fddi.h>
740 +#include <netinet/ip6.h>
741 +#include <netinet/icmp6.h>
742 #include <winops.h>
743 #include "arphdr.h"
744 #include "options.h"
745 @@ -77,16 +79,12 @@
746 char *ifname, int *nomem)
748 struct iphdr *ip;
749 + struct ip6_hdr *ip6;
750 struct tcphdr *tcp;
751 struct tcptableent *tcpentry;
753 ip = (struct iphdr *) (packet + 8);
755 - if (ip->protocol != IPPROTO_TCP)
756 - return;
758 - tcp = (struct tcphdr *) (packet + 8 + (ip->ihl * 4));
761 * We really won't be making use of nomem here. Timeout checking
762 * won't be performed either, so we just pass NULL as the pointer
763 @@ -94,9 +92,23 @@
764 * and set its internal timeout variable to 0.
767 - tcpentry = in_table(table, ip->saddr, ip->daddr,
768 + if (ip->version == 6)
770 + ip6 = (struct ip6_hdr *) (packet + 8);
771 + if (ip6->ip6_nxt != IPPROTO_TCP)
772 + return;
773 + tcp = (struct tcphdr *) (packet + 48);
774 + tcpentry = in_table(table, 0, 0, ip6->ip6_src.s6_addr, ip6->ip6_dst.s6_addr,
775 ntohs(tcp->source), ntohs(tcp->dest), ifname,
776 0, NULL, nomem, NULL);
777 + } else {
778 + if (ip->protocol != IPPROTO_TCP)
779 + return;
780 + tcp = (struct tcphdr *) (packet + 8 + (ip->ihl * 4));
781 + tcpentry = in_table(table, ip->saddr, ip->daddr, NULL, NULL,
782 + ntohs(tcp->source), ntohs(tcp->dest), ifname,
783 + 0, NULL, nomem, NULL);
786 if (tcpentry != NULL) {
787 tcpentry->stat = tcpentry->oth_connection->stat = FLAG_RST;
788 @@ -107,6 +119,7 @@
789 struct othptabent *add_othp_entry(struct othptable *table,
790 struct tcptable *tcptab,
791 unsigned long saddr, unsigned long daddr,
792 + struct in6_addr *s6addr, struct in6_addr *d6addr,
793 int is_ip, int protocol,
794 unsigned short linkproto, char *packet,
795 char *packet2, unsigned int br,
796 @@ -153,10 +166,18 @@
797 if (is_ip) {
798 new_entry->saddr = isaddr.s_addr = saddr;
799 new_entry->daddr = idaddr.s_addr = daddr;
801 - revname(rev_lookup, &isaddr, new_entry->s_fqdn, rvnfd);
802 - revname(rev_lookup, &idaddr, new_entry->d_fqdn, rvnfd);
804 + if (s6addr != NULL)
805 + memcpy(&new_entry->s6addr, s6addr, 16);
806 + else
807 + memset(&new_entry->s6addr, 0, 16);
809 + if (d6addr != NULL)
810 + memcpy(&new_entry->d6addr, d6addr, 16);
811 + else
812 + memset(&new_entry->s6addr, 0, 16);
814 + revname(rev_lookup, &isaddr, s6addr, new_entry->s_fqdn, rvnfd);
815 + revname(rev_lookup, &idaddr, d6addr, new_entry->d_fqdn, rvnfd);
816 if (!fragment) {
817 if (protocol == IPPROTO_ICMP) {
818 new_entry->un.icmp.type =
819 @@ -415,6 +436,14 @@
820 wattrset(table->othpwin, GREATTR);
821 strcpy(protname, "GRE");
822 break;
823 + case IPPROTO_ICMPV6:
824 + wattrset(table->othpwin, ICMPV6ATTR);
825 + strcpy(protname, "ICMPv6");
826 + break;
827 + case IPPROTO_IPV6:
828 + wattrset(table->othpwin, IPV6ATTR);
829 + strcpy(protname, "IPv6 tun");
830 + break;
831 default:
832 wattrset(table->othpwin, UNKNIPATTR);
833 protptr = getprotobynumber(entry->protocol);
834 @@ -520,7 +549,71 @@
835 strcpy(description, "bad/unkn");
836 break;
839 + } else if (entry->protocol == IPPROTO_ICMPV6) {
840 + switch (entry->un.icmp6.type) {
841 + case ICMP6_DST_UNREACH:
842 + strcpy(description, "dest unrch");
843 + switch (entry->un.icmp6.code) {
844 + case ICMP6_DST_UNREACH_NOROUTE:
845 + strcpy(additional, "no route");
846 + break;
847 + case ICMP6_DST_UNREACH_ADMIN:
848 + strcpy(additional, "admin");
849 + break;
850 + case ICMP6_DST_UNREACH_NOTNEIGHBOR:
851 + strcpy(additional, "not neigh");
852 + break;
853 + case ICMP6_DST_UNREACH_ADDR:
854 + strcpy(additional, "unreach addr");
855 + break;
856 + case ICMP6_DST_UNREACH_NOPORT:
857 + strcpy(additional, "no port");
858 + break;
860 + break;
861 + case ICMP6_PACKET_TOO_BIG:
862 + strcpy(description, "pkt too big");
863 + break;
864 + case ICMP6_TIME_EXCEEDED:
865 + strcpy(description, "time exceeded");
866 + break;
867 + case ICMP6_PARAM_PROB:
868 + strcpy(description, "param prob");
869 + break;
870 + case ICMP6_ECHO_REQUEST:
871 + strcpy(description, "echo req");
872 + break;
873 + case ICMP6_ECHO_REPLY:
874 + strcpy(description, "echo rply");
875 + break;
876 + case ND_ROUTER_SOLICIT:
877 + strcpy(description, "router sol");
878 + break;
879 + case ND_ROUTER_ADVERT:
880 + strcpy(description, "router adv");
881 + break;
882 + case ICMP6_MEMBERSHIP_QUERY:
883 + strcpy(description, "mbrship query");
884 + break;
885 + case ICMP6_MEMBERSHIP_REPORT:
886 + strcpy(description, "mbrship report");
887 + break;
888 + case ICMP6_MEMBERSHIP_REDUCTION:
889 + strcpy(description, "mbrship reduc");
890 + break;
891 + case ND_NEIGHBOR_SOLICIT:
892 + strcpy(description, "neigh sol");
893 + break;
894 + case ND_NEIGHBOR_ADVERT:
895 + strcpy(description, "neigh adv");
896 + break;
897 + case ND_REDIRECT:
898 + strcpy(description, "redirect");
899 + break;
900 + default:
901 + strcpy(description, "bad/unkn");
902 + break;
904 } else if (entry->protocol == IPPROTO_OSPFIGP) {
905 switch (entry->un.ospf.type) {
906 case OSPF_TYPE_HELLO:
907 @@ -564,11 +657,11 @@
908 strcat(msgstring, scratchpad);
910 if ((entry->protocol == IPPROTO_UDP) && (!(entry->fragment))) {
911 - sprintf(scratchpad, "from %.25s:%s to %.25s:%s",
912 + sprintf(scratchpad, "from %.40s:%s to %.40s:%s",
913 entry->s_fqdn, entry->un.udp.s_sname,
914 entry->d_fqdn, entry->un.udp.d_sname);
915 } else {
916 - sprintf(scratchpad, "from %.25s to %.25s", entry->s_fqdn,
917 + sprintf(scratchpad, "from %.40s to %.40s", entry->s_fqdn,
918 entry->d_fqdn);
921 --- ./iptraf-3.0.0.orig/src/othptab.h 2005-09-13 08:42:54.000000000 +0200
922 +++ ./iptraf-3.0.0/src/othptab.h 2006-01-08 05:29:02.000000000 +0100
923 @@ -34,6 +34,8 @@
924 struct othptabent {
925 unsigned long int saddr;
926 unsigned long int daddr;
927 + struct in6_addr s6addr;
928 + struct in6_addr d6addr;
929 char smacaddr[15];
930 char dmacaddr[15];
931 unsigned short linkproto;
932 @@ -69,6 +71,10 @@
933 char src_mac_address[6];
934 char dest_mac_address[6];
935 } rarp;
936 + struct {
937 + uint8_t type;
938 + uint8_t code;
939 + } icmp6;
940 } un;
941 unsigned int type;
942 unsigned int code;
943 @@ -133,9 +139,9 @@
944 struct othptabent *add_othp_entry(struct othptable *table,
945 struct tcptable *tcptab,
946 unsigned long saddr,
947 - unsigned long daddr, int is_ip,
948 - int protocol, unsigned short linkproto,
949 - char *packet, char *netpacket,
950 + unsigned long daddr, struct in6_addr *s6addr,
951 + struct in6_addr *d6addr, int is_ip, int protocol,
952 + unsigned short linkproto, char *packet, char *netpacket,
953 unsigned int br, char *ifname,
954 int *rev_lookup, int rvnamedon,
955 unsigned int tm, int logging,
956 --- ./iptraf-3.0.0.orig/src/packet.c 2006-01-07 23:27:48.000000000 +0100
957 +++ ./iptraf-3.0.0/src/packet.c 2006-01-08 05:23:43.000000000 +0100
958 @@ -28,6 +28,7 @@
959 #include <sys/socket.h>
960 #include <netinet/in.h>
961 #include <netinet/ip.h>
962 +#include <netinet/ip6.h>
963 #include <netinet/tcp.h>
964 #include <sys/time.h>
965 #include <net/if_arp.h>
966 @@ -308,6 +309,7 @@
968 static char aligned_buf[ALIGNED_BUF_LEN];
969 struct iphdr *ip;
970 + struct ip6_hdr *ip6;
971 int hdr_check;
972 register int ip_checksum;
973 register int iphlen;
974 @@ -361,7 +363,7 @@
975 * Apply non-IP packet filter
978 - if (fromaddr->sll_protocol != ETH_P_IP) {
979 + if ((fromaddr->sll_protocol != ETH_P_IP) && (fromaddr->sll_protocol != ETH_P_IPV6)) {
980 if ((fromaddr->sll_protocol == ETH_P_ARP) ||
981 (fromaddr->sll_protocol == ETH_P_RARP)) {
982 if (!nonipfilter(filter, fromaddr->sll_protocol)) {
983 @@ -375,9 +377,7 @@
984 return PACKET_OK;
987 - /*
988 - * TODO: Insert IPv6 processing code here
989 - */
990 + if (fromaddr->sll_protocol == ETH_P_IP) {
993 * At this point, we're now processing IP packets. Start by getting
994 @@ -394,7 +394,7 @@
995 ip->check = 0;
996 hdr_check = in_cksum((u_short *) ip, iphlen);
998 - if (hdr_check != ip_checksum)
999 + if ((hdr_check != ip_checksum))
1000 return CHECKSUM_ERROR;
1002 if ((ip->protocol == IPPROTO_TCP || ip->protocol == IPPROTO_UDP) &&
1003 @@ -458,9 +458,28 @@
1004 ip->protocol, match_opposite,
1005 &(filter->fl))))
1006 return PACKET_FILTERED;
1009 - return PACKET_OK;
1011 + return PACKET_OK;
1013 + else if (fromaddr->sll_protocol == ETH_P_IPV6) {
1014 + ip6 = (struct ip6_hdr *) (*packet);
1015 + iphlen = 40;
1016 + //TODO: Filter packets
1017 + if (ip6->ip6_nxt == IPPROTO_TCP) {
1018 + in_ip.tcp = (struct tcphdr *) ((char *) ip6 + iphlen);
1019 + if (sport != NULL)
1020 + *sport = in_ip.tcp->source;
1021 + if (dport != NULL)
1022 + *dport = in_ip.tcp->dest;
1023 + } else if (ip6->ip6_nxt == IPPROTO_UDP) {
1024 + in_ip.udp = (struct udphdr *) ((char *) ip6 + iphlen);
1025 + if (sport != NULL)
1026 + *sport = in_ip.udp->source;
1027 + if (dport != NULL)
1028 + *dport = in_ip.udp->dest;
1031 + return PACKET_OK;
1034 void pkt_cleanup(void)
1035 --- ./iptraf-3.0.0.orig/src/revname.c 2005-09-13 08:42:54.000000000 +0200
1036 +++ ./iptraf-3.0.0/src/revname.c 2006-01-08 05:24:43.000000000 +0100
1037 @@ -153,7 +153,7 @@
1041 -int revname(int *lookup, struct in_addr *saddr, char *target, int rvnfd)
1042 +int revname(int *lookup, struct in_addr *saddr, struct in6_addr *s6addr, char *target, int rvnfd)
1044 struct hostent *he;
1045 struct rvn rpkt;
1046 @@ -173,6 +173,11 @@
1047 rpkt.type = RVN_REQUEST;
1048 rpkt.saddr.s_addr = saddr->s_addr;
1050 + if (s6addr != NULL)
1051 + memcpy(rpkt.s6addr.s6_addr, s6addr->s6_addr, 16);
1052 + else
1053 + memset(rpkt.s6addr.s6_addr, 0, 4);
1055 sendto(rvnfd, &rpkt, sizeof(struct rvn), 0,
1056 (struct sockaddr *) &su,
1057 sizeof(su.sun_family) + strlen(su.sun_path));
1058 @@ -197,7 +202,10 @@
1059 } while ((br < 0) && (errno == EINTR));
1061 if (br < 0) {
1062 + if (saddr->s_addr != 0)
1063 strcpy(target, inet_ntoa(*saddr));
1064 + else
1065 + inet_ntop(AF_INET6, s6addr, target, 44);
1066 printipcerr();
1067 *lookup = 0;
1068 return RESOLVED;
1069 @@ -205,18 +213,26 @@
1070 strncpy(target, rpkt.fqdn, 44);
1071 return (rpkt.ready);
1072 } else {
1073 - he = gethostbyaddr((char *) saddr,
1074 - sizeof(struct in_addr), AF_INET);
1075 + if (saddr->s_addr != 0)
1076 + he = gethostbyaddr((char *) saddr, sizeof(struct in_addr), AF_INET);
1077 + else
1078 + he = gethostbyaddr((char *) s6addr, sizeof(struct in6_addr), AF_INET6);
1080 - if (he == NULL)
1081 + if (he == NULL) {
1082 + if (saddr->s_addr != 0)
1083 strcpy(target, inet_ntoa(*saddr));
1084 else
1085 + inet_ntop(AF_INET6, s6addr, target, 44);
1086 + } else {
1087 strncpy(target, he->h_name, 44);
1090 return RESOLVED;
1092 } else {
1093 - strcpy(target, inet_ntoa(*saddr));
1094 - return RESOLVED;
1095 + if (saddr->s_addr != 0 || s6addr == NULL)
1096 + strcpy(target, inet_ntoa(*saddr));
1097 + else
1098 + inet_ntop(AF_INET6, s6addr, target, 44);
1101 --- ./iptraf-3.0.0.orig/src/revname.h 2005-09-13 08:42:54.000000000 +0200
1102 +++ ./iptraf-3.0.0/src/revname.h 2006-01-08 05:24:54.000000000 +0100
1103 @@ -8,4 +8,5 @@
1104 int killrvnamed();
1105 void open_rvn_socket(int *fd);
1106 void close_rvn_socket(int fd);
1107 -int revname(int *lookup, struct in_addr *saddr, char *target, int rvnfd);
1109 +int revname(int *lookup, struct in_addr *saddr, struct in6_addr *s6addr, char *target, int rvnfd);
1110 --- ./iptraf-3.0.0.orig/src/rvnamed.c 2005-09-13 08:42:54.000000000 +0200
1111 +++ ./iptraf-3.0.0/src/rvnamed.c 2006-01-08 05:25:36.000000000 +0100
1112 @@ -55,6 +55,7 @@
1114 struct hosts {
1115 unsigned long addr;
1116 + uint8_t addr6[16];
1117 char fqdn[45];
1118 int ready;
1120 @@ -93,12 +94,17 @@
1122 ccfd = socket(PF_UNIX, SOCK_DGRAM, 0);
1124 - he = gethostbyaddr((char *) &(rvnpacket->saddr),
1125 - sizeof(struct in_addr), AF_INET);
1126 + if (rvnpacket->saddr.s_addr != 0)
1127 + he = gethostbyaddr((char *) &(rvnpacket->saddr), sizeof(struct in_addr), AF_INET);
1128 + else
1129 + he = gethostbyaddr((char *) &(rvnpacket->s6addr), sizeof(struct in6_addr), AF_INET6);
1131 - if (he == NULL)
1132 + if (he == NULL) {
1133 + if (rvnpacket->saddr.s_addr != 0)
1134 strcpy(rvnpacket->fqdn, inet_ntoa(rvnpacket->saddr));
1135 - else {
1136 + else
1137 + inet_ntop(AF_INET6, &(rvnpacket->s6addr), rvnpacket->fqdn, sizeof(rvnpacket->fqdn));
1138 + } else {
1139 bzero(rvnpacket->fqdn, 45);
1140 strncpy(rvnpacket->fqdn, he->h_name, 44);
1142 @@ -122,10 +128,14 @@
1143 unsigned int i = 0;
1145 while (i != lastfree) {
1146 + if (rvnpacket->saddr.s_addr != 0) {
1147 if ((rvnpacket->saddr.s_addr == hostlist[i].addr)
1148 && (hostlist[i].ready == RESOLVED))
1149 return i;
1151 + } else {
1152 + if (!memcmp(rvnpacket->s6addr.s6_addr, hostlist[i].addr6, sizeof(hostlist[i].addr6)))
1153 + return i;
1155 i++;
1158 @@ -300,7 +310,8 @@
1159 hi = 0;
1161 while (hi <= lastfree) {
1162 - if (hostlist[hi].addr == rvnpacket.saddr.s_addr)
1163 + if ((hostlist[hi].addr == rvnpacket.saddr.s_addr) &&
1164 + !memcmp(rvnpacket.s6addr.s6_addr, hostlist[hi].addr6, sizeof(hostlist[hi].addr6)))
1165 break;
1166 hi++;
1168 @@ -313,6 +324,7 @@
1169 hostindex = 0;
1171 hostlist[hi].addr = rvnpacket.saddr.s_addr;
1172 + memcpy(hostlist[hi].addr6, rvnpacket.s6addr.s6_addr, sizeof(hostlist[hi].addr6));
1174 strncpy(hostlist[hi].fqdn, rvnpacket.fqdn, 44);
1176 @@ -400,6 +412,8 @@
1178 hostlist[hostindex].addr =
1179 rvnpacket.saddr.s_addr;
1180 + memcpy(hostlist[hostindex].addr6, rvnpacket.s6addr.s6_addr,
1181 + sizeof(hostlist[hostindex].addr6));
1182 hostlist[hostindex].ready = RESOLVING;
1184 maxlogged = 0;
1185 @@ -455,7 +469,10 @@
1187 rvnpacket.type = RVN_REPLY;
1188 bzero(rvnpacket.fqdn, 45);
1189 + if (rvnpacket.saddr.s_addr != 0)
1190 strcpy(rvnpacket.fqdn, inet_ntoa(rvnpacket.saddr));
1191 + else
1192 + inet_ntop(AF_INET6, &rvnpacket.s6addr, rvnpacket.fqdn, sizeof(rvnpacket.fqdn));
1193 rvnpacket.ready = RESOLVING;
1195 br = sendto(ifd, &rvnpacket, sizeof(struct rvn), 0,
1196 --- ./iptraf-3.0.0.orig/src/rvnamed.h 2005-09-13 08:42:54.000000000 +0200
1197 +++ ./iptraf-3.0.0/src/rvnamed.h 2006-01-08 05:25:41.000000000 +0100
1198 @@ -22,5 +22,6 @@
1199 int type;
1200 int ready;
1201 struct in_addr saddr;
1202 + struct in6_addr s6addr;
1203 char fqdn[45];
1205 --- ./iptraf-3.0.0.orig/src/serv.c 2005-09-13 08:42:54.000000000 +0200
1206 +++ ./iptraf-3.0.0/src/serv.c 2006-01-08 05:26:03.000000000 +0100
1207 @@ -31,6 +31,7 @@
1208 #include <sys/socket.h>
1209 #include <netinet/in.h>
1210 #include <netinet/ip.h>
1211 +#include <netinet/ip6.h>
1212 #include <netinet/udp.h>
1213 #include <linux/if_packet.h>
1214 #include <linux/if_ether.h>
1215 @@ -1032,6 +1033,8 @@
1216 if (pkt_result != PACKET_OK)
1217 continue;
1219 + if (fromaddr.sll_protocol == ETH_P_IP) {
1221 if ((((struct iphdr *) ipacket)->protocol == IPPROTO_TCP)
1222 || (((struct iphdr *) ipacket)->protocol == IPPROTO_UDP)) {
1223 updateportent(&list, ((struct iphdr *) ipacket)->protocol,
1224 @@ -1049,6 +1052,26 @@
1228 + } else {
1229 + if ((((struct ip6_hdr *) ipacket)->ip6_nxt == IPPROTO_TCP)
1230 + || (((struct ip6_hdr *) ipacket)->ip6_nxt ==
1231 + IPPROTO_UDP)) {
1232 + updateportent(&list, ((struct ip6_hdr *) ipacket)->ip6_nxt,
1233 + ntohs(sport),
1234 + ntohs(((struct ip6_hdr *) ipacket)->ip6_plen + 40),
1235 + idx, 0, ports, options->servnames);
1236 + updateportent(&list, ((struct ip6_hdr *) ipacket)->ip6_nxt,
1237 + ntohs(dport),
1238 + ntohs(((struct ip6_hdr *) ipacket)->ip6_plen + 40),
1239 + idx, 1, ports, options->servnames);
1240 + if ((list.barptr == NULL) && (list.head != NULL)) {
1241 + set_barptr((char **) &(list.barptr), (char *) list.head,
1242 + &(list.head->starttime), (char *) &(list.head->spans),
1243 + sizeof(struct serv_spans), statwin, &statcleared, statx);
1244 + list.baridx = 1;
1250 if (logging) {
1251 --- ./iptraf-3.0.0.orig/src/tcptable.c 2005-09-13 08:42:54.000000000 +0200
1252 +++ ./iptraf-3.0.0/src/tcptable.c 2006-01-08 05:27:39.000000000 +0100
1253 @@ -59,8 +59,8 @@
1254 * The hash function for the TCP hash table
1257 -unsigned int tcp_hash(unsigned long saddr, unsigned int sport,
1258 - unsigned long daddr, unsigned int dport,
1259 +unsigned int tcp_hash(unsigned long saddr, uint32_t *s6addr, unsigned int sport,
1260 + unsigned long daddr, uint32_t *d6addr, unsigned int dport,
1261 char *ifname)
1263 int i;
1264 @@ -69,6 +69,13 @@
1265 for (i = 0; i <= strlen(ifname) - 1; i++)
1266 ifsum += ifname[i];
1268 + if (s6addr != 0 && d6addr != 0) {
1269 + for (i = 0; i < 4; i++) {
1270 + saddr ^= s6addr[i];
1271 + daddr ^= d6addr[i];
1275 return ((ifsum + (4 * saddr) + (3 * sport) +
1276 (2 * daddr) + dport) % ENTRIES_IN_HASH_TABLE);
1278 @@ -139,8 +146,8 @@
1279 unsigned int hp; /* hash position in table */
1280 struct tcp_hashentry *ptmp;
1282 - hp = tcp_hash(entry->saddr.s_addr, entry->sport,
1283 - entry->daddr.s_addr, entry->dport, entry->ifname);
1284 + hp = tcp_hash(entry->saddr.s_addr, entry->s6addr.s6_addr32, entry->sport,
1285 + entry->daddr.s_addr, entry->d6addr.s6_addr32, entry->dport, entry->ifname);
1287 ptmp = malloc(sizeof(struct tcp_hashentry));
1288 bzero(ptmp, sizeof(struct tcp_hashentry));
1289 @@ -215,6 +222,8 @@
1290 struct tcptableent *addentry(struct tcptable *table,
1291 unsigned long int saddr,
1292 unsigned long int daddr,
1293 + uint8_t *s6addr,
1294 + uint8_t *d6addr,
1295 unsigned int sport, unsigned int dport,
1296 int protocol,
1297 char *ifname, int *rev_lookup,
1298 @@ -311,8 +320,22 @@
1300 new_entry->saddr.s_addr = new_entry->oth_connection->daddr.s_addr =
1301 saddr;
1302 + if (s6addr == NULL) {
1303 + memset(&new_entry->s6addr, 0, 16);
1304 + memset(&new_entry->oth_connection->d6addr, 0, 16);
1305 + } else {
1306 + memcpy(&new_entry->s6addr, s6addr, 16);
1307 + memcpy(&new_entry->oth_connection->d6addr, s6addr, 16);
1309 new_entry->daddr.s_addr = new_entry->oth_connection->saddr.s_addr =
1310 daddr;
1311 + if (d6addr == NULL) {
1312 + memset(&new_entry->d6addr, 0, 16);
1313 + memset(&new_entry->oth_connection->s6addr, 0, 16);
1314 + } else {
1315 + memcpy(&new_entry->d6addr, d6addr, 16);
1316 + memcpy(&new_entry->oth_connection->s6addr, d6addr, 16);
1318 new_entry->protocol = protocol;
1321 @@ -349,9 +372,10 @@
1323 new_entry->stat = new_entry->oth_connection->stat = 0;
1325 - new_entry->s_fstat = revname(rev_lookup, &(new_entry->saddr),
1326 + new_entry->s_fstat = revname(rev_lookup, &(new_entry->saddr), &new_entry->s6addr,
1327 new_entry->s_fqdn, rvnfd);
1328 - new_entry->d_fstat = revname(rev_lookup, &(new_entry->daddr),
1330 + new_entry->d_fstat = revname(rev_lookup, &(new_entry->daddr), &new_entry->d6addr,
1331 new_entry->d_fqdn, rvnfd);
1334 @@ -490,7 +514,8 @@
1337 struct tcptableent *in_table(struct tcptable *table, unsigned long saddr,
1338 - unsigned long daddr, unsigned int sport,
1339 + unsigned long daddr, uint8_t *s6addr,
1340 + uint8_t *d6addr, unsigned int sport,
1341 unsigned int dport, char *ifname,
1342 int logging, FILE * logfile,
1343 int *nomem, struct OPTIONS *opts)
1344 @@ -503,6 +528,9 @@
1345 time_t now;
1346 time_t timeout;
1348 + int sfree = 0;
1349 + int dfree = 0;
1351 if (opts != NULL)
1352 timeout = opts->timeout;
1353 else
1354 @@ -515,12 +543,24 @@
1355 * Determine hash table index for this set of addresses and ports
1358 - hp = tcp_hash(saddr, sport, daddr, dport, ifname);
1359 + hp = tcp_hash(saddr, (uint32_t*) s6addr, sport, daddr, (uint32_t*) d6addr, dport, ifname);
1360 hashptr = table->hash_table[hp];
1362 + if (s6addr == NULL) {
1363 + s6addr = malloc(sizeof(struct in6_addr));
1364 + memset(s6addr, 0, 16);
1365 + sfree = 1;
1367 + if (d6addr == NULL) {
1368 + d6addr = malloc(sizeof(struct in6_addr));
1369 + memset(d6addr, 0, 16);
1370 + dfree = 1;
1372 while (hashptr != NULL) {
1373 if ((hashptr->tcpnode->saddr.s_addr == saddr) &&
1374 + (!memcmp(&hashptr->tcpnode->s6addr.s6_addr, s6addr, 16)) &&
1375 (hashptr->tcpnode->daddr.s_addr == daddr) &&
1376 + (!memcmp(&hashptr->tcpnode->d6addr.s6_addr, d6addr, 16)) &&
1377 (hashptr->tcpnode->sport == sport) &&
1378 (hashptr->tcpnode->dport == dport) &&
1379 (strcmp(hashptr->tcpnode->ifname, ifname) == 0))
1380 @@ -549,6 +589,9 @@
1381 hashptr = hashptr->next_entry;
1384 + if (sfree) free(s6addr);
1385 + if (dfree) free(d6addr);
1387 if (hashptr != NULL) { /* needed to avoid SIGSEGV */
1388 if ((((hashptr->tcpnode->finsent == 2) &&
1389 (hashptr->tcpnode->oth_connection->finsent == 2))) ||
1390 @@ -579,13 +622,13 @@
1391 char newmacaddr[15];
1393 if (tableentry->s_fstat != RESOLVED) {
1394 - tableentry->s_fstat = revname(revlook, &(tableentry->saddr),
1395 + tableentry->s_fstat = revname(revlook, &(tableentry->saddr), &(tableentry->s6addr),
1396 tableentry->s_fqdn, rvnfd);
1397 strcpy(tableentry->oth_connection->d_fqdn, tableentry->s_fqdn);
1398 tableentry->oth_connection->d_fstat = tableentry->s_fstat;
1400 if (tableentry->d_fstat != RESOLVED) {
1401 - tableentry->d_fstat = revname(revlook, &(tableentry->daddr),
1402 + tableentry->d_fstat = revname(revlook, &(tableentry->daddr), &(tableentry->d6addr),
1403 tableentry->d_fqdn, rvnfd);
1404 strcpy(tableentry->oth_connection->s_fqdn, tableentry->d_fqdn);
1405 tableentry->oth_connection->s_fstat = tableentry->d_fstat;
1406 --- ./iptraf-3.0.0.orig/src/tcptable.h 2006-01-07 23:27:48.000000000 +0100
1407 +++ ./iptraf-3.0.0/src/tcptable.h 2006-01-08 05:27:52.000000000 +0100
1408 @@ -49,6 +49,8 @@
1409 struct tcptableent {
1410 struct in_addr saddr;
1411 struct in_addr daddr;
1412 + struct in6_addr s6addr;
1413 + struct in6_addr d6addr;
1414 char s_fqdn[45]; /* fully-qualified domain names */
1415 char d_fqdn[45];
1416 int s_fstat;
1417 @@ -123,6 +125,7 @@
1418 struct tcptableent *addentry(struct tcptable *table,
1419 unsigned long int saddr,
1420 unsigned long int daddr,
1421 + uint8_t *s6addr, uint8_t *d6addr,
1422 unsigned int sport, unsigned int dport,
1423 int protocol,
1424 char *ifname, int *rev_lookup, int rvnamedon,
1425 @@ -130,6 +133,7 @@
1427 struct tcptableent *in_table(struct tcptable *table,
1428 unsigned long saddr, unsigned long daddr,
1429 + uint8_t *s6addr, uint8_t *d6addr,
1430 unsigned int sport, unsigned int dport,
1431 char *ifname,
1432 int logging, FILE * logfile, int *nomem,