1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-25 11:41:35 +01:00

Added support for IPSec.

This commit is contained in:
Matias Fontanini
2013-11-04 23:05:00 -03:00
parent de06fee5ab
commit 5345b29f8c
11 changed files with 679 additions and 57 deletions

View File

@@ -36,6 +36,7 @@
#include "ipv6.h"
#include "tcp.h"
#include "udp.h"
#include "ipsec.h"
#include "icmp.h"
#include "icmpv6.h"
#include "arp.h"
@@ -120,6 +121,10 @@ Tins::PDU *pdu_from_flag(Constants::IP::e flag, const uint8_t *buffer,
return new Tins::ICMPv6(buffer, size);
case Constants::IP::PROTO_IPV6:
return new Tins::IPv6(buffer, size);
case Constants::IP::PROTO_AH:
return new Tins::IPSecAH(buffer, size);
case Constants::IP::PROTO_ESP:
return new Tins::IPSecESP(buffer, size);
default:
break;
}
@@ -194,6 +199,27 @@ Constants::Ethernet::e pdu_flag_to_ether_type(PDU::PDUType flag) {
}
}
Constants::IP::e pdu_flag_to_ip_type(PDU::PDUType flag) {
switch(flag) {
case PDU::IP:
return Constants::IP::PROTO_IPIP;
case PDU::TCP:
return Constants::IP::PROTO_TCP;
case PDU::UDP:
return Constants::IP::PROTO_UDP;
case PDU::ICMP:
return Constants::IP::PROTO_ICMP;
case PDU::ICMPv6:
return Constants::IP::PROTO_ICMPV6;
case PDU::IPSEC_AH:
return Constants::IP::PROTO_AH;
case PDU::IPSEC_ESP:
return Constants::IP::PROTO_ESP;
default:
return static_cast<Constants::IP::e>(0xff);
};
}
bool increment(IPv4Address &addr) {
uint32_t addr_int = Endian::be_to_host<uint32_t>(addr);
bool reached_end = ++addr_int == 0xffffffff;