feat: added basic tcp, udp and icmp handling
This commit is contained in:
parent
a85bcc8ca2
commit
885be66d5e
5 changed files with 70 additions and 4 deletions
|
|
@ -67,3 +67,41 @@ int handle_ip(struct iphdr* ip) {
|
|||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int handle_icmp(struct icmphdr* icmp) {
|
||||
printf("\n\t\tICMP:\n");
|
||||
printf("\t\t\tType : %d\n", icmp->type);
|
||||
printf("\t\t\tCode : %d\n", icmp->code);
|
||||
printf("\t\t\tChecksum : %d\n", icmp->checksum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_tcp(struct tcphdr* tcp) {
|
||||
printf("\n\t\tTCP:\n");
|
||||
printf("\t\t\tPort Source : %d\n", ntohs(tcp->source));
|
||||
printf("\t\t\tPort Destination : %d\n", ntohs(tcp->dest));
|
||||
printf("\t\t\tSeq Number : %u\n", ntohl(tcp->seq));
|
||||
printf("\t\t\tAck Number : %u\n", ntohl(tcp->ack_seq));
|
||||
printf("\t\t\tData Offset : %d\n", tcp->doff);
|
||||
printf("\t\t\tFlags : ");
|
||||
if (tcp->urg) printf("URG ");
|
||||
if (tcp->ack) printf("ACK ");
|
||||
if (tcp->psh) printf("PSH ");
|
||||
if (tcp->rst) printf("RST ");
|
||||
if (tcp->syn) printf("SYN ");
|
||||
if (tcp->fin) printf("FIN ");
|
||||
printf("\n");
|
||||
printf("\t\t\tWindow Size : %d\n", ntohs(tcp->window));
|
||||
printf("\t\t\tChecksum : %d\n", ntohs(tcp->check));
|
||||
printf("\t\t\tUrgent Pointer : %d\n", tcp->urg_ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_udp(struct udphdr* udp) {
|
||||
printf("\n\t\tUDP:\n");
|
||||
printf("\t\t\tPort Source : %d\n", ntohs(udp->source));
|
||||
printf("\t\t\tPort Destination : %d\n", ntohs(udp->dest));
|
||||
printf("\t\t\tLength : %d\n", ntohs(udp->len));
|
||||
printf("\t\t\tChecksum : %d\n", ntohs(udp->check));
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue