Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Development
  3. problem with development

problem with development

Scheduled Pinned Locked Moved Development
20 Posts 2 Posters 56.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V
    V
    Victor Kirhenshtein
    wrote on last edited by
    #11

    Yes, it could be encrypted, and in that case you should provide correct encryption context. However, if you are not using encryption, you can simple pass NULL.

    Best regards,
    Victor

    1 Reply Last reply
    0
    • O
      O
      ophelie6989
      wrote on last edited by
      #12

      Thank you, i am going to use the fonction SendFileOverNXCP to send a message to the agent and RecvNXCPMessage to receive a message from the agent.

      1 Reply Last reply
      0
      • O
        O
        ophelie6989
        wrote on last edited by
        #13

        In fact i am not sure that the fonction SendFileOverNXCP is used to send a message to the agent.

        • How can i do to send a message to the agent and to receive it? I have used RecvNXCPMessage but i dont arrive to see the message sent by the agent.
        • What are the steps for the sending and the reception of message?

        Thank you very much

        1 Reply Last reply
        0
        • V
          V
          Victor Kirhenshtein
          wrote on last edited by
          #14

          In general, steps are following:

          1. create CSCPMessage object
          2. fill it with necessary variables and set correct command code
          3. create raw message (CSCP_MESSAGE) vith CSCPMessage::CreateMessage method
          4. send raw message to agent as usual
          5. receive response using RecvNXCPMessage function
          6. create CSCPMessage object from received raw message
          7. read variables from message object

          Best regards,
          Victor

          1 Reply Last reply
          0
          • O
            O
            ophelie6989
            wrote on last edited by
            #15

            Thank you, it was what i had done. I have send to the Agent the code 0x0097 in order to get the server informations. But which variable did i have to read from the message object for having the information about the server?

            Thank you very much

            1 Reply Last reply
            0
            • V
              V
              Victor Kirhenshtein
              wrote on last edited by
              #16

              You don't need command 0x0097 to read information from agent. You should use CMD_GET_PARAMETER (0x0041) and set name of the parameter to variable VID_PARAMETER (85). Agent will reply with command CMD_REQUEST_COMPLETED (0x001D). First, check variable VID_RCC (28). If it contains 0, then value of requested parameter will be in variable VID_VALUE (21). For example:

              CSCPMessage msg;

              msg.SetCode(CMD_GET_PARAMETER);
              msg.SetId(requestId);
              msg.SetVariable(VID_PARAMETER, "Agent.Version");

              <send message and get response into CSCPMessage *response>

              DWORD rcc = response->GetVariableLong(VID_RCC);
              if (rcc == ERR_SUCCESS)
              {
                char buffer[256];
                response->GetVariableStr(VID_VALUE, buffer, 256);
                // Now buffer contains value of requested parameter
              }

              Best regards,
              Victor

              1 Reply Last reply
              0
              • O
                O
                ophelie6989
                wrote on last edited by
                #17

                Thank you, i have tried what you told me. For the reception of a message from the agent i have done that:

                CSCPMessage *pMsg2=new CSCPMessage(); //classe
                  CSCP_MESSAGE *pRawMsg2;//structure
                  CSCP_BUFFER *pMsgBuffer;//structure buffer
                 
                  int iErr;
                  TCHAR szBuffer[128];

                 
                  // Initialize raw message receiving function
                  pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
                  RecvNXCPMessage(socketId, pRawMsg2, pMsgBuffer, RECEIVER_BUFFER_SIZE,0,0,0);
                 
                  // Allocate space for raw message
                  pRawMsg2 = (CSCP_MESSAGE *)malloc(RECEIVER_BUFFER_SIZE);
                  pMsg2 = new CSCPMessage(pRawMsg2);
                 
                 
                  DWORD rcc = pMsg2->GetVariableLong(VID_RCC);
                 
                  if (rcc == ERR_SUCCESS)
                    {
                   
                    char buffer[256];
                   
                      pMsg2->GetVariableStr(VID_VALUE, buffer, 256);
                      // Now buffer contains value of requested parameter
                     
                    int compteur;
                        for(compteur=0;compteur<256;compteur++)
                        {
                     
                                     printf("%c\n",buffer[compteur]);
                     
                                }//fin du for
                     
                     
                    }// fin if

                But i always don t managed to read informations. I have done a prinft  to see what informations are in the buffer but when i compiled nothing appeared in the buffer.
                What do i have to do in order to see the informations that i received from the Agent

                1 Reply Last reply
                0
                • V
                  V
                  Victor Kirhenshtein
                  wrote on last edited by
                  #18

                  You have missed code for actual message reception. Instead of

                  // Initialize raw message receiving function
                  pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
                  RecvNXCPMessage(socketId, pRawMsg2, pMsgBuffer, RECEIVER_BUFFER_SIZE,0,0,0);
                  
                  // Allocate space for raw message
                  pRawMsg2 = (CSCP_MESSAGE *)malloc(RECEIVER_BUFFER_SIZE);
                  pMsg2 = new CSCPMessage(pRawMsg2);
                  

                  you should have something like

                  // Initialize raw message receiving function
                  pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
                  RecvNXCPMessage(0, NULL, pMsgBuffer, RECEIVER_BUFFER_SIZE,0,0,0);
                  
                  CSCP_ENCRYPTION_CONTEXT *nullContext = NULL;
                  pRawMsg2 = (CSCP_MESSAGE *)malloc(RECEIVER_BUFFER_SIZE);
                  RecvNXCPMessage(socketId, pRawMsg2, pMsgBuffer, RECEIVER_BUFFER_SIZE,&nullContext,NULL,0);
                  pMsg2 = new CSCPMessage(pRawMsg2);
                  

                  Best regards,
                  Victor

                  1 Reply Last reply
                  0
                  • O
                    O
                    ophelie6989
                    wrote on last edited by
                    #19

                    Hi, thank you and Happy New Year!!
                    I have done what you said to me but the message send from the agent didn t work again.

                    I have that:
                    -----------Envoi du message a l agent-----------
                    code du message : A

                    -----------Reception du message de l agent-----------
                    ¨

                    When i send CMD_GETPAREMETER, i receive ".." with the code that i show you previously.

                    How can i do to see the parameters?

                    Thank you again

                    1 Reply Last reply
                    0
                    • V
                      V
                      Victor Kirhenshtein
                      wrote on last edited by
                      #20

                      Hello!

                      Did you set VID_PARAMETER variable before sending CMD_GET_PARAMETER request? You should have something like

                      msg.SetVariable(VID_PARAMETER, "Agent.Version");

                      before converting message into binary format and sending. Also, check VID_RCC variable in response message - may be it contains error.

                      Best regards,
                      Victor

                      1 Reply Last reply
                      0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      Powered by NodeBB Contributors
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups