Hi,

This patch adds a PROMISC option to fromsimdevice.cc. It will be soon required for full Click support in ns-3.

Thanks
Ruben
>From d6686ee698661840b74ee7eb6dab1749124032f6 Mon Sep 17 00:00:00 2001
From: Ruben Merz <[email protected]>
Date: Thu, 26 May 2011 22:44:29 +0200
Subject: [PATCH] Add PROMISC option for FromSimDevice

Signed-off-by: Ruben Merz <[email protected]>
---
 elements/ns/fromsimdevice.cc |    6 ++++++
 elements/ns/fromsimdevice.hh |    1 +
 include/click/router.hh      |    1 +
 include/click/simclick.h     |    1 +
 lib/router.cc                |    5 +++++
 5 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/elements/ns/fromsimdevice.cc b/elements/ns/fromsimdevice.cc
index 34029e4..4e7a68b 100644
--- a/elements/ns/fromsimdevice.cc
+++ b/elements/ns/fromsimdevice.cc
@@ -61,9 +61,11 @@ int
 FromSimDevice::configure(Vector<String> &conf, ErrorHandler *errh)
 {
   _packetbuf_size = 2048;
+  _promisc = false;
   if (Args(conf, this, errh)
       .read_mp("DEVNAME", _ifname)
       .read_mp("SNAPLEN", _packetbuf_size)
+      .read_mp("PROMISC", _promisc)
       .complete() < 0)
     return -1;
   if (_packetbuf_size > 8192 || _packetbuf_size < 128)
@@ -91,6 +93,10 @@ FromSimDevice::initialize(ErrorHandler *errh)
   // Request that we get packets sent to us from the simulator
   myrouter->sim_listen(_fd,eindex());
 
+  // Set the promisc mode on the interface
+  if (_promisc) {
+    myrouter->sim_if_promisc(_fd);
+  }
   return 0;
 }
 
diff --git a/elements/ns/fromsimdevice.hh b/elements/ns/fromsimdevice.hh
index 2171708..3f27841 100644
--- a/elements/ns/fromsimdevice.hh
+++ b/elements/ns/fromsimdevice.hh
@@ -51,6 +51,7 @@ class FromSimDevice : public Element {
   int _packetbuf_size;
   int _fd;
   unsigned char *_packetbuf;
+  bool _promisc;
 
   static void set_annotations(Packet *,int ptype);
   // set appropriate annotations, i.e. MAC packet type.
diff --git a/include/click/router.hh b/include/click/router.hh
index 016fb34..ea3e403 100644
--- a/include/click/router.hh
+++ b/include/click/router.hh
@@ -202,6 +202,7 @@ class Router { public:
     void sim_trace(const char* event);
     int sim_get_node_id();
     int sim_get_next_pkt_id();
+    int sim_if_promisc(int ifid);
 
   protected:
     Vector<Vector<int> *> _listenvecs;
diff --git a/include/click/simclick.h b/include/click/simclick.h
index cf43293..bb28f54 100644
--- a/include/click/simclick.h
+++ b/include/click/simclick.h
@@ -104,6 +104,7 @@ int simclick_gettimeofday(struct timeval* tv);
 #define SIMCLICK_GET_NODE_ID           9  // none
 #define SIMCLICK_GET_NEXT_PKT_ID       10 // none
 #define SIMCLICK_CHANGE_CHANNEL                11 // int ifid, int channelid
+#define SIMCLICK_IF_PROMISC            12 // int ifid
 
 int simclick_sim_command(simclick_node_t *sim, int cmd, ...);
 int simclick_click_command(simclick_node_t *sim, int cmd, ...);
diff --git a/lib/router.cc b/lib/router.cc
index ac48f22..478df72 100644
--- a/lib/router.cc
+++ b/lib/router.cc
@@ -2352,6 +2352,11 @@ Router::sim_get_next_pkt_id() {
     return simclick_sim_command(_master->simnode(), SIMCLICK_GET_NEXT_PKT_ID);
 }
 
+int
+Router::sim_if_promisc(int ifid) {
+    return simclick_sim_command(_master->simnode(), SIMCLICK_IF_PROMISC, ifid);
+}
+
 #endif // CLICK_NS
 
 CLICK_ENDDECLS
-- 
1.7.0.4

_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click

Reply via email to