Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Use the pointers to simgrid::Host instead of looking by name
[simgrid.git] / src / surf / ns3 / ns3_interface.h
index db6b193..8043743 100644 (file)
@@ -12,6 +12,9 @@
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 
+#include <simgrid/host.h>
+#include <surf/surf_routing.h>
+
 typedef enum {
   NS3_NETWORK_ELEMENT_NULL = 0,    /* NULL */
   NS3_NETWORK_ELEMENT_HOST,      /* host type */
@@ -40,11 +43,21 @@ XBT_PUBLIC(void *) ns3_add_host(const char * id);
 XBT_PUBLIC(void *) ns3_add_host_cluster(const char * id);
 XBT_PUBLIC(void *) ns3_add_router(const char * id);
 XBT_PUBLIC(void *) ns3_add_AS(const char * id);
-XBT_PUBLIC(void *) ns3_add_link(int src, e_ns3_network_element_type_t type_src,
+XBT_PUBLIC(void) ns3_add_link(int src, e_ns3_network_element_type_t type_src,
                 int dst, e_ns3_network_element_type_t type_dst,
                 char * bw,char * lat);
-XBT_PUBLIC(void *) ns3_end_platform(void);
-XBT_PUBLIC(void *) ns3_add_cluster(char * bw,char * lat,const char *id);
+XBT_PUBLIC(void) ns3_end_platform(void);
+XBT_PUBLIC(void) ns3_add_cluster(char * bw,char * lat,const char *id);
+
+XBT_INLINE
+ns3_nodes_t ns3_find_host(const char* id)
+{
+  sg_host_t host = sg_host_by_name(id);
+  if (host == nullptr)
+    return nullptr;
+  else
+    return (ns3_nodes_t) sg_host_get_facet(host, NS3_HOST_LEVEL);
+}
 
 SG_END_DECL()