13 // Uso: ./test_ipin ip mtu router forward proto queue_id
15 int main(int argc, char* argv[])
17 IPAddr addr("10.10.10.1");
22 key_t queue_id = DEV_DEFAULT_KEY;
24 addr = IPAddr(argv[1]);
28 router = atoi(argv[3]);
30 forward = atoi(argv[4]);
32 proto = atoi(argv[5]);
34 queue_id = atoi(argv[6]);
35 int que_id = msgget(queue_id, IPC_CREAT | 0666);
37 Dev dev(addr, mtu, queue_id);
38 que_id = msgget(queue_id+1, IPC_CREAT | 0666);
40 Dev fwque(addr, DEV_MAX_MTU, queue_id+1);
41 IPIn ipin(addr, dev, fwque, router, forward, std::cerr);
42 struct msqid_ds minfo;
43 for (msgctl(dev.que_id, IPC_STAT, &minfo); minfo.msg_qnum;
44 msgctl(dev.que_id, IPC_STAT, &minfo))
47 std::cout << "Quedan " << minfo.msg_qnum << " mensajes en la cola\n";
48 std::string s = ipin.recv(proto, src, dst);
49 std::cout << "Recibido '" << s << "' (len " << s.size() << ") de "
50 << src << " para " << dst << " (proto = " << proto << ")\n";
55 // vim: set et sw=4 sts=4 :