- Dev dev(addr);
- IPOut ipout(addr, dev);
- if (ipout.send("hola mundo", addr, dst, 0))
- std::cout << "Enviado 'hola mundo' a 10.10.10.1\n";
- else
- std::cout << "NO SE PUDO ENVIAR 'hola mundo' a 10.10.10.1\n";
+ unsigned mtu = 25;
+ unsigned proto = 0;
+ key_t queue_id = DEV_DEFAULT_KEY;
+ std::string fname = "route.txt";
+ if (argc > 1)
+ addr = IPAddr(argv[1]);
+ if (argc > 2)
+ dst = IPAddr(argv[2]);
+ if (argc > 3)
+ mtu = atoi(argv[3]);
+ if (argc > 4)
+ fname = argv[4];
+ if (argc > 5)
+ proto = atoi(argv[5]);
+ if (argc > 6)
+ queue_id = atoi(argv[6]);
+ int que_id = msgget(queue_id, IPC_CREAT | 0666); assert(que_id != -1);
+ que_id = msgget(queue_id+1, IPC_CREAT | 0666); assert(que_id != -1);
+ std::ifstream ifs(fname.c_str()); assert(ifs);
+ Dev dev(addr, mtu, queue_id);
+ Dev fwque(addr, DEV_MAX_MTU, queue_id+1);
+ RouteTable table(dev);
+ add_routes(table, ifs, dev);
+ IPOut ipout(addr, table, fwque, std::cerr);
+ std::string msg;
+ while (std::getline(std::cin, msg))
+ {
+ if (ipout.send(msg, proto, dst))
+ std::cout << "Enviado '" << msg << "' a " << dst << "\n";
+ else
+ std::cout << "NO SE PUDO ENVIAR '" << msg << "' a " << dst << "\n";
+ }