X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/77a15cf8943d5588e17815771420d189f3f8bca8..26fc1173c5122fd73d1cd2191e20d49fef1e1f32:/practicas/pipi/src/test_ipaddr.cpp diff --git a/practicas/pipi/src/test_ipaddr.cpp b/practicas/pipi/src/test_ipaddr.cpp index b3a84d9..a34cb28 100644 --- a/practicas/pipi/src/test_ipaddr.cpp +++ b/practicas/pipi/src/test_ipaddr.cpp @@ -1,14 +1,29 @@ #include "ipaddr.h" +#include "ipheader.h" #include int main() { + // Addr IPAddr ip1(0x0a0a0a05); IPAddr ip2("10.10.10.1"); IPAddr ip3(10, 10, 10, 2); std::cout << "IP1 = " << ip1 << "\n"; std::cout << "IP2 = " << ip2 << "\n"; std::cout << "IP3 = " << ip3 << "\n"; + // Header + IPHeader h1(4, 20, 1, 1, 0, 0, 64, 0x11, ip1, ip2); + std::cout << "Header1 = " << h1 << "\n"; + if (h1.check_checksum()) + std::cout << "Checksum OK\n"; + else + std::cout << "Checksum MAL!\n"; + h1.checksum = 1; + if (h1.check_checksum()) + std::cout << "Checksum OK\n"; + else + std::cout << "Checksum MAL!\n"; + return 0; } // vim: set et sw=4 sts=4 :