- error message for change password dialog
[public/netxms.git] / src / server / core / agent.cpp
CommitLineData
5039dede
AK
1/*
2** NetXMS - Network Management System
3** Copyright (C) 2006 Victor Kirhenshtein
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
19** File: agent.cpp
20**
21**/
22
23#include "nxcore.h"
24
25
26//
27// Destructor for extended agent connection class
28//
29
30AgentConnectionEx::~AgentConnectionEx()
31{
32}
33
34
35//
36// Trap processor
37//
38
39void AgentConnectionEx::OnTrap(CSCPMessage *pMsg)
40{
41 DWORD dwEventCode;
42 int i, iNumArgs;
43 Node *pNode;
44 TCHAR *pszArgList[32], szBuffer[32];
45 TCHAR szFormat[] = "ssssssssssssssssssssssssssssssss";
46
47 DbgPrintf(3, _T("Received trap message from agent at %s"), IpToStr(GetIpAddr(), szBuffer));
48 pNode = FindNodeByIP(GetIpAddr());
49 if (pNode != NULL)
50 {
51 dwEventCode = pMsg->GetVariableLong(VID_EVENT_CODE);
52 iNumArgs = (int)pMsg->GetVariableShort(VID_NUM_ARGS);
53 if (iNumArgs > 32)
54 iNumArgs = 32;
55 for(i = 0; i < iNumArgs; i++)
56 pszArgList[i] = pMsg->GetVariableStr(VID_EVENT_ARG_BASE + i);
57 DbgPrintf(3, _T("Event from trap: %d"), dwEventCode);
58
59 // Following call is not very good, but I'm too lazy now
60 // to change PostEvent()
61 szFormat[iNumArgs] = 0;
62 PostEvent(dwEventCode, pNode->Id(), (iNumArgs > 0) ? szFormat : NULL,
63 pszArgList[0], pszArgList[1], pszArgList[2], pszArgList[3],
64 pszArgList[4], pszArgList[5], pszArgList[6], pszArgList[7],
65 pszArgList[8], pszArgList[9], pszArgList[10], pszArgList[11],
66 pszArgList[12], pszArgList[13], pszArgList[14], pszArgList[15],
67 pszArgList[16], pszArgList[17], pszArgList[18], pszArgList[19],
68 pszArgList[20], pszArgList[21], pszArgList[22], pszArgList[23],
69 pszArgList[24], pszArgList[25], pszArgList[26], pszArgList[27],
70 pszArgList[28], pszArgList[29], pszArgList[30], pszArgList[31]);
71
72 // Cleanup
73 for(i = 0; i < iNumArgs; i++)
74 free(pszArgList[i]);
75 }
76 else
77 {
78 DbgPrintf(3, _T("Cannot find node for IP address %s"), IpToStr(GetIpAddr(), szBuffer));
79 }
80}