forked from KTZ-Goel/PacketSniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipv6.cpp
More file actions
executable file
·47 lines (39 loc) · 1.18 KB
/
ipv6.cpp
File metadata and controls
executable file
·47 lines (39 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "ipv6.h"
#include <arpa/inet.h>
#include <stdio.h>
#include "colors.h"
#include "ipprotocols.h"
#include "tcp.h"
#include "udp.h"
void handle_ipv6(QList<QStandardItem*>* row, const struct sniff_ipv6* ip6)
{
char buffer[INET6_ADDRSTRLEN];
printf(CYAN " IPv6 Header:\n" RESET);
// IPv6源地址
printf(" Source ------- %s\n",
inet_ntop(AF_INET6, ip6->ip6_src, buffer, sizeof(buffer)));
row->append(new QStandardItem(QString(buffer)));
// IPv6目的地址
printf(" Destination -- %s\n",
inet_ntop(AF_INET6, ip6->ip6_dst, buffer, sizeof(buffer)));
row->append(new QStandardItem(QString(buffer)));
printf(" Protocol ----- %X\n", ip6->ip6_p);
switch (ip6->ip6_p) {
case IP_TCP: {
handle_tcp(row, (struct sniff_tcp*)((char*)ip6 + IPV6_HEADER_LENGTH),
ntohs(ip6->ip6_len) - IPV6_HEADER_LENGTH);
break;
}
case IP_UDP: {
handle_udp(row, (struct sniff_udp*)((char*)ip6 + IPV6_HEADER_LENGTH));
break;
}
default: {
printf(YELLOW
" Transport layer protocol [0x%02X] not implemented yet." RESET
"\n",
ip6->ip6_p);
break;
}
}
}