10 #include <sys/types.h>
14 // Uso: ./test_ipin ip mtu router forward proto queue_id
16 int main(int argc, char* argv[])
18 IPAddr addr("10.10.10.1");
23 key_t queue_id = DEVQUE_DEFAULT_KEY;
25 addr = IPAddr(argv[1]);
29 router = atoi(argv[3]);
31 forward = atoi(argv[4]);
33 proto = atoi(argv[5]);
35 queue_id = atoi(argv[6]);
36 int que_id = msgget(queue_id, IPC_CREAT | 0666);
38 DevQue dev(addr, mtu, queue_id);
39 que_id = msgget(queue_id+1, IPC_CREAT | 0666);
41 DevQue fwque(addr, DEV_MAX_MTU, queue_id+1);
42 IPIn ipin(addr, dev, fwque, router, forward, std::cerr);
43 struct msqid_ds minfo;
44 for (msgctl(dev.que_id, IPC_STAT, &minfo); minfo.msg_qnum;
45 msgctl(dev.que_id, IPC_STAT, &minfo))
48 std::cout << "Quedan " << minfo.msg_qnum << " mensajes en la cola\n";
49 std::string s = ipin.recv(proto, src, dst);
50 std::cout << "Recibido '" << s << "' (len " << s.size() << ") de "
51 << src << " para " << dst << " (proto = " << proto << ")\n";
56 // vim: set et sw=4 sts=4 :