]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/smux/handlers.cpp
Fix compilation errors got after API changes
[stg.git] / projects / stargazer / plugins / other / smux / handlers.cpp
index 5a8c917d7a5c01927faaa56ca92ed84420399af4..b2292bda2cf6bffc6aef903b0918b5963af13a07 100644 (file)
@@ -1,25 +1,13 @@
-#include "asn1/OpenPDU.h"
-#include "asn1/ClosePDU.h"
-#include "asn1/RReqPDU.h"
-#include "asn1/GetRequest-PDU.h"
-#include "asn1/GetResponse-PDU.h"
-#include "asn1/VarBindList.h"
-#include "asn1/VarBind.h"
-#include "asn1/OBJECT_IDENTIFIER.h"
-#include "asn1/ber_decoder.h"
-#include "asn1/der_encoder.h"
+#include "stg/GetRequest-PDU.h"
+#include "stg/GetResponse-PDU.h"
+#include "stg/VarBindList.h"
+#include "stg/VarBind.h"
 
 #include "stg/common.h"
 
+#include "utils.h"
 #include "smux.h"
 
-std::string OI2String(OBJECT_IDENTIFIER_t * oi);
-int SendGetResponsePDU(int fd, GetResponse_PDU_t * getResponse);
-int SendGetResponseErrorPDU(int fd,
-                            const PDU_t * getRequest,
-                            int errorStatus,
-                            int errorIndex);
-
 bool SMUX::CloseHandler(const SMUX_PDUs_t * pdus)
 {
 printfd(__FILE__, "SMUX::CloseHandler()\n");
@@ -89,7 +77,7 @@ for (int i = 0; i < vbl->list.count; ++i)
     {
     VarBind_t * vb = getRequest->variable_bindings.list.array[i];
     Sensors::iterator it;
-    it = sensors.find(OI2String(&vb->name));
+    it = sensors.find(OID(&vb->name));
     if (it == sensors.end())
         {
         SendGetResponseErrorPDU(sock, getRequest,
@@ -129,7 +117,7 @@ for (int i = 0; i < vbl->list.count; ++i)
     {
     VarBind_t * vb = getRequest->variable_bindings.list.array[i];
     Sensors::iterator it;
-    it = sensors.upper_bound(OI2String(&vb->name));
+    it = sensors.upper_bound(OID(&vb->name));
     if (it == sensors.end())
         {
         SendGetResponseErrorPDU(sock, getRequest,
@@ -140,7 +128,7 @@ for (int i = 0; i < vbl->list.count; ++i)
     VarBind_t newVb;
     memset(&newVb, 0, sizeof(newVb));
 
-    newVb.name = vb->name;
+    it->first.ToOID(&newVb.name);
     it->second->GetValue(&newVb.value);
 
     ASN_SEQUENCE_ADD(varBindList, &newVb);
@@ -159,81 +147,3 @@ SendGetResponseErrorPDU(sock, &pdus->choice.set_request,
                         PDU__error_status_readOnly, 0);
 return false;
 }
-
-std::string OI2String(OBJECT_IDENTIFIER_t * oi)
-{
-std::string res;
-
-int arcs[1024];
-int count = OBJECT_IDENTIFIER_get_arcs(oi, arcs, sizeof(arcs[0]), 1024);
-
-if (count > 1024)
-    return "";
-
-for (int i = 0; i < count; ++i)
-    {
-    res += ".";
-    std::string arc;
-    strprintf(&arc, "%d", arcs[i]);
-    res += arc;
-    }
-
-return res;
-}
-
-int SendGetResponsePDU(int fd, GetResponse_PDU_t * getResponse)
-{
-asn_enc_rval_t error;
-
-char buffer[1024];
-error = der_encode_to_buffer(&asn_DEF_GetResponse_PDU, getResponse, buffer,
-                             sizeof(buffer));
-
-if (error.encoded == -1)
-    {
-    printfd(__FILE__, "Could not encode GetResponsePDU (at %s)\n",
-            error.failed_type ? error.failed_type->name : "unknown");
-    return -1;
-    }
-else
-    {
-    write(fd, buffer, error.encoded);
-    printfd(__FILE__, "GetResponsePDU encoded successfully to %d bytes\n",
-            error.encoded);
-    }
-return 0;
-}
-
-int SendGetResponseErrorPDU(int fd,
-                            const PDU_t * getRequest,
-                            int errorStatus,
-                            int errorIndex)
-{
-asn_enc_rval_t error;
-GetResponse_PDU_t msg;
-
-memset(&msg, 0, sizeof(msg));
-
-msg.request_id = getRequest->request_id;
-asn_long2INTEGER(&msg.error_status, errorStatus);
-asn_long2INTEGER(&msg.error_index, errorIndex);
-
-char buffer[1024];
-error = der_encode_to_buffer(&asn_DEF_GetResponse_PDU, &msg, buffer,
-                             sizeof(buffer));
-
-if (error.encoded == -1)
-    {
-    printfd(__FILE__, "Could not encode GetResponsePDU for error (at %s)\n",
-            error.failed_type ? error.failed_type->name : "unknown");
-    return -1;
-    }
-else
-    {
-    write(fd, buffer, error.encoded);
-    printfd(__FILE__,
-            "GetResponsePDU for error encoded successfully to %d bytes\n",
-            error.encoded);
-    }
-return 0;
-}