1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-25 03:31:36 +01:00

Updated IP, PDU and PacketSender so as to send forged ip packets successfully

This commit is contained in:
Santiago Alessandri
2011-08-11 09:35:23 -03:00
parent 8dc0a5a832
commit f9445b05b6
7 changed files with 87 additions and 68 deletions

View File

@@ -22,12 +22,13 @@ uint32_t Tins::Utils::ip_to_int(const string &ip) {
}
if(bytes_found < 4 || (i < ip.size() && bytes_found == 4))
throw std::runtime_error("Invalid ip address");
return result;
return ntohl(result);
}
string Tins::Utils::ip_to_string(uint32_t ip) {
ostringstream oss;
int mask(24);
ip = ntohl(ip);
while(mask >=0) {
oss << ((ip >> mask) & 0xff);
if(mask)