summaryrefslogtreecommitdiff
path: root/polux/application/agent/src/systemmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polux/application/agent/src/systemmanager.cpp')
-rwxr-xr-xpolux/application/agent/src/systemmanager.cpp2788
1 files changed, 2788 insertions, 0 deletions
diff --git a/polux/application/agent/src/systemmanager.cpp b/polux/application/agent/src/systemmanager.cpp
new file mode 100755
index 0000000000..43a05419d6
--- /dev/null
+++ b/polux/application/agent/src/systemmanager.cpp
@@ -0,0 +1,2788 @@
+/*
+ ****************************************************************************
+ * PROGRAM MODULE
+ *
+ * $Workfile: systemmanager.cpp $
+ * $Author: paris $
+ * $Date: 2007/11/22 14:37:49 $
+ *
+ * Copyright (C) 2004 by SPiDCOM Technologies All rights reserved.
+ *
+ ****************************************************************************
+ */
+
+#include <malloc.h>
+
+#include <iostream>
+using namespace std;
+
+#include "agent_pp/system_group.h"
+
+#include "mib-common.h"
+#include "systemmanager.h"
+#include "mib-interface.h"
+
+#include "if_mib.h"
+#include "ip_mib.h"
+#include "mau_mib.h"
+#include "spc200.h"
+#include "radius_auth_client_mib.h"
+
+#include "spidcom_alarm_mib.h"
+#include "agent_pp/snmp_notification_mib.h"
+#include "agent_pp/snmp_target_mib.h"
+#include "spidcom_traps.h"
+
+#include "nscrtv_eponeoc_property_mib.h"
+#include "nscrtv_eponeoc_alarms_mib.h"
+#include "nscrtv_eponeoc_common_mib.h"
+
+#include "spidcom_eoc_mib.h"
+
+#ifdef STUB_TEST
+#include "Stub.h"
+#endif // STUB_TEST
+
+#include "sm_agent_log_entry.h"
+
+#define LOG_SYSTEM_MANAGER_BEGIN(x) LOG_BEGIN(x);LOG("SystemManager");
+
+//link to initialize all customised Mibs
+extern int InitAllCustomMibs(Mib& mib);
+
+
+
+/**
+ * SystemManager
+ *
+ * Singleton implementation in order to manage the current
+ * System information
+ */
+
+SystemManager* SystemManager::m_instance_p = 0;
+
+SystemManager::SystemManager()
+ : ThreadManager(),
+ m_isInit( true ),
+ m_topoChanges(0),
+ m_nbSofts(1)
+{
+//PR18 BEGIN
+#if 0
+ sprintf(m_plcsystem.sysname,"Undefined System Name");
+
+ m_plcmac.ipGroup.ipNetToMediaType=IP_MIB_IPNETTOMEDIATYPE_STATIC; //PR08
+ m_plcmac.ipGroup.ipAdEntAddr=0x7F000000; //PR08
+ m_plcmac.ipGroup.ipAdEntNetMask=0xFFFFFFFF; //PR08
+ m_plcmac.ipGateway=0x0A000001; //PR16
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[0] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[1] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[2] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[3] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[4] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[5] = (char)255;
+
+ m_plcmac.mode = 0; //PR04 //PR50
+ m_plcmac.nb_hosts = 0; //PR05
+
+ m_plccac.inPackets = 0;
+ m_plccac.inPacketsError = 0;
+ m_plccac.outPackets = 0;
+ m_plccac.outPacketsError = 0;
+
+
+ m_ethmac.ipGroup.ipNetToMediaType=IP_MIB_IPNETTOMEDIATYPE_STATIC; //PR08
+ m_ethmac.ipGroup.ipAdEntAddr=0x7F000000;
+ m_ethmac.ipGroup.ipAdEntNetMask=0xFFFFFFFF; //PR08
+ m_ethmac.ipGateway=0x0A000002; //PR16
+
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[0] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[1] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[2] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[3] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[4] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[5] = (char)255;
+
+
+ m_ethmac.ifGeneralInformationGroup.ifHighSpeed = 1000000 * m_underlayer->getEthSpeed();
+// m_ethmac.mode=ETH_FULL_DUPLEX; //PR08
+// m_ethmac.dot3StatsDuplexStatus=ETHERLIKE_MIB_DOT3STATSDUPLEXSTATUS_HALFDUPLEX; //PR08
+// m_ethmac.dot3StatsDuplexStatus = m_underlayer->getEthMode();
+// m_ethmac.mauIfGrpBasic.ifMauStatus=_DEFAULT_SNMP_MAU_STATUS; //PR13
+
+
+ m_bridgemac.ipGroup.ipNetToMediaType=IP_MIB_IPNETTOMEDIATYPE_STATIC;
+ m_bridgemac.ipGroup.ipAdEntAddr=0x7F000000;
+ m_bridgemac.ipGroup.ipAdEntNetMask=0xFFFFFFFF; //PR08
+ m_bridgemac.ipGateway=0x0A000003; //PR16
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[0]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[1]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[2]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[3]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[4]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[5]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifHighSpeed = 0;
+
+
+ sprintf( m_ethmac.ifGeneralInformationGroup.ifDesc,
+ _DEFAULT_SNMP_ETHER_IF_DESCR,
+ m_ethmac.ifGeneralInformationGroup.ifHighSpeed );
+ sprintf(m_plcmac.ifGeneralInformationGroup.ifDesc,_DEFAULT_SNMP_PLC_IF_DESCR);
+ sprintf(m_bridgemac.ifGeneralInformationGroup.ifDesc,_DEFAULT_SNMP_BRIDGE_IF_DESCR);
+ m_ethmac.ifGeneralInformationGroup.ifType=_DEFAULT_SNMP_ETHER_IF_TYPE;
+ m_plcmac.ifGeneralInformationGroup.ifType=_DEFAULT_SNMP_PLC_IF_TYPE;
+ m_bridgemac.ifGeneralInformationGroup.ifType=_DEFAULT_SNMP_BRIDGE_IF_TYPE;
+
+ sprintf( m_ethmac.ifGeneralInformationGroup.ifName,_DEFAULT_SNMP_ETHER_IF_NAME);
+ sprintf( m_plcmac.ifGeneralInformationGroup.ifName,_DEFAULT_SNMP_PLC_IF_NAME);
+ sprintf( m_bridgemac.ifGeneralInformationGroup.ifName,_DEFAULT_SNMP_BRIDGE_IF_NAME);
+ m_ethmac.ifGeneralInformationGroup.ifAdminStatus=IF_MIB_IFADMINSTATUS_UP;
+ m_plcmac.ifGeneralInformationGroup.ifAdminStatus=IF_MIB_IFADMINSTATUS_UP;
+ m_bridgemac.ifGeneralInformationGroup.ifAdminStatus=IF_MIB_IFADMINSTATUS_UP;
+ m_ethmac.ifGeneralInformationGroup.ifOperStatus=IF_MIB_IFOPERSTATUS_UP;
+ m_plcmac.ifGeneralInformationGroup.ifOperStatus=IF_MIB_IFOPERSTATUS_UP;
+ m_bridgemac.ifGeneralInformationGroup.ifOperStatus=IF_MIB_IFOPERSTATUS_UP;
+ m_ethmac.ifHCPacketGroup.ifMtu=1500;
+ m_plcmac.ifHCPacketGroup.ifMtu=500;
+ m_bridgemac.ifHCPacketGroup.ifMtu=1480;
+ m_ethmac.ifHCPacketGroup.ifPromiscuousMode=IF_MIB_IFPROMISCUOUSMODE_TRUE;
+ m_plcmac.ifHCPacketGroup.ifPromiscuousMode=IF_MIB_IFPROMISCUOUSMODE_TRUE;
+ m_bridgemac.ifHCPacketGroup.ifPromiscuousMode=IF_MIB_IFPROMISCUOUSMODE_TRUE;
+ m_ethmac.ifGeneralInformationGroup.ifConnectorPresent=IF_MIB_IFCONNECTORPRESENT_TRUE;
+ m_plcmac.ifGeneralInformationGroup.ifConnectorPresent=IF_MIB_IFCONNECTORPRESENT_TRUE;
+ m_bridgemac.ifGeneralInformationGroup.ifConnectorPresent=IF_MIB_IFCONNECTORPRESENT_FALSE;
+ sprintf( m_ethmac.ifGeneralInformationGroup.ifAlias,_DEFAULT_SNMP_ETHER_IF_NAME);
+ sprintf( m_plcmac.ifGeneralInformationGroup.ifAlias,_DEFAULT_SNMP_PLC_IF_NAME);
+ sprintf( m_bridgemac.ifGeneralInformationGroup.ifAlias,_DEFAULT_SNMP_BRIDGE_IF_NAME);
+//PR08 END
+//PR07 END
+#endif
+
+ // System default mib values
+ sprintf(m_plcsystem.sysname,"Undefined System Name");
+
+ // plc interface default mib values
+ m_plcmac.ipGroup.ipNetToMediaType=IP_MIB_IPNETTOMEDIATYPE_STATIC;
+ m_plcmac.ipGroup.ipAdEntAddr=0x7F000000;
+ m_plcmac.ipGroup.ipAdEntNetMask=0xFFFFFFFF;
+ m_plcmac.ipGateway=0x0A000001;
+
+ m_plcmac.ifHCPacketGroup.ifMtu=0;
+ m_plcmac.ifHCPacketGroup.ifPromiscuousMode=IF_MIB_IFPROMISCUOUSMODE_TRUE;
+
+ m_plcmac.ifGeneralInformationGroup.ifType=_DEFAULT_SNMP_PLC_IF_TYPE;
+ m_plcmac.ifGeneralInformationGroup.ifConnectorPresent=IF_MIB_IFCONNECTORPRESENT_TRUE;
+ m_plcmac.ifGeneralInformationGroup.ifOperStatus=IF_MIB_IFOPERSTATUS_UP;
+ m_plcmac.ifGeneralInformationGroup.ifAdminStatus=IF_MIB_IFADMINSTATUS_UP;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[0] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[1] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[2] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[3] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[4] = (char)255;
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[5] = (char)255;
+
+ m_plcmac.ifGeneralInformationGroup.ifHighSpeed=24*(PMD_MAX_BANDS-1);
+ sprintf(m_plcmac.ifGeneralInformationGroup.ifDesc,_DEFAULT_SNMP_PLC_IF_DESCR);
+ sprintf(m_plcmac.ifGeneralInformationGroup.ifName,_DEFAULT_SNMP_PLC_IF_NAME);
+ sprintf(m_plcmac.ifGeneralInformationGroup.ifAlias,_DEFAULT_SNMP_PLC_IF_NAME);
+
+ m_plcmac.mode = 0; //PR50
+ m_plcmac.nb_hosts = 0;
+
+ // ethernet interface default mib values
+ m_ethmac.ipGroup.ipNetToMediaType=IP_MIB_IPNETTOMEDIATYPE_STATIC;
+ m_ethmac.ipGroup.ipAdEntAddr=0x7F000000;
+ m_ethmac.ipGroup.ipAdEntNetMask=0xFFFFFFFF;
+ m_ethmac.ipGateway=0x0A000002;
+
+ m_ethmac.ifHCPacketGroup.ifMtu=0;
+ m_ethmac.ifHCPacketGroup.ifPromiscuousMode=IF_MIB_IFPROMISCUOUSMODE_TRUE;
+
+ m_ethmac.ifGeneralInformationGroup.ifType=_DEFAULT_SNMP_ETHER_IF_TYPE;
+ m_ethmac.ifGeneralInformationGroup.ifConnectorPresent=IF_MIB_IFCONNECTORPRESENT_TRUE;
+ m_ethmac.ifGeneralInformationGroup.ifOperStatus=IF_MIB_IFOPERSTATUS_UP;
+ m_ethmac.ifGeneralInformationGroup.ifAdminStatus=IF_MIB_IFADMINSTATUS_UP;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[0] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[1] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[2] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[3] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[4] = (char)255;
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[5] = (char)255;
+
+ //m_ethmac.ifGeneralInformationGroup.ifHighSpeed=100;
+ sprintf(m_ethmac.ifGeneralInformationGroup.ifDesc,
+ _DEFAULT_SNMP_ETHER_IF_DESCR,
+ m_ethmac.ifGeneralInformationGroup.ifHighSpeed );
+ sprintf(m_ethmac.ifGeneralInformationGroup.ifName,_DEFAULT_SNMP_ETHER_IF_NAME);
+ sprintf(m_ethmac.ifGeneralInformationGroup.ifAlias,_DEFAULT_SNMP_ETHER_IF_NAME);
+
+ //m_ethDefaultMode = m_ethmac.dot3StatsDuplexStatus;
+ m_ethmac.mauIfGrpBasic.ifMauStatus=_DEFAULT_SNMP_MAU_STATUS;
+
+ // bridge interface default mib values
+ m_bridgemac.ipGroup.ipNetToMediaType=IP_MIB_IPNETTOMEDIATYPE_STATIC;
+ m_bridgemac.ipGroup.ipAdEntAddr=0x7F000000;
+ m_bridgemac.ipGroup.ipAdEntNetMask=0xFFFFFFFF;
+ m_bridgemac.ipGateway=0x0A000003;
+
+ m_bridgemac.ifHCPacketGroup.ifMtu=0;
+ m_bridgemac.ifHCPacketGroup.ifPromiscuousMode=IF_MIB_IFPROMISCUOUSMODE_TRUE;
+
+ m_bridgemac.ifGeneralInformationGroup.ifType=_DEFAULT_SNMP_BRIDGE_IF_TYPE;
+ m_bridgemac.ifGeneralInformationGroup.ifConnectorPresent=IF_MIB_IFCONNECTORPRESENT_FALSE;
+ m_bridgemac.ifGeneralInformationGroup.ifOperStatus=IF_MIB_IFOPERSTATUS_UP;
+ m_bridgemac.ifGeneralInformationGroup.ifAdminStatus=IF_MIB_IFADMINSTATUS_UP;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[0]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[1]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[2]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[3]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[4]=(char)255;
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[5]=(char)255;
+
+ m_bridgemac.ifGeneralInformationGroup.ifHighSpeed=100;
+ sprintf(m_bridgemac.ifGeneralInformationGroup.ifDesc,_DEFAULT_SNMP_BRIDGE_IF_DESCR);
+ sprintf(m_bridgemac.ifGeneralInformationGroup.ifName,_DEFAULT_SNMP_BRIDGE_IF_NAME);
+ sprintf(m_bridgemac.ifGeneralInformationGroup.ifAlias,_DEFAULT_SNMP_BRIDGE_IF_NAME);
+
+ unsigned int i = 0, j = 0, k = 0, l = 0, indx = 0;
+ for ( i=1 ; i< PLCP_MAX_HOST ; ++i )
+ {
+ for ( j=1 ; j< PMD_MAX_BANDS ; ++j ) // can be a lower value
+ {
+ for ( k=0; k<PMD_GROUPS_PER_BAND; ++k )
+ {
+ for ( l=0 ; l<PMD_CARRIERS_PER_GROUP; ++l ) //plcStatsGroup
+ {
+ indx = j*PMD_GROUPS_PER_BAND*PMD_CARRIERS_PER_GROUP+k*PMD_CARRIERS_PER_GROUP + l;
+
+ m_plchost[i].signal[indx] = 0;
+ m_plchost[i].noise [indx] = 0;
+ }
+ }
+ m_plchost[i].avg_band_att[j]=0;
+ m_plchost[i].avg_band_snr[j]=0;
+
+ }
+
+ m_plchost[i].macAddress[0] = (char)255;
+ m_plchost[i].macAddress[1] = (char)255;
+ m_plchost[i].macAddress[2] = (char)255;
+ m_plchost[i].macAddress[3] = (char)255;
+ m_plchost[i].macAddress[4] = (char)255;
+ m_plchost[i].macAddress[5] = (char)255;
+
+ m_plchost[i].gain = 0;
+ m_plchost[i].automatic = true;
+ m_plchost[i].mtu = 0;
+ m_plchost[i].avgNoise = 0;
+ m_plchost[i].avg_att = 0; //PR10
+ m_plchost[i].avg_snr = 0; //PR10
+
+ m_plchost[i].rx_channel.index = 1;
+ m_plchost[i].rx_channel.type = RX_CHANNEL;
+ m_plchost[i].rx_channel.pilots[0] = 0;
+ m_plchost[i].rx_channel.pilots[1] = 0;
+ m_plchost[i].rx_channel.bandwidth = 0;
+ m_plchost[i].rx_channel.max_bandwidth = 0;
+
+ m_plchost[i].rx_last_channel.index = 2;
+ m_plchost[i].rx_last_channel.type = RX_LAST_CHANNEL;
+ m_plchost[i].rx_last_channel.pilots[0] = 0;
+ m_plchost[i].rx_last_channel.pilots[1] = 0;
+ m_plchost[i].rx_last_channel.bandwidth = 0;
+ m_plchost[i].rx_last_channel.max_bandwidth = 0;
+
+ m_plchost[i].tx_channel.index = 3;
+ m_plchost[i].tx_channel.type = TX_CHANNEL;
+ m_plchost[i].tx_channel.pilots[0] = 0;
+ m_plchost[i].tx_channel.pilots[1] = 0;
+ m_plchost[i].tx_channel.bandwidth = 0;
+ m_plchost[i].tx_channel.max_bandwidth = 0;
+
+ for ( unsigned int i = 0; i<(PMD_GROUPS_PER_BAND/2); ++i )
+ {
+ m_plchost[i].rx_channel.modulation[i] = 0;
+ m_plchost[i].rx_last_channel.modulation[i] = 0;
+ m_plchost[i].tx_channel.modulation[i] = 0;
+ }
+ }
+
+ for ( j=0; j<PMD_MAX_BANDS; ++j )
+ {
+ for ( k=0; k<PMD_GROUPS_PER_BAND; ++k )
+ {
+ indx = j*PMD_GROUPS_PER_BAND + k;
+ m_systemcarrier.groupNotch[indx]=0;
+ m_systemcarrier.groupPilot[indx]=0;
+ }
+ }
+
+ sprintf( m_plcsystem.sysname, "Default System Name" );
+ sprintf( m_plcsystem.AFEVersion, "Default AFE Version" );
+ sprintf( m_plcsystem.boardVersion, "Default Board Version" );
+ sprintf( m_plcsystem.softwareVersion, "Default Software Version" );
+
+
+ m_plcanalyser.enable=0;
+ m_plcanalyser.agc=0;
+ for (j=1;j< PMD_MAX_BANDS;++j)
+ {
+ m_plcanalyser.fft_div[j]=0;
+ for(k=0;k<PMD_GROUPS_PER_BAND;++k )
+ {
+ for(l=0;l<PMD_CARRIERS_PER_GROUP;++l )
+ {
+ unsigned int indx=
+ j*PMD_GROUPS_PER_BAND*PMD_CARRIERS_PER_GROUP+k*PMD_CARRIERS_PER_GROUP+l;
+ m_plcanalyser.min_signal[indx] =0;
+ m_plcanalyser.avg_signal[indx] =0;
+ m_plcanalyser.max_signal[indx] =0;
+ m_plcanalyser.last_signal[indx]=0;
+ }
+ }
+ }
+
+
+ m_agcanalyser.enable=0;
+ m_agcanalyser.period=_DEFAULT_AGC_PERIOD;
+ m_agcanalyser.samples=_DEFAULT_AGC_SAMPLES;
+ for (j=0;j<MAX_AGC_SAMPLES;++j) // can be a lower value
+ m_agcanalyser.agc[j]=0;
+
+ // by default auto mode for speed and duplex is true
+ m_eth_auto = true;
+ m_current_eth_config.eth_speed = ETH_SPEED_AUTO;
+ m_current_eth_config.eth_duplex = ETH_MODE_AUTO;
+
+ /* SARFT MIB */
+
+ // GENERAL-MIB
+
+ // MasterAdminGroup
+ memset(&mMasterAdminGroup, '\0', sizeof(master_admin_group_t));
+
+#ifdef STUB_TEST
+ m_underlayer = new Stub();
+# else // !STUB_TEST
+ m_underlayer = new Underlayer();
+#endif // STUB_TEST
+
+ for(int i=0;i<PLCP_MAX_HOST;++i) {
+ m_lastTimeUpdate[i] = 0;
+ }
+}
+
+SystemManager::~SystemManager()
+{
+ if (!m_underlayer) {
+ delete m_underlayer;
+ }
+}
+
+/**
+ * To get the only Singleton instance
+ */
+SystemManager*
+SystemManager::instance()
+{
+ if ( m_instance_p == 0 )
+ {
+ m_instance_p = new SystemManager();
+
+ //////////////////////////////////////////////////////////
+ // Get the entire system information from low interface
+ //////////////////////////////////////////////////////////
+
+ //
+ m_instance_p->_getEntireSystemInfo();
+ }
+
+ return m_instance_p;
+}
+
+/**
+ * To avoid singleton memory leaks
+ */
+void
+SystemManager::freeMemory()
+{
+ if ( m_instance_p != 0 )
+ {
+ delete m_instance_p;
+ m_instance_p = 0;
+ }
+}
+
+/**
+ * To get an incremental counter (only for tests)
+ */
+unsigned long
+SystemManager::getInc()
+{
+ unsigned int val = instance()->get();
+ if ( val > 1000000 )
+ {
+ instance()->reset();
+ val = 0;
+ }
+
+ return val;
+}
+
+
+unsigned long SystemManager::getInc(unsigned int i)
+{
+ if (i<PLCP_MAX_HOST)
+ return m_lastTimeUpdate[i];
+ else
+ return 0;
+}
+
+
+void SystemManager::setInc(int i, const unsigned long& iTime)
+{
+ if (i<PLCP_MAX_HOST)
+ m_lastTimeUpdate[i] = iTime;
+}
+
+//PR08 BEGIN
+/**
+ * To convert from int ip to char ip
+ */
+
+void SystemManager::intIP_to_strIP(unsigned long intIP, char* ipAddress)
+{
+ sprintf(ipAddress,"%lu.%lu.%lu.%lu",(intIP>>24)&0xFF,(intIP>>16)&0xFF,(intIP>>8)&0xFF,intIP&0xFF);
+}
+
+/**
+ * To convert from char ip to int ip
+ */
+
+unsigned long SystemManager::strIP_to_intIP(char* ipAddress)
+{
+ unsigned long intIP=0x00000000;
+ unsigned char scale;
+ char digit[4];
+ unsigned char x;
+
+ for(unsigned char i=0;i<4;i++)
+ {
+ x=0;
+ scale=(3-i)*8;
+ while(*ipAddress!='.' && *ipAddress!='\0')
+ {
+ digit[x++]=*ipAddress++;
+ x&=3;
+ }
+ ipAddress++;
+ digit[x]='\0';
+ intIP|=(atoi(digit)<<scale);
+ }
+ return intIP;
+}
+//PR08 END
+
+/*void SystemManager::macAdd_to_strIP(char* strIp,const unsigned char macAdd[],const char* dev)
+{
+ m_instance_p->m_underlayer->mib_mac_add_to_str_ip(strIp,macAdd,dev);
+}*/
+
+void
+SystemManager::_getEntireSystemInfo()
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ m_isInit = true;
+ (void)PlcSystem();
+ (void)BridgeMac(); //PR07
+ (void)EthMac();
+ (void)PlcMac();
+ (void)PlcSNAnalyser(); //PR12
+ (void)PlcAGCAnalyser(); //PR17
+ (void)EthCurrentConfig();
+
+ refreshPlcHosts();
+ refreshSoftwareReleases();
+ (void)SystemCarrier();
+ m_isInit = false;
+ m_underlayer->setIsInit(false);
+
+}
+
+const char*
+SystemManager::SysName()
+{
+ memset(mAdminOIDGroup.name, '\0', OID_PARAM_LENGTH);
+
+ if (0 != m_underlayer->getConfFileParam(mAdminOIDGroup.name, SPIDLIB_ADMIN_SYS_NAME_KEY, SPIDLIB_CONFIG_SNMP_PATH, SPIDLIB_PARAMETER_OID_MAX_LENGTH))
+ {
+ return NULL;
+ }
+
+ return mAdminOIDGroup.name;
+}
+
+const char*
+SystemManager::SysLocation()
+{
+ memset(mAdminOIDGroup.location, '\0', OID_PARAM_LENGTH);
+
+ if (0 != m_underlayer->getConfFileParam(mAdminOIDGroup.location, SPIDLIB_ADMIN_SYS_LOCATION_KEY, SPIDLIB_CONFIG_SNMP_PATH, SPIDLIB_PARAMETER_OID_MAX_LENGTH))
+ {
+ return NULL;
+ }
+
+ return mAdminOIDGroup.location;
+}
+
+const char*
+SystemManager::SysContact()
+{
+ memset(mAdminOIDGroup.contact, '\0', OID_PARAM_LENGTH);
+
+ if (0 != m_underlayer->getConfFileParam(mAdminOIDGroup.contact, SPIDLIB_ADMIN_SYS_CONTACT_KEY, SPIDLIB_CONFIG_SNMP_PATH, SPIDLIB_PARAMETER_OID_MAX_LENGTH))
+ {
+ return NULL;
+ }
+
+ return mAdminOIDGroup.contact;
+}
+
+const struct plc_system&
+SystemManager::PlcSystem()
+{
+ static unsigned long last = getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ unsigned long inc = getInc()-last;
+ if ( m_isInit || inc >= _DEFAULT_DATA_REFRESH_PERIOD_NODE )
+ {
+ last += inc;
+ // Get from low interface
+ m_underlayer->mib_getPlcSystem( &m_plcsystem );
+ }
+
+ return m_plcsystem;
+}
+
+
+const struct plc_mac&
+SystemManager::PlcMac()
+{
+ static unsigned long last = getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ unsigned long inc = getInc()-last;
+ if ( m_isInit || inc >= _DEFAULT_DATA_REFRESH_PERIOD_NODE )
+ {
+ last += inc;
+ // Get from low interface
+ m_underlayer->mib_getPlcMac( &m_plcmac );
+ }
+
+ return m_plcmac;
+}
+
+const struct eth_mac&
+SystemManager::EthMac()
+{
+ static unsigned long last = getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ unsigned long inc = getInc()-last;
+ if ( m_isInit || inc >= _DEFAULT_DATA_REFRESH_PERIOD_NODE )
+ {
+ last += inc;
+ // Get from low interface
+ m_underlayer->mib_getEthMac(&m_ethmac);
+ m_ethmac.ifGeneralInformationGroup.ifHighSpeed = getEthCurrentSpeed();
+ }
+
+ return m_ethmac;
+}
+
+
+
+const eth_config_t&
+SystemManager::EthCurrentConfig()
+{
+ static unsigned long last = getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ unsigned long inc = getInc()-last;
+ if ( m_isInit || inc >= _DEFAULT_DATA_REFRESH_PERIOD_NODE )
+ {
+ last += inc;
+ // Get from low interface
+ m_underlayer->mib_getEthCurrentMode(m_current_eth_config.eth_duplex);
+ m_underlayer->mib_getEthCurrentSpeed(m_current_eth_config.eth_speed);
+
+ }
+
+ return m_current_eth_config;
+}
+
+
+int SystemManager::getEthCurrentMode()
+{
+ return EthCurrentConfig().eth_duplex;
+
+}
+
+
+int SystemManager::getEthCurrentSpeed()
+{
+ return EthCurrentConfig().eth_speed;
+
+}
+
+
+
+
+const struct bridge_mac&
+SystemManager::BridgeMac()
+{
+ static unsigned long last = getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ unsigned long inc = getInc()-last;
+ if ( m_isInit || inc >= _DEFAULT_DATA_REFRESH_PERIOD_NODE )
+ {
+ last += inc;
+ // Get from low interface
+ m_underlayer->mib_getBridgeMac( &m_bridgemac );
+ }
+
+ return m_bridgemac;
+}
+
+
+//PR12 BEGIN
+const struct plc_analyser& SystemManager::PlcSNAnalyser()
+{
+ static unsigned long last=getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+ unsigned long inc=getInc()-last;
+ if(m_isInit||inc>=_DEFAULT_ANALYSER_REFRESH_PERIOD)
+ {
+ last += inc;
+ // Get from low interface
+ m_underlayer->mib_getPlcAnalyser(&m_plcanalyser);
+ }
+
+ return m_plcanalyser;
+}
+//PR12 END
+
+
+//PR17 BEGIN
+const struct agc_analyser& SystemManager::PlcAGCAnalyser()
+{
+ static unsigned long last=getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+ unsigned long inc=getInc()-last;
+ if(m_isInit||inc>=_DEFAULT_ANALYSER_REFRESH_PERIOD)
+ {
+ last += inc;
+ // Get from low interface
+ m_underlayer->mib_getAgcAnalyser(&m_agcanalyser);
+ }
+
+ return m_agcanalyser;
+}
+//PR17 END
+
+
+unsigned int
+SystemManager::NbPlcHosts()
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ unsigned int nbHosts = 0;
+ nbHosts = m_underlayer->mib_getHostNb();
+ return nbHosts;
+}
+
+const struct plc_host&
+SystemManager::PlcHost(unsigned int hostId)
+{
+ //unsigned long period = getInc() - m_lastTimeUpdate[hostId];
+ //if ( /*m_isInit || */period >= _DEFAULT_DATA_REFRESH_PERIOD )
+ {
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("refresh host");
+ if (m_isInit) LOG("m_isInit is TRUE");
+ else LOG("m_isInit is FALSE");
+ LOG_END;
+
+ refreshPlcHost(hostId);
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("hostrefreshed");
+ LOG_END;
+
+ }
+
+ return m_plchost[hostId];
+}
+
+
+
+const struct plc_host& SystemManager::getStoredPlcHost(unsigned int hostId)
+{
+ return m_plchost[hostId];
+}
+
+
+void
+SystemManager::refreshPlcHost( unsigned int hostId )
+{
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHost HEAVY IOCTL BEGIN for host id"); LOG(hostId);
+ LOG_END;
+
+ m_isHostActive[hostId] = ( m_underlayer->mib_getPlcHost( hostId, &m_plchost[hostId] ) == RET_SUCCESS );
+
+ //update the time of last update
+
+
+ /*char test[50]={0};
+ sprintf(test, "%02X-%02X-%02X-%02X-%02X-%02X",
+ m_plchost[hostId].macAddress[0],
+ m_plchost[hostId].macAddress[1],
+ m_plchost[hostId].macAddress[2],
+ m_plchost[hostId].macAddress[3],
+ m_plchost[hostId].macAddress[4],
+ m_plchost[hostId].macAddress[5]);*/
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHost HEAVY IOCTL finished");
+ LOG_END;
+
+
+ if (m_isHostActive[hostId])
+ {
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHost Host updated"); LOG(hostId);
+ LOG("MAC Address is: ");
+ LOG((int)m_plchost[hostId].macAddress[0]);
+ LOG((int)m_plchost[hostId].macAddress[1]);
+ LOG((int)m_plchost[hostId].macAddress[2]);
+ LOG((int)m_plchost[hostId].macAddress[3]);
+ LOG((int)m_plchost[hostId].macAddress[4]);
+ LOG((int)m_plchost[hostId].macAddress[5]);
+ LOG_END;
+
+ m_lastTimeUpdate[hostId]= getInc();
+ }
+ else
+ {
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHost HEAVY IOCTL in ERROR");
+ LOG_END;
+ }
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("end refresh host index"); LOG(hostId);
+ LOG_END;
+}
+
+
+void
+SystemManager::refreshPlcHosts(bool lightrefresh)
+{
+ LOG_BEGIN(DEBUG_LOG);
+ if (lightrefresh)
+ LOG("SystemManager::refreshPlcHosts called with light ioctl");
+ else
+ LOG("SystemManager::refreshPlcHosts called with heavy ioctl");
+ LOG_END;
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+
+ unsigned int nbHosts = NbPlcHosts();
+ unsigned int nbOfActiveHosts = 0;
+ unsigned int i = 0;
+ //for ( unsigned int i=0 ; i<nbHosts; ++i ) IMS#5
+ for (i = 0; ((i < PLCP_MAX_HOST) && (nbOfActiveHosts < nbHosts)); ++i)
+ {
+ if (!lightrefresh)
+ {
+ m_isHostActive[i] = ( m_underlayer->mib_getPlcHost( i, &m_plchost[i] ) == RET_SUCCESS );
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHosts HEAVY IOCTL for Mac Address: ");
+ LOG((int)m_plchost[i].macAddress[0]);
+ LOG((int)m_plchost[i].macAddress[1]);
+ LOG((int)m_plchost[i].macAddress[2]);
+ LOG((int)m_plchost[i].macAddress[3]);
+ LOG((int)m_plchost[i].macAddress[4]);
+ LOG((int)m_plchost[i].macAddress[5]);
+ LOG("index is:");LOG(i);
+ LOG("isHostActive:"); LOG(m_isHostActive[i] == 1 ? "true" : "false");
+ LOG_END;
+ }
+ else
+ {
+ m_isHostActive[i] = ( updatePlcLightHostByIndex(i) == RET_SUCCESS );
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHosts LIGHT IOCTL for Mac Address: ");
+ LOG((int)m_plchost[i].macAddress[0]);
+ LOG((int)m_plchost[i].macAddress[1]);
+ LOG((int)m_plchost[i].macAddress[2]);
+ LOG((int)m_plchost[i].macAddress[3]);
+ LOG((int)m_plchost[i].macAddress[4]);
+ LOG((int)m_plchost[i].macAddress[5]);
+ LOG("index is:");LOG(i);
+ LOG("isHostActive:"); LOG(m_isHostActive[i] == 1 ? "true" : "false");
+ LOG_END;
+ }
+
+
+ if (!lightrefresh)
+ {
+ m_lastTimeUpdate[i] = getInc();
+ }
+
+ if ( m_isHostActive[i] ) {
+ nbOfActiveHosts ++;
+ }
+ }
+
+ /* FIX: need to declare all the other hosts not active! */
+ for (unsigned int j = i; j < PLCP_MAX_HOST; j++)
+ m_isHostActive[j] = 0;
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("refresh all hosts end");
+ LOG_END;
+}
+
+
+void
+SystemManager::refreshPlcHostsBasePort()
+{
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHostsBasePort begin");
+ LOG_END;
+
+ unsigned int nbHosts = NbPlcHosts();
+ unsigned int nbOfActiveHosts = 0;
+ for (unsigned int i=0; ((i<PLCP_MAX_HOST)&&(nbOfActiveHosts<nbHosts)); ++i)
+ {
+ if ( m_isHostActive[i] = ( updatePlcHostBasePortByIndex(i) == RET_SUCCESS ) )
+ {
+ nbOfActiveHosts ++;
+ }
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager::refreshPlcHostsBasePort for Mac Address: ");
+ LOG((int)m_plchost[i].macAddress[0]);
+ LOG((int)m_plchost[i].macAddress[1]);
+ LOG((int)m_plchost[i].macAddress[2]);
+ LOG((int)m_plchost[i].macAddress[3]);
+ LOG((int)m_plchost[i].macAddress[4]);
+ LOG((int)m_plchost[i].macAddress[5]);
+ LOG("index is:"); LOG(i);
+ LOG("isHostActive:"); LOG(m_isHostActive[i] == 1 ? "true" : "false");
+ LOG_END;
+ }
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("refresh all hosts base port entry end");
+ LOG_END;
+}
+
+
+const struct system_carrier_tab&
+SystemManager::SystemCarrier()
+{
+ static unsigned long last = getInc();
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ unsigned long period = getInc()-last;
+ if ( m_isInit || period >= _DEFAULT_DATA_REFRESH_PERIOD )
+ {
+ last += period;
+ m_underlayer->mib_getSystemCarrier( &m_systemcarrier );
+ }
+
+ return m_systemcarrier;
+}
+
+
+void
+SystemManager::setMib(Mib* mib)
+{
+ global_mib = mib;
+
+ return;
+}
+
+Mib*
+SystemManager::getMib()
+{
+ return global_mib;;
+}
+
+
+int SystemManager::tableOidAlarmProcess_analog(const char* oid_string, spidlib_analog_alarm_entry_t* alarm)
+{
+ char entire_oid_string[_DEFAULT_OID_BUFFER_SIZE];
+ unsigned int hostIndex = 0;
+
+ if ( (NULL == oid_string) || (NULL == alarm) )
+ return -1;
+
+ refreshPlcHosts(true /* heavy refresh */);
+
+ if (NULL == m_plchost)
+ {
+ syslog(LOG_NOTICE, "error retrieving connected hosts");
+ return -1;
+ }
+
+ // Select which case of "table oid" has to be checked
+ if ( (0 == strcmp(oid_string, oidModEoCOnlineCNURFUpstreamAttenuation) ) || (0 == strcmp(oid_string, oidModEoCOnlineCNURFUpstreamAttenuation_2)) )
+ {
+ // modEoCCNURFAttenuation
+ int agc_call;
+ char mac_slave[18];
+ int uplink_attenuation = 0;
+ spidlib_whitelist_entry_t temp_entry;
+
+ strncpy (alarm->oid, oid_string, sizeof(alarm->oid));
+
+ for (hostIndex=0; hostIndex<PLCP_MAX_HOST; hostIndex++)
+ {
+ // check that slave is online, not broadscat and not multicast
+ if ( (SystemManager::instance()->isHostActive(hostIndex))
+ && (0 != memcmp(m_plchost[hostIndex].macAddress, "\xff\xff\xff\xff\xff\xff", 6))
+ && !(m_plchost[hostIndex].macAddress[0] & 0x01) /*Remove multicast hosts*/)
+ {
+ //get agc_call error parameter to use in the calculation of the uplink attenuation
+ if (spidlib_get_agc_call(&agc_call) != 0)
+ agc_call = 0;
+
+ //get RF output level of slave to use in the calculation of the uplink attenuation
+ if (spidlib_mac_bin_to_str_lower(m_plchost[hostIndex].macAddress, mac_slave) != 0)
+ {
+ syslog(LOG_NOTICE, "couldn't retrieve mac slave, attenuation calculation might be wrong");
+ temp_entry.RFOutput_level = SPIDLIB_WHITELIST_OUTPUT_LEVEL_MAX;
+ }
+ else if (spidlib_get_whitelist_entry(mac_slave, &temp_entry) != 0)
+ {
+ syslog(LOG_NOTICE, "retrieve slave output level, attenuation calculation might be wrong");
+ temp_entry.RFOutput_level = SPIDLIB_WHITELIST_OUTPUT_LEVEL_MAX;
+ }
+
+ uplink_attenuation = m_plchost[hostIndex].avg_att + agc_call + temp_entry.RFOutput_level - SPIDLIB_WHITELIST_OUTPUT_LEVEL_MAX;
+
+ // Build entire oid : RFAttenuation oid.master index.slave index to add this event in alarm_current table
+ memset(entire_oid_string, '\0', sizeof(entire_oid_string) );
+ sprintf(entire_oid_string, "%s.0.%d", oidModEoCOnlineCNURFUpstreamAttenuation, hostIndex);
+
+ // Check value to trigger or not an alarm
+ if (checkAnalogAlarm(alarm, uplink_attenuation, SPIDLIB_TRUE, entire_oid_string) != 0)
+ syslog(LOG_DEBUG, "SNMP agent: error checking alarm with OID (table) %s", entire_oid_string);
+ }
+ }
+ }
+ else if ( (0 == strcmp(oid_string, oidModEoCOnlineCNURFDownstreamQuality) ) || (0 == strcmp(oid_string, oidModEoCOnlineCNURFDownstreamQuality_2) ) )
+ {
+ // modEoCOnlineCNURFDownstreamQuality
+ unsigned int quality_tx;
+
+ for (hostIndex=0; hostIndex<PLCP_MAX_HOST; hostIndex++)
+ {
+ // check that slave is online, not broadscat and not multicast
+ if ( (SystemManager::instance()->isHostActive(hostIndex))
+ && (0 != memcmp(m_plchost[hostIndex].macAddress, "\xff\xff\xff\xff\xff\xff", 6))
+ && !(m_plchost[hostIndex].macAddress[0] & 0x01) /*Remove multicast hosts*/)
+ {
+ if (m_plchost[hostIndex].tx_channel.max_bandwidth == 0)
+ refreshPlcHosts(false /* heavy refresh */);
+
+ if (m_plchost[hostIndex].tx_channel.max_bandwidth == 0)
+ quality_tx = 55;
+ else
+ {quality_tx = m_plchost[hostIndex].tx_channel.bandwidth*100/m_plchost[hostIndex].tx_channel.max_bandwidth;}
+
+ // Build entire oid : RFAttenuation oid + master index + slave index to add this event in alarm_current table
+ memset(entire_oid_string, '\0', sizeof(entire_oid_string) );
+ sprintf(entire_oid_string, "%s.0.%d", oidModEoCOnlineCNURFDownstreamQuality, hostIndex);
+
+ // Check value to trigger or not an alarm
+ if (checkAnalogAlarm(alarm, quality_tx>100?100:quality_tx, SPIDLIB_TRUE, entire_oid_string) != 0)
+ syslog(LOG_DEBUG, "SNMP agent: error checking alarm with OID (table) %s", entire_oid_string);
+ }
+ }
+ }
+ else if ( (0 == strcmp(oid_string, oidModEoCOnlineCNURFUpstreamQuality) ) || (0 == strcmp(oid_string, oidModEoCOnlineCNURFUpstreamQuality_2) ) )
+ {
+ //ModEoCOnlineCNURFUpstreamQuality
+ unsigned int quality_rx;
+
+ for (hostIndex=0; hostIndex<PLCP_MAX_HOST; hostIndex++)
+ {
+ if ( (SystemManager::instance()->isHostActive(hostIndex))
+ && (0 != memcmp(m_plchost[hostIndex].macAddress, "\xff\xff\xff\xff\xff\xff", 6))
+ && !(m_plchost[hostIndex].macAddress[0] & 0x01) /*Remove multicast hosts*/)
+ {
+ if (m_plchost[hostIndex].rx_channel.max_bandwidth == 0)
+ {
+ refreshPlcHosts(false /* heavy refresh */);
+ }
+
+ if (m_plchost[hostIndex].rx_channel.max_bandwidth == 0)
+ {
+ quality_rx = 55;
+ }
+ else
+ {
+ quality_rx = m_plchost[hostIndex].rx_channel.bandwidth*100/m_plchost[hostIndex].rx_channel.max_bandwidth;
+ }
+
+ // Build entire oid : RFAttenuation oid + master index + slave index to add this event in alarm_current table
+ memset(entire_oid_string, '\0', sizeof(entire_oid_string) );
+ sprintf(entire_oid_string, "%s.0.%d", oidModEoCOnlineCNURFUpstreamQuality, hostIndex);
+
+ // Check value to trigger or not an alarm
+ if (checkAnalogAlarm(alarm, quality_rx>100?100:quality_rx, SPIDLIB_TRUE, entire_oid_string) != 0)
+ syslog(LOG_DEBUG, "SNMP agent: error checking alarm with OID (table) %s", entire_oid_string);
+ }
+ }
+ }
+ else if ( (0 == strcmp(oid_string, oidModEoCOnlineCNUPhyDownstreamRate) ) || (0 == strcmp(oid_string, oidModEoCOnlineCNUPhyDownstreamRate_2) ) )
+ {
+ //ModEoCOnlineCNUPhyDownstreamRate
+ unsigned int downstream_rate;
+
+ for (hostIndex=0; hostIndex<PLCP_MAX_HOST; hostIndex++)
+ {
+ if ( (SystemManager::instance()->isHostActive(hostIndex))
+ && (0 != memcmp(m_plchost[hostIndex].macAddress, "\xff\xff\xff\xff\xff\xff", 6))
+ && !(m_plchost[hostIndex].macAddress[0] & 0x01) /*Remove multicast hosts*/)
+ {
+ if (m_plchost[hostIndex].tx_channel.bandwidth == 0)
+ refreshPlcHosts(false /* heavy refresh */);
+
+ downstream_rate = m_plchost[hostIndex].tx_channel.bandwidth;
+
+ // Build entire oid : RFAttenuation oid + master index + slave index to add this event in alarm_current table
+ memset(entire_oid_string, '\0', sizeof(entire_oid_string) );
+ sprintf(entire_oid_string, "%s.0.%d", oidModEoCOnlineCNUPhyDownstreamRate, hostIndex);
+
+ // Check value to trigger or not an alarm
+ if (checkAnalogAlarm(alarm, downstream_rate, SPIDLIB_TRUE, entire_oid_string) != 0)
+ syslog(LOG_DEBUG, "SNMP agent: error checking alarm with OID (table) %s", entire_oid_string);
+ }
+ }
+ }
+ else if ( (0 == strcmp(oid_string, oidModEoCOnlineCNUPhyUpstreamRate) ) || (0 == strcmp(oid_string, oidModEoCOnlineCNUPhyUpstreamRate_2) ) )
+ {
+ //ModEoCOnlineCNUPhyUpstreamRate
+ unsigned int upstream_rate;
+
+ for (hostIndex=0; hostIndex<PLCP_MAX_HOST; hostIndex++)
+ {
+ if ( (SystemManager::instance()->isHostActive(hostIndex))
+ && (0 != memcmp(m_plchost[hostIndex].macAddress, "\xff\xff\xff\xff\xff\xff", 6))
+ && !(m_plchost[hostIndex].macAddress[0] & 0x01) /*Remove multicast hosts*/)
+ {
+ if (m_plchost[hostIndex].tx_channel.bandwidth == 0)
+ refreshPlcHosts(false /* heavy refresh */);
+
+ upstream_rate = m_plchost[hostIndex].rx_channel.bandwidth;
+
+ // Build entire oid : RFAttenuation oid + master index + slave index to add this event in alarm_current table
+ memset(entire_oid_string, '\0', sizeof(entire_oid_string) );
+ sprintf(entire_oid_string, "%s.0.%d", oidModEoCOnlineCNUPhyUpstreamRate, hostIndex);
+
+ // Check value to trigger or not an alarm
+ if (checkAnalogAlarm(alarm, upstream_rate, SPIDLIB_TRUE, entire_oid_string) != 0)
+ syslog(LOG_DEBUG, "SNMP agent: error checking alarm with OID (table) %s", entire_oid_string);
+ }
+ }
+ }
+ else
+ {
+ syslog(LOG_DEBUG, "no such leaf %s", oid_string);
+ return -1;
+ }
+ return 0;
+}
+
+
+int SystemManager::tableOidAlarmProcess_discrete(const char* oid_string, spidlib_discrete_alarm_entry_t* alarm)
+{
+ char entire_oid_string[_DEFAULT_OID_BUFFER_SIZE];
+ unsigned int hostIndex = 0;
+
+ if ( (NULL == oid_string) || (NULL == alarm) )
+ return -1;
+
+ // Select which case of "table oid" has to be checked
+ if ( 0 == strcmp(oid_string, oidModEoCCNUWhiteListRegisterOnlineState) || (0 == strcmp(oid_string, oidModEoCCNUWhiteListRegisterOnlineState_2)) )
+ {
+ // modEoCCNURFAttenuation
+ strncpy (alarm->oid, oid_string, sizeof(alarm->oid));
+
+ // get entire whitelist list
+ spidlib_whitelist_entry_t white_entry[SPIDLIB_WHITELIST_MAX_NB];
+ int counter = SPIDLIB_WHITELIST_MAX_NB;
+ if (spidlib_get_whitelist_list(white_entry, &counter) != 0)
+ {
+ syslog(LOG_NOTICE, "couldn't get entire whitelist list : can't check alarm for %s oid",oid_string );
+ return -1;
+ }
+ else
+ {
+ for (int i = 0; i < counter; i++)
+ {
+ // Build entire oid : WhitelistRegisterOnlineState.WLEntryIndex
+ memset(entire_oid_string, '\0', sizeof(entire_oid_string) );
+ sprintf(entire_oid_string, "%s.%d", oidModEoCCNUWhiteListRegisterOnlineState, white_entry[i].tei);
+
+ // Check value to trigger or not an alarm
+ if (checkDiscreteAlarm(alarm, (white_entry[i].is_connected == 1)?1:0, SPIDLIB_TRUE, entire_oid_string) != 0)
+ syslog(LOG_DEBUG, "SNMP agent: error checking alarm with OID (table) %s", entire_oid_string);
+ }
+ }
+ }
+ else
+ {
+ syslog(LOG_DEBUG, "no such leaf %s", oid_string);
+ return -1;
+ }
+ return 0;
+}
+
+
+int SystemManager::getValueForOID(const char* oid_string, int* result)
+{
+ Oidx* research = new Oidx(oid_string);
+ MibEntry* entry = getMib()->get(*research);
+ if (entry != NULL)
+ {
+ if (entry->type() == AGENTPP_LEAF)
+ {
+ MibLeaf* leaf = (MibLeaf*) entry;
+ int temp_status; int &temp_status_ref = temp_status;
+ leaf->get_request(NULL, 0);
+ leaf->get_value(temp_status_ref);
+ delete research;
+ *result = temp_status;
+ return 0;
+ }
+ else
+ {
+ syslog(LOG_DEBUG, "this is no leaf %s", oid_string);
+ return -1;
+ }
+ }
+ else
+ return -1;
+
+ return 0;
+}
+
+/**
+ * To initialize the MIB
+ */
+void
+SystemManager::Init(Mib& mib )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+#ifdef SYSGROUP_MIB
+ //
+ //////////////////////////////////////////////////////////
+ // Fill System Group MIB : SYSGROUP
+ //////////////////////////////////////////////////////////
+ //
+
+ OctetStr sysDescr (_DEFAULT_SNMP_SYS_DESC);
+ OctetStr sysObjId (_DEFAULT_SNMP_SYS_OBJECT_ID);
+ int sysServices(_DEFAULT_SNMP_SYS_SERVICES );
+
+ sysGroup* sysGrp = new sysGroup( sysDescr.get_printable(),
+ sysObjId.get_printable(),
+ sysServices);
+
+ //
+ // Fill System OR Table
+ //
+
+ Oidx firstRow("1");
+ Oidx ind (_DEFAULT_SNMP_SYS_OR_ID);
+
+ MibTableRow* sysOREntryRow = sysOREntry::instance->add_row(firstRow);
+ sysOREntry::instance->set_row( sysOREntryRow,
+ ind,
+ _DEFAULT_SNMP_SYS_OR_DESCR,
+ sysUpTime::get_currentTime() );
+
+ // Add sys group MIB
+ mib.add( sysGrp );
+#endif
+
+#ifdef IF_MIB
+ //
+ //////////////////////////////////////////////////////////
+ // Fill Interface MIB : IF_MIB
+ //////////////////////////////////////////////////////////
+ //
+
+ if_mib* ifMib = new if_mib();
+
+ //
+ // Initialisation of all MIB entries and tables
+ //
+
+ ifEntry::instance->init();
+ ifXEntry::instance->init();
+
+ // Add IF MIB
+ mib.add( ifMib );
+#endif
+
+#ifdef MAU_MIB
+ //
+ //////////////////////////////////////////////////////////
+ // Fill MAU MIB : MAU_MIB
+ //////////////////////////////////////////////////////////
+ //
+
+ mau_mib* mauMib = new mau_mib();
+
+ //
+ // Initialisation of all MIB entries and tables
+ //
+
+ ifMauEntry::instance->init();
+ ifMauAutoNegEntry::instance->init();
+
+ // Add MAU MIB
+ mib.add( mauMib );
+#endif
+
+#ifdef IP_MIB
+ //
+ //////////////////////////////////////////////////////////
+ // Fill IP MIB : IP_MIB
+ //////////////////////////////////////////////////////////
+ //
+
+ ip_mib* ipMib = new ip_mib();
+
+ //
+ // Initialisation of all MIB entries and tables
+ //
+
+
+ ipAddrEntry::instance->init();
+ ipNetToMediaEntry::instance->init();
+
+ //
+ //////////////////////////////////////////////////////////
+ // Fill BRIDGE MIB : BRIDGE_MIB (here part of ip mib source)
+ //////////////////////////////////////////////////////////
+ //
+
+ //
+ // Initialisation of all MIB entries and tables
+ //
+
+ dot1dBaseBridgeAddress::instance->init();
+ dot1dBaseNumPorts::instance->init();
+ dot1dBaseType::instance->init();
+
+ dot1dBasePortEntry::instance->init();
+ dot1dStpPortEntry::instance->init();
+
+ // Add IP MIB (+ BRIDGE MIB)
+ mib.add( ipMib );
+#endif
+
+#ifdef SPC200_MIB
+ //
+ //////////////////////////////////////////////////////////
+ // Fill SPC200 MIB
+ //////////////////////////////////////////////////////////
+ //
+
+ spc200* spcMib = new spc200();
+
+ //
+ // Initialisation of all MIB entries and tables
+ //
+
+ plcMode::instance->init(); //PR04 //PR50
+ plcNodeNetConfigEntry::instance->init();
+ plcTopoChanges::instance->init();
+
+ spcMib->refreshNodeCarrier( true );
+ spcMib->refreshPlcHosts( true );
+ spcMib->refreshPlcAGCAnalyser(true); //PR17
+
+ currentSoftwareVersion::instance->init();
+ softwareEntry::instance->init();
+
+ // extended ifTable
+ ifEntryExt::instance->init();
+
+ // Add SPC200 MIB
+ mib.add( spcMib );
+#endif
+
+ //
+ //////////////////////////////////////////////////////////
+ // Fill RADIUS AUTHENTICATION CLIENT MIB
+ //////////////////////////////////////////////////////////
+ //
+
+ //radius_auth_client_mib *radiusAuthClientMib = new radius_auth_client_mib();
+ //radiusAuthServerEntry::instance->init();
+
+ // Add Radius Mib
+ //mib.add(radiusAuthClientMib);
+
+
+ //
+ //////////////////////////////////////////////////////////
+ // EXTERNAL REFERENCE TO INIT AND ADD ALL CUSTOMS MIB
+ // THE ADD MUST BE DONE IN THE InitAllCustomMibs thanks to
+ // the reference of mib given in parameter
+ //////////////////////////////////////////////////////////
+ //
+
+ ::InitAllCustomMibs(mib);
+
+#ifdef TRAP_SUPPORT
+ // Alarm Mib
+ spidcom_alarm_mib* alarmMib = new spidcom_alarm_mib();
+
+ // Initialisation of all MIB entries and tables
+ alarmMib->refreshAlarmList(true);
+ spidcom_alarm_mib_neAlarmActiveLastTrapIndex::instance->init();
+ spidcom_alarm_mib_neAlarmActivePhoto::instance->init();
+ spidcom_alarm_mib_neAlarmTrapCounter::instance->init();
+ spidcom_alarm_mib_neAlarmTrapFilter::instance->init();
+ mib.add(alarmMib);
+
+ //FOR NOTIFICATION TRAPS
+
+ spidcom_traps* trapsMib = new spidcom_traps();
+ mib.add(trapsMib);
+#endif
+
+#ifdef TRAP_SUPPORT
+ mib.add(new snmp_target_mib());
+ mib.add( new snmp_notification_mib());
+#endif
+
+ /* SARFT MIB */
+
+#ifdef SARFT_MIB_PROPERTY
+ // PROPERTY-MIB
+ mib.add(new nscrtv_eponeoc_property_mib());
+#endif
+
+#ifdef SARFT_MIB_ALARM
+ // ALARM-MIB
+ mib.add(new nscrtv_eponeoc_alarms_mib());
+#endif
+
+#ifdef SARFT_MIB_COMMON
+ // GENERAL-MIB
+ mib.add(new nscrtv_eponeoc_common_mib());
+#endif
+
+#ifdef SPIDCOM_EOC_MIB
+ //temporary mib
+ mib.add(new spidcom_eoc_mib());
+#endif
+}
+
+
+enum plc_modulation
+SystemManager::modulationFromInt
+ ( unsigned int modulation)
+{
+ switch ( modulation )
+ {
+ case 0:
+ return MOD_NONE;
+ //break;
+ case 1:
+ return MOD_BPSK;
+ //break;
+ case 2:
+ return MOD_QPSK;
+ //break;
+ case 3:
+ return MOD_QAM16;
+ //break;
+ case 4:
+ return MOD_QAM64;
+ //break;
+ case 5:
+ return MOD_QAM256;
+ //break;
+ default:
+ return MOD_NONE;
+ }
+}
+
+//
+// Set methods
+//
+
+void
+SystemManager::setSysName( const char* sysname )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ bool result = false;
+
+ result = ( m_underlayer->mib_setSysname(const_cast<char*>( sysname ) ) == RET_SUCCESS );
+ if ( result )
+ strcpy( m_plcsystem.sysname, sysname );
+}
+
+
+void SystemManager::setPlcMode(unsigned char plcMode) //PR50
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ m_plcmac.mode=plcMode;
+ m_underlayer->mib_setPlcMac(&instance()->m_plcmac);
+
+}
+
+
+
+void SystemManager::setPlcSNAnalyserEnable(bool enable)
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+ m_plcanalyser.enable=enable?1:0;
+ m_underlayer->mib_setPlcAnalyser(&instance()->m_plcanalyser);
+}
+
+
+void SystemManager::setPlcAGCAnalyserEnable(bool enable)
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+ m_agcanalyser.enable=enable?1:0;
+ m_underlayer->mib_setAgcAnalyser(&instance()->m_agcanalyser);
+}
+
+
+
+
+bool
+SystemManager::setPlcBasePortChannelEstimation(
+ const OctetStr& portAddress,
+ bool newChannelEstimation )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ bool retVal = false;
+ {
+ unsigned int nbHosts = NbPlcHosts();
+
+ int index = -1;
+
+ for ( unsigned int i=0 ; i<nbHosts ; ++i ) // plcBasePort
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[i].macAddress[0],
+ m_plchost[i].macAddress[1],
+ m_plchost[i].macAddress[2],
+ m_plchost[i].macAddress[3],
+ m_plchost[i].macAddress[4],
+ m_plchost[i].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( portAddress == hostMacAddress )
+ {
+ index = i;
+ break;
+ }
+ }
+
+ if (index != -1)
+ {
+ refreshPlcHost(index);
+
+ if ( isHostActive(index) )
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[index].macAddress[0],
+ m_plchost[index].macAddress[1],
+ m_plchost[index].macAddress[2],
+ m_plchost[index].macAddress[3],
+ m_plchost[index].macAddress[4],
+ m_plchost[index].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( portAddress == hostMacAddress )
+ {
+ m_plchost[index].automatic = newChannelEstimation ? 1 : 0;
+ retVal = ( m_underlayer->mib_setPlcHost( index, &m_plchost[index] ) == RET_SUCCESS);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+
+void
+SystemManager::setNodeMacAddr(
+ unsigned char Interface,
+ OctetStr& mac_address ) // voluntarily unconst to use []
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ switch(Interface)
+ {
+ case _DEFAULT_SNMP_ETHER_IF_INDEX:
+ {
+ for ( unsigned int i = 0; i < 6 ; ++i )
+ {
+ m_ethmac.ifGeneralInformationGroup.ifPhysicalAddress[i] = (unsigned char)mac_address[i];
+ }
+ // Set the value to the low interface
+ m_underlayer->mib_setEthMac( &m_ethmac );
+ break;
+ }
+ case _DEFAULT_SNMP_PLC_IF_INDEX:
+ {
+ for ( unsigned int i = 0; i < 6 ; ++i )
+ {
+ m_plcmac.ifGeneralInformationGroup.ifPhysicalAddress[i] = (unsigned char)mac_address[i];
+ }
+ // Set the value to the low interface
+ m_underlayer->mib_setPlcMac( &m_plcmac );
+ break;
+ }
+ case _DEFAULT_SNMP_BRIDGE_IF_INDEX:
+ {
+ for ( unsigned int i = 0; i < 6 ; ++i )
+ {
+ m_bridgemac.ifGeneralInformationGroup.ifPhysicalAddress[i] = (unsigned char)mac_address[i];
+ }
+ // Set the value to the low interface
+ m_underlayer->mib_setBridgeMac( &m_bridgemac );
+ break;
+ }
+ }
+}
+
+void
+SystemManager::setNodeIpAddr(
+ unsigned char Interface,
+ const char* ip_address )
+{
+ char ipAddress[16];
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ switch (Interface)
+ {
+ case _DEFAULT_SNMP_ETHER_IF_INDEX:
+ {
+ for ( unsigned int i = 0; i < 15 ; ++i )
+ {
+ ipAddress[i] = ip_address[i];
+ }
+
+ ipAddress[15] = '\0';
+ m_ethmac.ipGroup.ipAdEntAddr=SystemManager::strIP_to_intIP(ipAddress);
+
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setEthMac( &m_ethmac );
+
+ break;
+ }
+ case _DEFAULT_SNMP_PLC_IF_INDEX:
+ {
+ for ( unsigned int i = 0; i < 15 ; ++i )
+ {
+ ipAddress[i] = ip_address[i];
+ }
+ ipAddress[15] = '\0';
+ m_plcmac.ipGroup.ipAdEntAddr=SystemManager::strIP_to_intIP(ipAddress);
+
+
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setPlcMac( &m_plcmac );
+
+ break;
+ }
+ case _DEFAULT_SNMP_BRIDGE_IF_INDEX:
+ {
+ for ( unsigned int i = 0; i < 15 ; ++i )
+ {
+ ipAddress[i] = ip_address[i];
+ }
+ ipAddress[15] = '\0';
+ m_bridgemac.ipGroup.ipAdEntAddr=SystemManager::strIP_to_intIP(ipAddress);
+
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setBridgeMac( &m_bridgemac );
+
+ break;
+ }
+ }
+}
+
+
+
+void
+SystemManager::setNodeNetMask(
+ unsigned char Interface,
+ const char* subnet_mask )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+ char ipSubnetMask[16];
+
+ for ( unsigned int i = 0; i < 15 ; ++i )
+ {
+ ipSubnetMask[i] = subnet_mask[i]; //PR08
+ }
+ ipSubnetMask[15] = '\0';
+
+
+ switch(Interface)
+ {
+ case _DEFAULT_SNMP_ETHER_IF_INDEX:
+ {
+ // fill systemmanager attributes
+ m_ethmac.ipGroup.ipAdEntNetMask=SystemManager::strIP_to_intIP(ipSubnetMask);
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setEthMac( &m_ethmac );
+
+ break;
+ }
+ case _DEFAULT_SNMP_PLC_IF_INDEX:
+ {
+ // fill systemmanager attributes
+ m_plcmac.ipGroup.ipAdEntNetMask=SystemManager::strIP_to_intIP(ipSubnetMask);
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setPlcMac( &m_plcmac );
+
+ break;
+ }
+ case _DEFAULT_SNMP_BRIDGE_IF_INDEX:
+ {
+ // fill systemmanager attributes
+ m_bridgemac.ipGroup.ipAdEntNetMask=SystemManager::strIP_to_intIP(ipSubnetMask);
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setBridgeMac( &m_bridgemac );
+ break;
+ }
+ }
+}
+
+//PR16 BEGIN
+void SystemManager::setNodeGateway(unsigned char Interface,const char* ip_address)
+{
+ char ipGateway[16];
+ for(unsigned int i=0;i<15;++i)
+ {
+ ipGateway[i]=ip_address[i];
+ }
+ ipGateway[15]='\0';
+
+ switch(Interface)
+ {
+ case _DEFAULT_SNMP_ETHER_IF_INDEX:
+ {
+ m_ethmac.ipGateway=SystemManager::strIP_to_intIP(ipGateway);
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setEthMac(&m_ethmac);
+
+ break;
+ }
+ case _DEFAULT_SNMP_PLC_IF_INDEX:
+ {
+ m_plcmac.ipGateway=SystemManager::strIP_to_intIP(ipGateway);
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setPlcMac(&m_plcmac); //PR06
+
+ break;
+ }
+ case _DEFAULT_SNMP_BRIDGE_IF_INDEX:
+ {
+ m_bridgemac.ipGateway=SystemManager::strIP_to_intIP(ipGateway);
+ // Set the value to the low interface (NYI)
+ m_underlayer->mib_setBridgeMac(&m_bridgemac);
+
+ break;
+ }
+ }
+}
+
+
+bool
+SystemManager::setPlcChannelModulations
+ ( OctetStr & address, // voluntarily unconst to use [] operator
+ const long& channel,
+ const long& band,
+ const long& modulation1,
+ const long& modulation2,
+ const long& modulation3,
+ const long& modulation4,
+ const long& modulation5,
+ const long& modulation6,
+ const long& modulation7,
+ const long& modulation8,
+ const long& modulation9,
+ const long& modulation10,
+ const long& modulation11,
+ const long& modulation12,
+ const long& modulation13,
+ const long& modulation14,
+ const long& modulation15,
+ const long& modulation16 )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ bool retVal = false;
+
+ {
+ unsigned int nbHosts = NbPlcHosts();
+
+ int index = -1;
+ for ( unsigned int i=0 ; i<nbHosts ; ++i ) // plcBasePort
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[i].macAddress[0],
+ m_plchost[i].macAddress[1],
+ m_plchost[i].macAddress[2],
+ m_plchost[i].macAddress[3],
+ m_plchost[i].macAddress[4],
+ m_plchost[i].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( address == hostMacAddress )
+ {
+ index = i;
+ break;
+ }
+ }
+
+ if (index != -1)
+ {
+ refreshPlcHost(index);
+ if ( isHostActive(index) )
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[index].macAddress[0],
+ m_plchost[index].macAddress[1],
+ m_plchost[index].macAddress[2],
+ m_plchost[index].macAddress[3],
+ m_plchost[index].macAddress[4],
+ m_plchost[index].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( address == hostMacAddress )
+ {
+ if ( channel == 1 )
+ {
+ m_plchost[index].rx_channel.modulation[band*8 ] =
+ (unsigned char)( modulationFromInt(modulation1-1)*16 +
+ modulationFromInt(modulation2-1) );
+ m_plchost[index].rx_channel.modulation[band*8+1] =
+ (unsigned char)( modulationFromInt(modulation3-1)*16 +
+ modulationFromInt(modulation4-1) );
+ m_plchost[index].rx_channel.modulation[band*8+2] =
+ (unsigned char)( modulationFromInt(modulation5-1)*16 +
+ modulationFromInt(modulation6-1) );
+ m_plchost[index].rx_channel.modulation[band*8+3] =
+ (unsigned char)( modulationFromInt(modulation7-1)*16 +
+ modulationFromInt(modulation8-1) );
+ m_plchost[index].rx_channel.modulation[band*8+4] =
+ (unsigned char)( modulationFromInt(modulation9-1)*16 +
+ modulationFromInt(modulation10-1) );
+ m_plchost[index].rx_channel.modulation[band*8+5] =
+ (unsigned char)( modulationFromInt(modulation11-1)*16 +
+ modulationFromInt(modulation12-1) );
+ m_plchost[index].rx_channel.modulation[band*8+6] =
+ (unsigned char)( modulationFromInt(modulation13-1)*16 +
+ modulationFromInt(modulation14-1) );
+ m_plchost[index].rx_channel.modulation[band*8+7] =
+ (unsigned char)( modulationFromInt(modulation15-1)*16 +
+ modulationFromInt(modulation16-1) );
+ }
+ else if ( channel == 2 )
+ {
+ m_plchost[index].rx_last_channel.modulation[band*8 ] =
+ (unsigned char)( modulationFromInt(modulation1-1)*16 +
+ modulationFromInt(modulation2-1) );
+ m_plchost[index].rx_last_channel.modulation[band*8+1] =
+ (unsigned char)( modulationFromInt(modulation3-1)*16 +
+ modulationFromInt(modulation4-1) );
+ m_plchost[index].rx_last_channel.modulation[band*8+2] =
+ (unsigned char)( modulationFromInt(modulation5-1)*16 +
+ modulationFromInt(modulation6-1) );
+ m_plchost[index].rx_last_channel.modulation[band*8+3] =
+ (unsigned char)( modulationFromInt(modulation7-1)*16 +
+ modulationFromInt(modulation8-1) );
+ m_plchost[index].rx_last_channel.modulation[band*8+4] =
+ (unsigned char)( modulationFromInt(modulation9-1)*16 +
+ modulationFromInt(modulation10-1) );
+ m_plchost[index].rx_last_channel.modulation[band*8+5] =
+ (unsigned char)( modulationFromInt(modulation11-1)*16 +
+ modulationFromInt(modulation12-1) );
+ m_plchost[index].rx_last_channel.modulation[band*8+6] =
+ (unsigned char)( modulationFromInt(modulation13-1)*16 +
+ modulationFromInt(modulation14-1) );
+ m_plchost[index].rx_last_channel.modulation[band*8+7] =
+ (unsigned char)( modulationFromInt(modulation15-1)*16 +
+ modulationFromInt(modulation16-1) );
+ }
+ else
+ {
+ m_plchost[index].tx_channel.modulation[band*8 ] =
+ (unsigned char)( modulationFromInt(modulation1-1)*16 +
+ modulationFromInt(modulation2-1) );
+ m_plchost[index].tx_channel.modulation[band*8+1] =
+ (unsigned char)( modulationFromInt(modulation3-1)*16 +
+ modulationFromInt(modulation4-1) );
+ m_plchost[index].tx_channel.modulation[band*8+2] =
+ (unsigned char)( modulationFromInt(modulation5-1)*16 +
+ modulationFromInt(modulation6-1) );
+ m_plchost[index].tx_channel.modulation[band*8+3] =
+ (unsigned char)( modulationFromInt(modulation7-1)*16 +
+ modulationFromInt(modulation8-1) );
+ m_plchost[index].tx_channel.modulation[band*8+4] =
+ (unsigned char)( modulationFromInt(modulation9-1)*16 +
+ modulationFromInt(modulation10-1) );
+ m_plchost[index].tx_channel.modulation[band*8+5] =
+ (unsigned char)( modulationFromInt(modulation11-1)*16 +
+ modulationFromInt(modulation12-1) );
+ m_plchost[index].tx_channel.modulation[band*8+6] =
+ (unsigned char)( modulationFromInt(modulation13-1)*16 +
+ modulationFromInt(modulation14-1) );
+ m_plchost[index].tx_channel.modulation[band*8+7] =
+ (unsigned char)( modulationFromInt(modulation15-1)*16 +
+ modulationFromInt(modulation16-1) );
+ }
+ retVal = ( mib_setPlcHost( index, &m_plchost[index] ) == RET_SUCCESS);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+
+bool
+SystemManager::setPlcChannelPilots
+ ( OctetStr& address, //Voluntarily unconst to use [] operator
+ const long& channel,
+ const long& band,
+ const long& pilot1,
+ const long& pilot2 )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ bool retVal = false;
+ {
+ unsigned int nbHosts = NbPlcHosts();
+
+ int index = -1;
+ for ( unsigned int i=0 ; i<nbHosts ; ++i ) // plcBasePort
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[i].macAddress[0],
+ m_plchost[i].macAddress[1],
+ m_plchost[i].macAddress[2],
+ m_plchost[i].macAddress[3],
+ m_plchost[i].macAddress[4],
+ m_plchost[i].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( address == hostMacAddress )
+ {
+ index = i;
+ break;
+ }
+ }
+
+ if (index != -1)
+ {
+ refreshPlcHost(index);
+ if ( isHostActive(index) )
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[index].macAddress[0],
+ m_plchost[index].macAddress[1],
+ m_plchost[index].macAddress[2],
+ m_plchost[index].macAddress[3],
+ m_plchost[index].macAddress[4],
+ m_plchost[index].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( address == hostMacAddress )
+ {
+ if ( channel == 1 )
+ {
+ m_plchost[index].rx_channel.pilots[band*2] = (unsigned char)pilot1;
+ m_plchost[index].rx_channel.pilots[band*2+1] = (unsigned char)pilot2;
+ }
+ else if ( channel == 2 )
+ {
+ m_plchost[index].rx_last_channel.pilots[band*2] = (unsigned char)pilot1;
+ m_plchost[index].rx_last_channel.pilots[band*2+1] = (unsigned char)pilot2;
+ }
+ else
+ {
+ m_plchost[index].tx_channel.pilots[band*2] = (unsigned char)pilot1;
+ m_plchost[index].tx_channel.pilots[band*2+1] = (unsigned char)pilot2;
+ }
+ retVal = ( mib_setPlcHost( index, &m_plchost[index] ) == RET_SUCCESS );
+ }
+ }
+ }
+ }
+ return retVal;
+}
+
+bool
+SystemManager::setPlcTxGain
+ ( OctetStr & address, // voluntarily unconst to use [] operator
+ const long& gain )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ bool retVal = false;
+ {
+ unsigned int nbHosts = NbPlcHosts();
+
+ int index = -1;
+ for ( unsigned int i=0 ; i<nbHosts ; ++i ) // plcBasePort
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[i].macAddress[0],
+ m_plchost[i].macAddress[1],
+ m_plchost[i].macAddress[2],
+ m_plchost[i].macAddress[3],
+ m_plchost[i].macAddress[4],
+ m_plchost[i].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( address == hostMacAddress )
+ {
+ index = i;
+ break;
+ }
+ }
+
+ if (index != -1)
+ {
+ refreshPlcHost(index);
+ if ( isHostActive(index) )
+ {
+ const unsigned char physAddr[] =
+ { m_plchost[index].macAddress[0],
+ m_plchost[index].macAddress[1],
+ m_plchost[index].macAddress[2],
+ m_plchost[index].macAddress[3],
+ m_plchost[index].macAddress[4],
+ m_plchost[index].macAddress[5] };
+
+ OctetStr hostMacAddress(physAddr, 6) ;
+
+ if ( address == hostMacAddress )
+ {
+ m_plchost[index].gain= gain;
+ retVal = ( m_underlayer->mib_setPlcHost( index, &m_plchost[index] ) == RET_SUCCESS );
+ }
+ }
+ }
+ }
+ return retVal;
+}
+
+bool
+SystemManager::setNodeNotches
+ ( const long& band,
+ const long& group,
+ const long& carrier1,
+ const long& carrier2,
+ const long& carrier3,
+ const long& carrier4,
+ const long& carrier5,
+ const long& carrier6,
+ const long& carrier7,
+ const long& carrier8 )
+{
+ static unsigned int set_on[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ bool retVal = false;
+ {
+ unsigned int indx = band*PMD_GROUPS_PER_BAND + group - 1;
+ m_systemcarrier.groupNotch[indx] = 0;
+
+ if ( carrier1 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[0];
+ if ( carrier2 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[1];
+ if ( carrier3 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[2];
+ if ( carrier4 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[3];
+ if ( carrier5 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[4];
+ if ( carrier6 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[5];
+ if ( carrier7 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[6];
+ if ( carrier8 == 1 )
+ m_systemcarrier.groupNotch[indx] = m_systemcarrier.groupNotch[indx] | set_on[7];
+
+ LOG_SYSTEM_MANAGER_BEGIN(DEBUG_LOG);
+ LOG("New Node Notches on Band:");
+ LOG(band);
+ LOG("Grp");
+ LOG(group);
+ LOG_END;
+
+ retVal = ( m_underlayer->mib_setSystemCarrier( &m_systemcarrier ) == RET_SUCCESS );
+
+ }
+ return retVal;
+}
+
+
+bool
+SystemManager::setNodePilots
+ ( const long& band,
+ const long& pilot1,
+ const long& pilot2 )
+{
+ static unsigned int set_on[] = { 1, 2, 4, 8, 16, 32, 64, 128};
+
+ //ThreadSynchronize _ts_synchronize(*instance());
+
+ bool retVal = false;
+ {
+ unsigned int indx = 0;
+ for ( unsigned int j=0 ; j< PMD_GROUPS_PER_BAND ; ++j )
+ {
+ indx = band*PMD_GROUPS_PER_BAND + j;
+ m_systemcarrier.groupPilot[ indx ] = 0;
+ }
+
+ indx = band*PMD_GROUPS_PER_BAND + (unsigned int)( (pilot1 - 1) / PMD_CARRIERS_PER_GROUP);
+ m_systemcarrier.groupPilot[ indx ] = m_systemcarrier.groupPilot[ indx ] |
+ set_on[ (pilot1 - 1) % PMD_CARRIERS_PER_GROUP ];
+
+ indx = band*PMD_GROUPS_PER_BAND + (unsigned int)( (pilot2 - 1) / PMD_CARRIERS_PER_GROUP);
+ m_systemcarrier.groupPilot[ indx ] = m_systemcarrier.groupPilot[ indx ] |
+ set_on[ (pilot2 - 1)% PMD_CARRIERS_PER_GROUP ];
+
+ LOG_SYSTEM_MANAGER_BEGIN(DEBUG_LOG);
+ LOG("New Node Pilots B:");
+ LOG(band);
+ LOG("P1");
+ LOG(pilot1);
+ LOG("P2");
+ LOG(pilot2);
+ LOG_END;
+
+ retVal = ( m_underlayer->mib_setSystemCarrier( &m_systemcarrier ) == RET_SUCCESS );
+
+ }
+ return retVal;
+}
+
+
+bool
+SystemManager::plcNodeAdaptsCarriers
+ ( const long& band,
+ const long& group,
+ const long& carrier1,
+ const long& carrier2,
+ const long& carrier3,
+ const long& carrier4,
+ const long& carrier5,
+ const long& carrier6,
+ const long& carrier7,
+ const long& carrier8 )
+{
+ //ThreadSynchronize _ts_synchronize(*instance());
+ bool retVal;
+
+ {
+ unsigned int indx =
+ band*PMD_GROUPS_PER_BAND*PMD_CARRIERS_PER_GROUP + (group-1)*PMD_CARRIERS_PER_GROUP;
+
+ m_systemcarrier.carrierAdapt[indx +0] = carrier1;
+ m_systemcarrier.carrierAdapt[indx +1] = carrier2;
+ m_systemcarrier.carrierAdapt[indx +2] = carrier3;
+ m_systemcarrier.carrierAdapt[indx +3] = carrier4;
+ m_systemcarrier.carrierAdapt[indx +4] = carrier5;
+ m_systemcarrier.carrierAdapt[indx +5] = carrier6;
+ m_systemcarrier.carrierAdapt[indx +6] = carrier7;
+ m_systemcarrier.carrierAdapt[indx +7] = carrier8;
+
+
+ retVal = ( m_underlayer->mib_setSystemCarrier( &m_systemcarrier ) == RET_SUCCESS );
+
+ }
+ return retVal;
+}
+
+
+void
+SystemManager::commit()
+{
+ m_underlayer->mib_commit();
+}
+
+void
+SystemManager::boardReset()
+{
+ m_underlayer->mib_boardReset();
+}
+
+
+void
+SystemManager::setFlatAdapt()
+{
+ m_underlayer->mib_setFlatAdapt();
+}
+
+int
+SystemManager::softwareUpload
+ ( const char* ipFtpServer,
+ const char* login,
+ const char* passwd,
+ const char* softwareName,
+ const long& portFtpServer ) //PR03
+{
+ int retVal = (int)RC_UPG_GENERIC_ERROR;
+
+
+#ifdef __LINUX__
+ retVal = RC_UPG_OK;
+ if ( retVal == (int)RC_UPG_OK)
+ {
+ retVal = (int)m_underlayer->mib_upgradeSoftware(const_cast<char*>(ipFtpServer),
+ (unsigned short)(portFtpServer),
+ const_cast<char*>(login),
+ const_cast<char*>(passwd),
+ const_cast<char*>(softwareName) );
+ }
+#else
+ retVal = m_underlayer->mib_openFTP( const_cast<char*>(ipFtpServer),
+ (unsigned short)(portFtpServer), //PR03
+ const_cast<char*>(login),
+ const_cast<char*>(passwd));
+ if ( retVal == (int)RC_UPG_OK)
+ {
+ retVal = (int)m_underlayer->mib_upgradeSoftware(const_cast<char*>(softwareName),
+ (unsigned short)(portFtpServer),
+ const_cast<char*>(login),
+ const_cast<char*>(passwd),
+ const_cast<char*>(softwareName));
+ if (retVal != (int)RC_UPG_ON_GOING)
+ (void)m_underlayer->mib_closeFTP();
+ }
+#endif // __LINUX__
+ return retVal;
+}
+
+int
+SystemManager::softwareSwitch
+ ( const long& id )
+{
+ int retVal = (int)RC_UPG_GENERIC_ERROR;
+ retVal = (int)m_underlayer->mib_commitSoftwareUpgrade( const_cast<char*>(m_softReleases[id-1]));
+ return retVal;
+}
+
+int
+SystemManager::softwareErase
+ ( const long& id )
+{
+ int retVal = (int)RC_UPG_GENERIC_ERROR;
+ retVal = (int)m_underlayer->mib_eraseRelease( const_cast<char*>(m_softReleases[id-1]));
+ return retVal;
+}
+
+void
+SystemManager::refreshSoftwareReleases()
+{
+ m_nbSofts = m_underlayer->mib_getSoftwareRelease( m_softReleases );
+}
+
+int
+SystemManager::getSoftwareReleases( char softReleases[10][32] )
+{
+ for ( int i=0; i<m_nbSofts; ++i )
+ {
+ sprintf( softReleases[i], m_softReleases[i]);
+ }
+
+ return m_nbSofts;
+}
+
+int
+SystemManager::getLastUploadStatus()
+{
+ int retVal = (int)RC_UPG_GENERIC_ERROR;
+
+ retVal = (int)m_underlayer->mib_getLastUploadStatus();
+ return retVal;
+}
+
+void SystemManager::getBootstats(int *boot, int *manualReset, int *failureReset)
+{
+ m_underlayer->mib_get_bootstats(boot,manualReset,failureReset);
+}
+
+
+/**
+ * Get the Spanning Tree Protocol enabled state for a given interface
+ *
+ * @param Interface
+ * The interface on which retrieve the enabled state
+ * @return
+ * The spanning tree protocol enabled state for the given interface
+ *
+ * @see dot1dStpPortEntry, dot1dStpPortEnabled
+ */
+bool SystemManager::getSpanningTreeProtocol( unsigned char Interface ) {
+
+ unsigned char interf=0;
+ switch(Interface) {
+ case (_DEFAULT_SNMP_ETHER_IF_INDEX):
+ interf = ETHERNET_INTERFACE;
+ break;
+ case (_DEFAULT_SNMP_PLC_IF_INDEX):
+ interf = PLC_INTERFACE;
+ break;
+ }
+
+ return m_underlayer->mib_get_stp_enabled(interf);
+}
+
+/**
+ * Set the Spanning Tree Protocol enabled state for a given interface
+ *
+ * @param enabled
+ * The enabled state of the interface
+ * @param Interface
+ * The interface on which performs the change
+ *
+ * @see dot1dStpPortEntry, dot1dStpPortEnabled
+ */
+void SystemManager::setSpanningTreeProtocol( bool enabled , unsigned char Interface ) {
+
+ unsigned char interf=0;
+ switch(Interface) {
+ case (_DEFAULT_SNMP_ETHER_IF_INDEX):
+ interf = ETHERNET_INTERFACE;
+ break;
+ case (_DEFAULT_SNMP_PLC_IF_INDEX):
+ interf = PLC_INTERFACE;
+ break;
+ }
+
+ m_underlayer->mib_set_stp_enabled(enabled,interf);
+}
+
+//---- FD01: BEGIN SNMP community
+
+void SystemManager::getSNMPCommunity( char * pSnmp_GET_community_name, char * pSnmp_SET_community_name ){
+
+ /* if overriden retrieve these data */
+ if (!m_underlayer->mib_get_SNMP_community( pSnmp_GET_community_name, pSnmp_SET_community_name ) )
+ {
+ // put default values if underlayer could not find values (could be no config file on the modem)
+ strcpy(pSnmp_GET_community_name,_DEFAULT_SNMP_GET_COMMUNITY);
+ strcpy(pSnmp_SET_community_name,_DEFAULT_SNMP_SET_COMMUNITY);
+ }
+
+}
+
+//---- FD01: END SNMP community
+
+/**
+ * Return the current ethernet auto negotiated mode (on/off)
+ *
+ * @return
+ * true if the auto negotiation mode is enabled, false otherwise
+ *
+ * @see getEthMode, getEthDefaultMode
+ */
+
+/*bool SystemManager::getEthAutoMode() {
+ return m_underlayer->mib_get_eth_auto_mode();
+}*/
+
+
+
+/**
+ * Set the ethernet auto negotiated mode (on/off)
+ *
+ * @param enabled
+ * true to enable the auto negotiated mode, false otherwise
+ * @return
+ * nothing
+ *
+ * @see setEthMode, setEthDefaultMode
+ */
+/*void SystemManager::setEthAutoMode(bool enabled) {
+ m_underlayer->mib_set_eth_auto_mode(enabled);
+}*/
+
+
+
+/**
+ * Return the current ethernet mode
+ *
+ * @return
+ * the current ethernet mode
+ *
+ * @see getEthAutoMode, setEthDefaultMode
+ */
+/*int SystemManager::getEthMode() {
+ int mode = m_underlayer->mib_get_eth_mode(); // actually get the value in the hardware
+// m_ethmac.dot3StatsDuplexStatus = mode; // update the ethmac structure // ETH_STATIC
+ return mode;
+}*/
+
+
+
+/**
+ * Set the current ethernet mode
+ *
+ * @param mode
+ * the ethernet mode
+ * @return
+ * nothing
+ *
+ * @see setEthAutoMode, setEthDefaultMode
+ */
+/*void SystemManager::setEthMode(int mode) {
+ //m_ethmac.dot3StatsDuplexStatus = mode; // update the ethmac structure // ETH_STATIC comment this line
+ m_underlayer->mib_set_eth_mode(mode); // actually set the value in the hardware
+}*/
+
+
+
+
+/**
+ * Return the default ethernet mode
+ *
+ * @return
+ * the default ethernet mode
+ *
+ * @see getEthAutoMode, setEthMode
+ */
+enumDuplex_t SystemManager::getWishedEthMode() {
+ return m_underlayer->mib_getWishedEthMode();
+}
+
+/**
+ * Set the default ethernet mode
+ *
+ * @param defaultMode
+ * the defaultMode
+ * @return
+ * nothing
+ *
+ * @see setEthMode, setEthAutoMode
+ */
+void SystemManager::setWishedEthMode(enumDuplex_t aMode) {
+ m_underlayer->mib_setWishedEthMode(aMode);
+}
+
+
+enumSpeed_t DEBUG_METH(SystemManager::getWishedEthSpeed() {)
+ return m_underlayer->mib_getWishedEthSpeed();
+}
+
+void DEBUG_METH(SystemManager::setWishedEthSpeed(enumSpeed_t aSpeed) {)
+ DEBUG_TXT(aSpeed);
+ m_underlayer->mib_setWishedEthSpeed(aSpeed);
+}
+
+bool SystemManager::getEthAutoMode()
+{
+ return ( (m_underlayer->mib_getWishedEthSpeed()==ETH_SPEED_AUTO) || (m_underlayer->mib_getWishedEthMode()==ETH_MODE_AUTO) );
+}
+
+/*long DEBUG_METH(SystemManager::getEthDefaultSpeed() {)
+ DEBUG_TXT(m_ethDefaultSpeed);
+ return m_ethDefaultSpeed;
+}
+
+void DEBUG_METH(SystemManager::setEthDefaultSpeed(long speed) {)
+ DEBUG_TXT(speed);
+ m_ethDefaultSpeed = speed;
+}
+
+bool SystemManager::getEthAutoSpeed() {
+ return m_underlayer->mib_get_eth_auto_speed();
+}
+
+void SystemManager::setEthAutoSpeed(bool enabled) {
+ m_underlayer->mib_set_eth_auto_speed(enabled);
+}*/
+
+
+
+int SystemManager::getBridgeAdminStatus() {
+ return m_underlayer->mib_get_bridge_admin_status();
+}
+
+void SystemManager::setBridgeAdminStatus(int status) {
+ m_underlayer->mib_set_bridge_admin_status(status);
+}
+
+
+
+bool SystemManager::getPlcIsSpyDynamic() {
+ return m_underlayer->mib_get_plc_is_spy_dynamic();
+}
+
+void SystemManager::setPlcIsSpyDynamic(bool enabled) {
+ m_underlayer->mib_set_plc_is_spy_dynamic(enabled);
+}
+
+unsigned int SystemManager::getPlcStaticSpySynchBandNb() {
+ return m_underlayer->mib_get_plc_static_spy_synch_band_nb();
+}
+
+void SystemManager::setPlcStaticSpySynchBandNb(unsigned int bandNb) {
+ m_underlayer->mib_set_plc_static_spy_synch_band_nb(bandNb);
+}
+
+
+
+bool SystemManager::getPlcSegmentationAndReassembly() {
+ return m_underlayer->mib_get_plc_segmentation_and_reassembly();
+}
+
+void SystemManager::setPlcSegmentationAndReassembly(bool enabled) {
+ m_underlayer->mib_set_plc_segmentation_and_reassembly(enabled);
+}
+
+bool SystemManager::getPlcPowerEqualization() {
+ return m_underlayer->mib_get_plc_power_equalization();
+}
+
+void SystemManager::setPlcPowerEqualization(bool enabled) {
+ m_underlayer->mib_set_plc_power_equalization(enabled);
+}
+
+unsigned int SystemManager::getPlcMasterBssId() {
+ return m_underlayer->mib_get_plc_bss_id();
+}
+
+void SystemManager::setPlcMasterBssId(unsigned int bssId) {
+ m_underlayer->mib_set_plc_bss_id(bssId);
+}
+
+unsigned int SystemManager::getPlcSlaveBssId() {
+ return m_underlayer->mib_get_plc_preferred_bss_id();
+}
+
+void SystemManager::setPlcSlaveBssId(unsigned int bssId) {
+ m_underlayer->mib_set_plc_preferred_bss_id(bssId);
+}
+
+// RADIUS
+
+unsigned long int SystemManager::getRadiusAuthIp() {
+ return m_underlayer->mib_get_radius_auth_ip();
+}
+
+int SystemManager::getRadiusAuthPort() {
+ return m_underlayer->mib_get_radius_auth_port();
+}
+
+int SystemManager::getRadiusAuthMethod() {
+ return m_underlayer->mib_get_radius_auth_method();
+}
+
+char* SystemManager::getRadiusAuthUserName() {
+ return m_underlayer->mib_get_radius_auth_username();
+}
+
+bool SystemManager::setRadiusAuthentication(int authMethod,
+ const char *radiusUserName,
+ const char *radiusPassword,
+ unsigned long radiusAuthServerAddressInt,
+ long radiusAuthClientServerPortNumber ) {
+ bool status;
+
+ if ( m_plcmac.mode == PLC_MODE_MASTER ) {
+ // set the radius authentication for master mode
+ status = m_underlayer->mib_set_radius_master_authentication(authMethod,
+ radiusAuthServerAddressInt,
+ radiusAuthClientServerPortNumber,
+ radiusPassword);
+ }
+ else if ( m_plcmac.mode == PLC_MODE_SLAVE ) {
+ // set the radius authentication for the slave mode
+ status = m_underlayer->mib_set_radius_slave_authentication(radiusUserName,radiusPassword);
+ }
+
+ return status;
+}
+
+// DHCP
+
+void SystemManager::setIsIpDynamic(bool isDynamic) {
+ //m_underlayer->mib_set_is_ip_dynamic(isDynamic);
+ if (isDynamic)
+ {
+ spidlib_set_ip_mode(SPIDLIB_IP_MODE_DHCP);
+ }
+ else
+ {
+ spidlib_set_ip_mode(SPIDLIB_IP_MODE_STATIC);
+ }
+}
+
+bool SystemManager::getIsIpDynamic() {
+ //return m_underlayer->mib_get_is_ip_dynamic();
+ char tempIpMode[IP_MODE_STRING_MAX_LENGTH];
+ memset(tempIpMode, 0, IP_MODE_STRING_MAX_LENGTH);
+ if ( (0 == spidlib_get_ip_mode(tempIpMode, IP_MODE_STRING_MAX_LENGTH))
+ && (0 == strcmp(tempIpMode, SPIDLIB_IP_MODE_DHCP)) )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
+void SystemManager::convertOidxToMacAdd(unsigned char outputMacAdd[], const Oidx & indexOidx) {
+ const char* indexStr = indexOidx.get_printable();
+
+ LOG_SYSTEM_MANAGER_BEGIN(DEBUG_LOG);
+ LOG("convertOidxToMacAdd, input =");
+ LOG(indexStr);
+ LOG_END;
+
+ Oidx work = Oidx(indexOidx);
+ int myInt=0;
+ for(int i=0;i<6;i++) {
+ myInt = (int)work.last();
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("THE INT I GET IN THE CONVERSTION IS");LOG(myInt);
+ LOG_END;
+ outputMacAdd[5-i] = work.last();
+ work = work.cut_right(1);
+ }
+
+ LOG_SYSTEM_MANAGER_BEGIN(DEBUG_LOG);
+ LOG("convertOidxToMacAdd, output =");
+
+ OctetStr aAddress(outputMacAdd,6);
+ LOG( "address: " ); LOG(aAddress.get_printable());
+ LOG((int)outputMacAdd[0]);
+ LOG((int)outputMacAdd[1]);
+ LOG((int)outputMacAdd[2]);
+ LOG((int)outputMacAdd[3]);
+ LOG((int)outputMacAdd[4]);
+ LOG((int)outputMacAdd[5]);
+ LOG_END;
+
+}
+
+ /**
+ * The caller must delete the Oidx
+ */
+Oidx* SystemManager::convertMacAddToOidx(const unsigned char macAdd[]) {
+ char macAddStr[_DEFAULT_OID_BUFFER_SIZE];
+ LOG_SYSTEM_MANAGER_BEGIN(DEBUG_LOG);
+ LOG("convertMacAddToOidx, input =");
+ LOG((int)macAdd[0]);
+ LOG((int)macAdd[1]);
+ LOG((int)macAdd[2]);
+ LOG((int)macAdd[3]);
+ LOG((int)macAdd[4]);
+ LOG((int)macAdd[5]);
+ LOG_END;
+ sprintf( macAddStr, "%lu.%lu.%lu.%lu.%lu.%lu",
+ macAdd[0],
+ macAdd[1],
+ macAdd[2],
+ macAdd[3],
+ macAdd[4],
+ macAdd[5]);
+ Oidx* result = new Oidx(macAddStr);
+ LOG_SYSTEM_MANAGER_BEGIN(DEBUG_LOG);
+ LOG("convertMacAddToOidx output =");
+ LOG(result->get_printable());
+ LOG_END;
+ return result;
+}
+
+
+int SystemManager::getPLcHostIndex(const unsigned char iMacAddress[6])
+{
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager getPLcHostIndex begin with Mac Address: ");
+ LOG((int)iMacAddress[0]);
+ LOG((int)iMacAddress[1]);
+ LOG((int)iMacAddress[2]);
+ LOG((int)iMacAddress[3]);
+ LOG((int)iMacAddress[4]);
+ LOG((int)iMacAddress[5]);
+ LOG_END;
+
+ int i = m_underlayer->mib_getIndexByMac(iMacAddress);
+ if ( (i<0) || (i>= PLCP_MAX_HOST))
+ {
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager getPLcHostIndex return -1");
+ LOG_END;
+ return -1;
+ }
+ else
+ {
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager getPLcHostIndex return hostId: "); LOG(i);
+ LOG_END;
+ return i;
+ }
+}
+
+int SystemManager::updatePlcHostBasePortByIndex(int i)
+{
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager updatePlcHostBasePortByIndex begin");
+ LOG_END;
+
+ // if host was not active, it should now be active, and managed
+ bool hostToRefresh = !m_isHostActive[i];
+
+ // bool result
+ struct plc_base_port aHostBasePort;
+ m_isHostActive[i] = (RET_SUCCESS == m_underlayer->mib_getPlcBasePortByIndex(i, &aHostBasePort));
+
+ if (!m_isHostActive[i])
+ {
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager error mib_getPlcBasePortByIndex returns -1");
+ LOG_END;
+ return -1;
+ }
+ else
+ {
+ // update plc base port entry data of host in host list
+ for (int j=0; j<6; ++j)
+ {
+ if (aHostBasePort.macAddress[j] != m_plchost[i].macAddress[j])
+ {
+ m_plchost[i].macAddress[j] = (unsigned char)aHostBasePort.macAddress[j];
+ // if mac address changed => host must be refreshed
+ hostToRefresh = true;
+ }
+ }
+ m_plchost[i].automatic = aHostBasePort.automatic;
+ m_plchost[i].avg_att = aHostBasePort.avg_att;
+
+ if (hostToRefresh)
+ {
+ // host was not active and is active now or host mac changed => host must be refreshed
+ m_lastTimeUpdate[i] = 0;
+ }
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager mib_getPlcBasePortByIndex returns a mac address");
+ LOG_END;
+ return 0;
+ }
+}
+
+int SystemManager::updatePlcLightHostByIndex(int i)
+{
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager updatePlcLightHostByIndex begin");
+ LOG_END;
+
+ // if host was not active, it should now be active, and managed
+ bool hostToRefresh = !m_isHostActive[i];
+
+ struct plc_host aLightHost;
+
+ ///bool result
+ m_isHostActive[i] = (m_underlayer->mib_getPlcLightHost(i, &aLightHost) == RET_SUCCESS);
+
+ if (!m_isHostActive[i])
+ {
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager error mib_getPlcLightHost returns -1");
+ LOG_END;
+ return -1;
+ }
+ else
+ {
+ // update data of light host in host list
+ m_plchost[i].automatic = aLightHost.automatic;
+ m_plchost[i].avg_att = aLightHost.avg_att;
+
+ for (int j=0;j<6;++j)
+ {
+
+ if ( aLightHost.macAddress[j] != m_plchost[i].macAddress[j])
+ {
+ m_plchost[i].macAddress[j] = (unsigned char) aLightHost.macAddress[j];
+ // if mac address changed => host must be refreshed
+ hostToRefresh = true;
+
+ }
+ }
+
+ if (hostToRefresh)
+ {
+ //host was not active and is active now or host mac changed => host must be refreshed
+ m_lastTimeUpdate[i] = 0;
+ }
+
+ LOG_BEGIN(DEBUG_LOG);
+ LOG("SystemManager mib_getPlcLightHost return a mac address");
+ LOG_END;
+ return 0;
+ }
+}
+
+