From: Martin Quinson Date: Fri, 23 Dec 2016 21:08:44 +0000 (+0100) Subject: clang-format these files, no change X-Git-Tag: v3_14~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3d7871258a01dc77c95cd4618034b8fd89bbd8d9 clang-format these files, no change --- diff --git a/src/surf/ns3/ns3_interface.h b/src/surf/ns3/ns3_interface.h index 215d6d8e1c..b9270f91f2 100644 --- a/src/surf/ns3/ns3_interface.h +++ b/src/surf/ns3/ns3_interface.h @@ -8,10 +8,10 @@ #include -namespace simgrid{ - namespace surf{ - class NetworkNS3Action; - } +namespace simgrid { +namespace surf { +class NetworkNS3Action; +} } class NetCardNs3 { @@ -24,13 +24,13 @@ public: SG_BEGIN_DECL() -XBT_PUBLIC(void) ns3_initialize(const char* TcpProtocol); +XBT_PUBLIC(void) ns3_initialize(const char* TcpProtocol); XBT_PUBLIC(void) ns3_create_flow(sg_host_t src, sg_host_t dst, double start, u_int32_t TotalBytes, simgrid::surf::NetworkNS3Action* action); -XBT_PUBLIC(void) ns3_simulator(double maxSeconds); -XBT_PUBLIC(void *) ns3_add_router(const char * id); -XBT_PUBLIC(void) ns3_add_link(int src, int dst, char * bw,char * lat); +XBT_PUBLIC(void) ns3_simulator(double maxSeconds); +XBT_PUBLIC(void*) ns3_add_router(const char* id); +XBT_PUBLIC(void) ns3_add_link(int src, int dst, char* bw, char* lat); XBT_PUBLIC(void) ns3_add_cluster(const char* id, char* bw, char* lat); SG_END_DECL() diff --git a/src/surf/ns3/ns3_simulator.cc b/src/surf/ns3/ns3_simulator.cc index e7b3382097..06bd569643 100644 --- a/src/surf/ns3/ns3_simulator.cc +++ b/src/surf/ns3/ns3_simulator.cc @@ -9,11 +9,12 @@ #include "xbt/log.h" #include "xbt/sysdep.h" -static void delete_mysocket(void *p) +static void delete_mysocket(void* p) { - delete (SgFlow *)p; + delete (SgFlow*)p; } -xbt_dict_t flowFromSock = xbt_dict_new_homogeneous(delete_mysocket);; // ns3::sock -> SgFlow +xbt_dict_t flowFromSock = xbt_dict_new_homogeneous(delete_mysocket); +; // ns3::sock -> SgFlow static void receive_callback(ns3::Ptr socket); static void send_callback(ns3::Ptr sock, uint32_t txSpace); @@ -21,20 +22,23 @@ static void datasent_callback(ns3::Ptr socket, uint32_t dataSent); XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3); -SgFlow::SgFlow(uint32_t totalBytes, simgrid::surf::NetworkNS3Action * action) { +SgFlow::SgFlow(uint32_t totalBytes, simgrid::surf::NetworkNS3Action* action) +{ totalBytes_ = totalBytes; - remaining_ = totalBytes; - action_ = action; + remaining_ = totalBytes; + action_ = action; } -static SgFlow* getFlowFromSocket(ns3::Ptr socket) { - return (SgFlow*)xbt_dict_get_or_null(flowFromSock, transformSocketPtr(socket)); +static SgFlow* getFlowFromSocket(ns3::Ptr socket) +{ + return (SgFlow*)xbt_dict_get_or_null(flowFromSock, transformSocketPtr(socket)); } -static void receive_callback(ns3::Ptr socket){ +static void receive_callback(ns3::Ptr socket) +{ SgFlow* flow = getFlowFromSocket(socket); - if (flow->finished_ == false){ + if (flow->finished_ == false) { flow->finished_ = true; XBT_DEBUG("recv_cb of F[%p, %p, %d]", flow, flow->action_, flow->totalBytes_); XBT_DEBUG("Stop simulator at %f seconds", ns3::Simulator::Now().GetSeconds()); @@ -43,72 +47,78 @@ static void receive_callback(ns3::Ptr socket){ } } -static void send_callback(ns3::Ptr sock, uint32_t txSpace){ - SgFlow* flow = getFlowFromSocket(sock); +static void send_callback(ns3::Ptr sock, uint32_t txSpace) +{ + SgFlow* flow = getFlowFromSocket(sock); - if (flow->remaining_ == 0) // all data was already buffered (and socket was already closed) - return; + if (flow->remaining_ == 0) // all data was already buffered (and socket was already closed) + return; - uint8_t *data = (uint8_t*)malloc(sizeof(uint8_t)*txSpace); + uint8_t* data = (uint8_t*)malloc(sizeof(uint8_t) * txSpace); - while (flow->bufferedBytes_ < flow->totalBytes_ && sock->GetTxAvailable () > 0) { + while (flow->bufferedBytes_ < flow->totalBytes_ && sock->GetTxAvailable() > 0) { - uint32_t toWrite = std::min ({flow->remaining_, txSpace, sock->GetTxAvailable ()}); - int amountSent = sock->Send (data, toWrite, 0); + uint32_t toWrite = std::min({flow->remaining_, txSpace, sock->GetTxAvailable()}); + int amountSent = sock->Send(data, toWrite, 0); - if(amountSent < 0) - return; - flow->bufferedBytes_ += amountSent; - flow->remaining_ -= amountSent; + if (amountSent < 0) + return; + flow->bufferedBytes_ += amountSent; + flow->remaining_ -= amountSent; - XBT_DEBUG("send_cb of F[%p, %p, %d] (%d/%d) %d buffered", flow, flow->action_, flow->totalBytes_, - flow->remaining_, flow->totalBytes_, amountSent); - } - free(data); + XBT_DEBUG("send_cb of F[%p, %p, %d] (%d/%d) %d buffered", flow, flow->action_, flow->totalBytes_, flow->remaining_, + flow->totalBytes_, amountSent); + } + free(data); - if ((flow->bufferedBytes_) >= flow->totalBytes_) - sock->Close(); + if ((flow->bufferedBytes_) >= flow->totalBytes_) + sock->Close(); } -static void datasent_callback(ns3::Ptr socket, uint32_t dataSent){ +static void datasent_callback(ns3::Ptr socket, uint32_t dataSent) +{ SgFlow* flow = getFlowFromSocket(socket); flow->sentBytes_ += dataSent; XBT_DEBUG("datasent_cb of F[%p, %p, %d] %d sent", flow, flow->action_, flow->totalBytes_, dataSent); } -static void normalClose_callback(ns3::Ptr socket){ +static void normalClose_callback(ns3::Ptr socket) +{ SgFlow* flow = getFlowFromSocket(socket); XBT_DEBUG("normalClose_cb of F[%p, %p, %d]", flow, flow->action_, flow->totalBytes_); - receive_callback (socket); + receive_callback(socket); } -static void errorClose_callback(ns3::Ptr socket){ +static void errorClose_callback(ns3::Ptr socket) +{ SgFlow* flow = getFlowFromSocket(socket); XBT_DEBUG("errorClose_cb of F[%p, %p, %d]", flow, flow->action_, flow->totalBytes_); xbt_die("NS3: a socket was closed anormally"); } -static void succeededConnect_callback(ns3::Ptr socket){ +static void succeededConnect_callback(ns3::Ptr socket) +{ SgFlow* flow = getFlowFromSocket(socket); XBT_DEBUG("succeededConnect_cb of F[%p, %p, %d]", flow, flow->action_, flow->totalBytes_); } -static void failedConnect_callback(ns3::Ptr socket){ +static void failedConnect_callback(ns3::Ptr socket) +{ SgFlow* mysocket = getFlowFromSocket(socket); XBT_DEBUG("failedConnect_cb of F[%p, %p, %d]", mysocket, mysocket->action_, mysocket->totalBytes_); xbt_die("NS3: a socket failed to connect"); } -void StartFlow(ns3::Ptr sock, const char *to, uint16_t port_number) +void StartFlow(ns3::Ptr sock, const char* to, uint16_t port_number) { - ns3::InetSocketAddress serverAddr (to, port_number); + ns3::InetSocketAddress serverAddr(to, port_number); sock->Connect(serverAddr); - sock->SetSendCallback (MakeCallback (&send_callback)); - sock->SetRecvCallback (MakeCallback (&receive_callback)); - sock->SetDataSentCallback (MakeCallback (&datasent_callback)); - sock->SetConnectCallback (MakeCallback (&succeededConnect_callback), MakeCallback (&failedConnect_callback)); - sock->SetCloseCallbacks (MakeCallback (&normalClose_callback), MakeCallback (&errorClose_callback)); + sock->SetSendCallback(MakeCallback(&send_callback)); + sock->SetRecvCallback(MakeCallback(&receive_callback)); + sock->SetDataSentCallback(MakeCallback(&datasent_callback)); + sock->SetConnectCallback(MakeCallback(&succeededConnect_callback), MakeCallback(&failedConnect_callback)); + sock->SetCloseCallbacks(MakeCallback(&normalClose_callback), MakeCallback(&errorClose_callback)); SgFlow* flow = getFlowFromSocket(sock); XBT_DEBUG("startFlow_cb of F[%p, %p, %d] dest=%s port=%d", flow, flow->action_, flow->totalBytes_, to, port_number); diff --git a/src/surf/ns3/ns3_simulator.h b/src/surf/ns3/ns3_simulator.h index 804863851b..2847a6037f 100644 --- a/src/surf/ns3/ns3_simulator.h +++ b/src/surf/ns3/ns3_simulator.h @@ -11,35 +11,35 @@ #include "ns3_interface.h" -#include #include +#include #include #include -#include #include +#include #include class SgFlow { public: - SgFlow(uint32_t totalBytes, simgrid::surf::NetworkNS3Action * action); + SgFlow(uint32_t totalBytes, simgrid::surf::NetworkNS3Action* action); -//private: + // private: std::uint32_t bufferedBytes_ = 0; - std::uint32_t sentBytes_ = 0; + std::uint32_t sentBytes_ = 0; std::uint32_t remaining_; std::uint32_t totalBytes_; bool finished_ = false; simgrid::surf::NetworkNS3Action* action_; }; -void StartFlow(ns3::Ptr sock, const char *to, uint16_t port_number); +void StartFlow(ns3::Ptr sock, const char* to, uint16_t port_number); -static inline const char *transformSocketPtr (ns3::Ptr localSocket) +static inline const char* transformSocketPtr(ns3::Ptr localSocket) { static char key[24]; std::stringstream sstream; - sstream << localSocket ; - snprintf(key,24,"%s",sstream.str().c_str()); + sstream << localSocket; + snprintf(key, 24, "%s", sstream.str().c_str()); return key; }