-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathipv6.cpp
More file actions
40 lines (32 loc) · 1.1 KB
/
ipv6.cpp
File metadata and controls
40 lines (32 loc) · 1.1 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
#include <stdio.h>
#include <arpa/inet.h>
#include "colors.h"
#include "ipv6.h"
#include "tcp.h"
#include "udp.h"
#include "ipprotocols.h"
void handle_ipv6(QList<QStandardItem *> *row, const struct sniff_ipv6 *ip6){
char buffer[INET6_ADDRSTRLEN];
printf(CYAN " IPv6 Header:\n" RESET);
//Append the source address
printf(" Source ------- %s\n", inet_ntop(AF_INET6, ip6->ip6_src, buffer, sizeof(buffer)));
row->append(new QStandardItem(QString(buffer)));
//Append the destination address
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;
}
}
}