#include "ipin.h"
#include "ipaddr.h"
-#include "dev.h"
+#include "devque.h"
#include <iostream>
#include <cstdlib>
+#include <cassert>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
-// Uso: ./test_ipin ip mtu proto queue_id
+// Uso: ./test_ipin ip mtu router forward proto queue_id
int main(int argc, char* argv[])
{
IPAddr addr("10.10.10.1");
unsigned mtu = 25;
- unsigned proto = 0;
- key_t queue_id = DEV_DEFAULT_KEY;
+ bool router = false;
+ bool forward = false;
+ uint8_t proto = 0;
+ key_t queue_id = DEVQUE_DEFAULT_KEY;
if (argc > 1)
addr = IPAddr(argv[1]);
if (argc > 2)
mtu = atoi(argv[2]);
if (argc > 3)
- proto = atoi(argv[3]);
+ router = atoi(argv[3]);
if (argc > 4)
- queue_id = atoi(argv[4]);
- Dev dev(addr, mtu, queue_id);
- IPIn ipin(addr, dev);
+ forward = atoi(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);
+ DevQue dev(addr, mtu, queue_id);
+ que_id = msgget(queue_id+1, IPC_CREAT | 0666);
+ assert(que_id != -1);
+ DevQue fwque(addr, DEV_MAX_MTU, queue_id+1);
+ IPIn ipin(addr, dev, fwque, router, forward, std::cerr);
struct msqid_ds minfo;
for (msgctl(dev.que_id, IPC_STAT, &minfo); minfo.msg_qnum;
msgctl(dev.que_id, IPC_STAT, &minfo))