From: Maxim Mamontov Date: Thu, 1 Sep 2011 14:16:37 +0000 (+0300) Subject: Produce debug output only if SMUX_DEBUG is defined X-Git-Tag: 2.408-alpha^0 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/44378b3654976b893daa96f44cea9fcb62092209 Produce debug output only if SMUX_DEBUG is defined --- diff --git a/projects/stargazer/plugins/other/smux/handlers.cpp b/projects/stargazer/plugins/other/smux/handlers.cpp index 5f25a82f..7ceb2994 100644 --- a/projects/stargazer/plugins/other/smux/handlers.cpp +++ b/projects/stargazer/plugins/other/smux/handlers.cpp @@ -10,24 +10,40 @@ #include "utils.h" #include "smux.h" +#ifdef SMUX_DEBUG bool SMUX::CloseHandler(const SMUX_PDUs_t * pdus) { printfd(__FILE__, "SMUX::CloseHandler()\n"); asn_fprint(stderr, &asn_DEF_SMUX_PDUs, pdus); return false; } +#else +bool SMUX::CloseHandler(const SMUX_PDUs_t *) +{ +return false; +} +#endif +#ifdef SMUX_DEBUG bool SMUX::RegisterResponseHandler(const SMUX_PDUs_t * pdus) { printfd(__FILE__, "SMUX::RegisterResponseHandler()\n"); asn_fprint(stderr, &asn_DEF_SMUX_PDUs, pdus); return false; } +#else +bool SMUX::RegisterResponseHandler(const SMUX_PDUs_t *) +{ +return false; +} +#endif bool SMUX::PDUsRequestHandler(const SMUX_PDUs_t * pdus) { +#ifdef SMUX_DEBUG printfd(__FILE__, "SMUX::PDUsRequestHandler()\n"); asn_fprint(stderr, &asn_DEF_SMUX_PDUs, pdus); +#endif PDUsHandlers::iterator it; it = pdusHandlers.find(pdus->choice.pdus.present); if (it != pdusHandlers.end()) @@ -36,6 +52,7 @@ if (it != pdusHandlers.end()) } else { +#ifdef SMUX_DEBUG switch (pdus->present) { case PDUs_PR_NOTHING: @@ -50,21 +67,31 @@ else default: printfd(__FILE__, "SMUX::PDUsRequestHandler() - undefined\n"); } +#endif } return false; } +#ifdef SMUX_DEBUG bool SMUX::CommitOrRollbackHandler(const SMUX_PDUs_t * pdus) { printfd(__FILE__, "SMUX::CommitOrRollbackHandler()\n"); asn_fprint(stderr, &asn_DEF_SMUX_PDUs, pdus); return false; } +#else +bool SMUX::CommitOrRollbackHandler(const SMUX_PDUs_t *) +{ +return false; +} +#endif bool SMUX::GetRequestHandler(const PDUs_t * pdus) { +#ifdef SMUX_DEBUG printfd(__FILE__, "SMUX::GetRequestHandler()\n"); asn_fprint(stderr, &asn_DEF_PDUs, pdus); +#endif const GetRequest_PDU_t * getRequest = &pdus->choice.get_request; GetResponse_PDU_t * msg = static_cast(calloc(1, sizeof(GetResponse_PDU_t))); assert(msg && "Enought mempry to allocate GetResponse_PDU_t"); @@ -99,15 +126,19 @@ for (int i = 0; i < vbl->list.count; ++i) } SendGetResponsePDU(sock, msg); +#ifdef SMUX_DEBUG asn_fprint(stderr, &asn_DEF_GetResponse_PDU, msg); +#endif ASN_STRUCT_FREE(asn_DEF_GetResponse_PDU, msg); return false; } bool SMUX::GetNextRequestHandler(const PDUs_t * pdus) { +#ifdef SMUX_DEBUG printfd(__FILE__, "SMUX::GetNextRequestHandler()\n"); asn_fprint(stderr, &asn_DEF_PDUs, pdus); +#endif const GetRequest_PDU_t * getRequest = &pdus->choice.get_request; GetResponse_PDU_t * msg = static_cast(calloc(1, sizeof(GetResponse_PDU_t))); assert(msg && "Enought mempry to allocate GetResponse_PDU_t"); @@ -127,7 +158,9 @@ for (int i = 0; i < vbl->list.count; ++i) it = sensors.upper_bound(OID(&vb->name)); if (it == sensors.end()) { +#ifdef SMUX_DEBUG printfd(__FILE__, "SMUX::GetNextRequestHandler() - '%s' not found\n", OID(&vb->name).ToString().c_str()); +#endif SendGetResponseErrorPDU(sock, getRequest, PDU__error_status_noSuchName, i); return true; @@ -143,15 +176,19 @@ for (int i = 0; i < vbl->list.count; ++i) } SendGetResponsePDU(sock, msg); +#ifdef SMUX_DEBUG asn_fprint(stderr, &asn_DEF_PDU, msg); +#endif ASN_STRUCT_FREE(asn_DEF_GetResponse_PDU, msg); return false; } bool SMUX::SetRequestHandler(const PDUs_t * pdus) { +#ifdef SMUX_DEBUG printfd(__FILE__, "SMUX::SetRequestHandler()\n"); asn_fprint(stderr, &asn_DEF_PDUs, pdus); +#endif SendGetResponseErrorPDU(sock, &pdus->choice.set_request, PDU__error_status_readOnly, 0); return false; diff --git a/projects/stargazer/plugins/other/smux/smux.cpp b/projects/stargazer/plugins/other/smux/smux.cpp index cc69aa81..fc45fe04 100644 --- a/projects/stargazer/plugins/other/smux/smux.cpp +++ b/projects/stargazer/plugins/other/smux/smux.cpp @@ -16,12 +16,6 @@ #include "stg/common.h" #include "stg/plugin_creator.h" -/*#include "stg/users.h" -#include "stg/tariffs.h" -#include "stg/admins.h" -#include "stg/services.h" -#include "stg/corporations.h" -#include "stg/traffcounter.h"*/ #include "smux.h" #include "utils.h" @@ -163,12 +157,12 @@ sensors[OID(".1.3.6.1.4.1.38313.1.1.2")] = new ConnectedUsersSensor(*users); sensors[OID(".1.3.6.1.4.1.38313.1.1.3")] = new AuthorizedUsersSensor(*users); sensors[OID(".1.3.6.1.4.1.38313.1.1.4")] = new AlwaysOnlineUsersSensor(*users); sensors[OID(".1.3.6.1.4.1.38313.1.1.5")] = new NoCashUsersSensor(*users); -sensors[OID(".1.3.6.1.4.1.38313.1.1.7")] = new DisabledDetailStatsUsersSensor(*users); -sensors[OID(".1.3.6.1.4.1.38313.1.1.8")] = new DisabledUsersSensor(*users); -sensors[OID(".1.3.6.1.4.1.38313.1.1.9")] = new PassiveUsersSensor(*users); -sensors[OID(".1.3.6.1.4.1.38313.1.1.10")] = new CreditUsersSensor(*users); -sensors[OID(".1.3.6.1.4.1.38313.1.1.11")] = new FreeMbUsersSensor(*users); -sensors[OID(".1.3.6.1.4.1.38313.1.1.12")] = new TariffChangeUsersSensor(*users); +sensors[OID(".1.3.6.1.4.1.38313.1.1.6")] = new DisabledDetailStatsUsersSensor(*users); +sensors[OID(".1.3.6.1.4.1.38313.1.1.7")] = new DisabledUsersSensor(*users); +sensors[OID(".1.3.6.1.4.1.38313.1.1.8")] = new PassiveUsersSensor(*users); +sensors[OID(".1.3.6.1.4.1.38313.1.1.9")] = new CreditUsersSensor(*users); +sensors[OID(".1.3.6.1.4.1.38313.1.1.10")] = new FreeMbUsersSensor(*users); +sensors[OID(".1.3.6.1.4.1.38313.1.1.11")] = new TariffChangeUsersSensor(*users); // Tariffs sensors[OID(".1.3.6.1.4.1.38313.1.2.1")] = new TotalTariffsSensor(*tariffs); // Admins @@ -181,12 +175,12 @@ sensors[OID(".1.3.6.1.4.1.38313.1.5.1")] = new TotalCorporationsSensor(*corporat sensors[OID(".1.3.6.1.4.1.38313.1.6.1")] = new TotalRulesSensor(*traffcounter); // Table data -tables[".1.3.6.1.4.1.38313.1.1.6"] = new TariffUsersTable(".1.3.6.1.4.1.38313.1.1.6", *tariffs, *users); +tables[".1.3.6.1.4.1.38313.1.2.2"] = new TariffUsersTable(".1.3.6.1.4.1.38313.1.2.2", *tariffs, *users); UpdateTables(); SetNotifiers(); -#ifdef DEBUG +#ifdef SMUX_DEBUG Sensors::const_iterator it(sensors.begin()); while (it != sensors.end()) { @@ -319,6 +313,7 @@ if (it != smuxHandlers.end()) } else { +#ifdef SMUX_DEBUG switch (pdus->present) { case SMUX_PDUs_PR_NOTHING: @@ -334,6 +329,7 @@ else printfd(__FILE__, "PDUs: undefined\n"); } asn_fprint(stderr, &asn_DEF_SMUX_PDUs, pdus); +#endif } return false; } diff --git a/projects/stargazer/plugins/other/smux/utils.cpp b/projects/stargazer/plugins/other/smux/utils.cpp index ff7bb590..8d3988eb 100644 --- a/projects/stargazer/plugins/other/smux/utils.cpp +++ b/projects/stargazer/plugins/other/smux/utils.cpp @@ -44,7 +44,6 @@ if (left < str.length()) } arcs[arcPos++] = arc; } -printfd(__FILE__, "String2OI() - arcPos: %d\n", arcPos); OBJECT_IDENTIFIER_set_arcs(oi, arcs, sizeof(arcs[0]), arcPos); return true; } @@ -103,8 +102,6 @@ if (error.encoded == -1) else { write(fd, buffer, error.encoded); - printfd(__FILE__, "OpenPDU encoded successfully to %d bytes\n", - error.encoded); } return true; } @@ -132,7 +129,6 @@ if (error.encoded == -1) else { write(fd, buffer, error.encoded); - printfd(__FILE__, "ClosePDU encoded successfully\n"); } return 0; } @@ -166,8 +162,6 @@ if (error.encoded == -1) else { write(fd, buffer, error.encoded); - printfd(__FILE__, "RReqPDU encoded successfully to %d bytes\n", - error.encoded); } return 0; } @@ -211,8 +205,6 @@ if (error.encoded == -1) else { write(fd, buffer, error.encoded); - printfd(__FILE__, "GetResponsePDU encoded successfully to %d bytes\n", - error.encoded); } return 0; } @@ -248,9 +240,6 @@ if (error.encoded == -1) else { write(fd, buffer, error.encoded); - printfd(__FILE__, - "GetResponsePDU for error encoded successfully to %d bytes\n", - error.encoded); } return 0; }