X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/51f24d14e8c4c52776a98c8e2aaacf95f90ad1f4..0a2739fe97762f57a80599ef170df98e07422a3d:/practicas/pipi/src/test_ipin.cpp?ds=inline diff --git a/practicas/pipi/src/test_ipin.cpp b/practicas/pipi/src/test_ipin.cpp index 7b56b11..01b19aa 100644 --- a/practicas/pipi/src/test_ipin.cpp +++ b/practicas/pipi/src/test_ipin.cpp @@ -3,16 +3,30 @@ #include "ipaddr.h" #include "dev.h" #include +#include #include #include #include #include #include -int main() +// Uso: ./test_ipin ip mtu proto queue_id + +int main(int argc, char* argv[]) { IPAddr addr("10.10.10.1"); - Dev dev(addr); + unsigned mtu = 25; + unsigned proto = 0; + key_t queue_id = DEV_DEFAULT_KEY; + if (argc > 1) + addr = IPAddr(argv[1]); + if (argc > 2) + mtu = atoi(argv[2]); + if (argc > 3) + proto = atoi(argv[3]); + if (argc > 4) + queue_id = atoi(argv[4]); + Dev dev(addr, mtu, queue_id); IPIn ipin(addr, dev); struct msqid_ds minfo; for (msgctl(dev.que_id, IPC_STAT, &minfo); minfo.msg_qnum; @@ -20,8 +34,9 @@ int main() { IPAddr src, dst; std::cout << "Quedan " << minfo.msg_qnum << " mensajes en la cola\n"; - std::string s = ipin.recv(0, src, dst); - std::cout << "Recibido '" << s << "' (len " << s.size() << ")\n"; + std::string s = ipin.recv(proto, src, dst); + std::cout << "Recibido '" << s << "' (len " << s.size() << ") de " + << src << " para " << dst << " (proto = " << proto << ")\n"; } return 0; }