1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 20:01:35 +01:00

Added IPv4Address class.

This commit is contained in:
Matias Fontanini
2012-05-03 12:03:26 -03:00
parent ae7e1b3d0d
commit 08f8521ae7
10 changed files with 113 additions and 168 deletions

View File

@@ -40,13 +40,11 @@ using namespace std;
const uint8_t Tins::IP::DEFAULT_TTL = 128;
Tins::IP::IP(const string &ip_dst, const string &ip_src, PDU *child) : PDU(Constants::IP::PROTO_IP, child) {
Tins::IP::IP(IPv4Address ip_dst, IPv4Address ip_src, PDU *child) :
PDU(Constants::IP::PROTO_IP, child) {
init_ip_fields();
if(ip_dst.size())
this->dst_addr(ip_dst);
if(ip_src.size())
this->src_addr(ip_src);
this->dst_addr(ip_dst);
this->src_addr(ip_src);
}
Tins::IP::IP(const IP &other) : PDU(other) {
@@ -144,12 +142,6 @@ Tins::IP::IP(const uint8_t *buffer, uint32_t total_sz) : PDU(Constants::IP::PROT
}
}
Tins::IP::IP(uint32_t ip_dst, uint32_t ip_src, PDU *child) : PDU(Constants::IP::PROTO_IP, child) {
init_ip_fields();
this->dst_addr(ip_dst);
this->src_addr(ip_src);
}
Tins::IP::~IP() {
cleanup();
}
@@ -199,20 +191,14 @@ void Tins::IP::check(uint16_t new_check) {
_ip.check = Utils::net_to_host_s(new_check);
}
void Tins::IP::src_addr(const string &ip) {
_ip.saddr = Utils::net_to_host_l(Utils::resolve_ip(ip));
void Tins::IP::src_addr(IPv4Address ip) {
_ip.saddr = ip;
}
void Tins::IP::src_addr(uint32_t ip) {
_ip.saddr = Utils::net_to_host_l(ip);
}
void Tins::IP::dst_addr(const string &ip) {
_ip.daddr = Utils::net_to_host_l(Utils::resolve_ip(ip));
}
void Tins::IP::dst_addr(uint32_t ip) {
_ip.daddr = Utils::net_to_host_l(ip);
void Tins::IP::dst_addr(IPv4Address ip) {
_ip.daddr = ip;
}
void Tins::IP::head_len(uint8_t new_head_len) {