summaryrefslogtreecommitdiff
path: root/polux/application/agent/src/UnderlayerSarft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polux/application/agent/src/UnderlayerSarft.cpp')
-rw-r--r--polux/application/agent/src/UnderlayerSarft.cpp958
1 files changed, 958 insertions, 0 deletions
diff --git a/polux/application/agent/src/UnderlayerSarft.cpp b/polux/application/agent/src/UnderlayerSarft.cpp
new file mode 100644
index 0000000000..4cf8cf787c
--- /dev/null
+++ b/polux/application/agent/src/UnderlayerSarft.cpp
@@ -0,0 +1,958 @@
+/*
+ ****************************************************************************
+ * PROGRAM MODULE
+ *
+ * $Workfile: Underlayer.cpp $
+ * $Author: CBu $
+ * $Date: 2008/07/29 $
+ *
+ * Copyright (C) 2008 by SPiDCOM Technologies All rights reserved.
+ *
+ *****************************************************************************
+ */
+#include "underlayer.h"
+#include "mib-interface.h"
+#include "systemmanager.h"
+#include <syslog.h>
+#include <sys/stat.h>
+
+/* spidlib is a C-library */
+extern "C"
+{
+ #include "spidlib.h"
+}
+
+/*
+ * GET/SET METHODS
+ */
+
+
+/* SARFT MIB */
+
+
+// PROPERTY-MIB
+
+
+// AnalogPropertyTable
+
+
+// TODO
+
+
+// DiscretePropertyTable
+
+
+// TODO
+
+
+// CurrentAlarmTable
+
+
+// TODO
+
+
+// ALARM-MIB
+
+
+int Underlayer::getAlarmLogNumberOfEntries ( int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ // TODO
+ return 0;
+}
+
+
+int Underlayer::getAlarmLogLastIndex ( int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ // TODO
+ return 0;
+}
+
+
+// AlarmLogTable
+
+
+// TODO
+
+
+// GENERAL-MIB
+
+
+// MasterAdminGroup
+
+
+int Underlayer::getAdminLogicalId ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_admin_logical_id(get_value, SPIDLIB_ADMIN_LOGICAL_ID_STRING_MAX_LENGTH);
+}
+
+
+int Underlayer::setAdminLogicalId ( const char *set_value )
+{
+ if (NULL == set_value)
+ {
+ return -1;
+ }
+
+ return spidlib_set_admin_logical_id(set_value);
+}
+
+
+int Underlayer::getAdminManufactoryInfo ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_manufactory_info(get_value, DEFAULT_SNMP_STRING_MAX_LENGTH);
+}
+
+int Underlayer::getAdminHardwareVersion ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_hardware_version(get_value, SPIDLIB_ADMIN_HARDWARE_VERSION_STRING_MAX_LENGTH);
+}
+
+
+int Underlayer::getAdminModelNumber ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_model_number(get_value, DEFAULT_SNMP_STRING_MAX_LENGTH);
+}
+
+
+int Underlayer::getAdminSerialNumber ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_serial_number(get_value, DEFAULT_SNMP_STRING_MAX_LENGTH);
+}
+
+
+int Underlayer::getAdminSoftwareVersion ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_software_version(get_value, DEFAULT_SNMP_STRING_MAX_LENGTH);
+}
+
+
+int Underlayer::getAdminVendorSpecialInfo ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_vendor_info(get_value, DEFAULT_SNMP_STRING_MAX_LENGTH);
+}
+
+
+int Underlayer::getAdminIpData ( const char *iface, char *address, char *netmask, char *broadcast, char *gateway )
+{
+ if ( (NULL == iface)
+ || (NULL == address)
+ || (NULL == netmask)
+ || (NULL == broadcast)
+ || (NULL == gateway) )
+ {
+ return -1;
+ }
+
+ return spidlib_get_ip_data(iface, address, netmask, broadcast, gateway);
+}
+
+
+int Underlayer::setAdminIpData ( const char *iface, char *address, char *netmask, char *broadcast, char *gateway )
+{
+ if ( (NULL == iface)
+ || (NULL == address)
+ || (NULL == netmask)
+ || (NULL == broadcast)
+ || (NULL == gateway) )
+ {
+ return -1;
+ }
+
+ return spidlib_set_ip_data(iface, address, netmask, broadcast, gateway);
+}
+
+
+int Underlayer::getAdminEmsIpAddress ( char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+ return spidlib_read_config_param(SPIDLIB_CONFIG_SNMP_PATH, SPIDLIB_ADMIN_EMS_IP_ADDRESS_ID_NAME_KEY,
+ get_value, SPIDLIB_ADMIN_EMS_IP_ADDRESS_MAX_LENGTH);
+}
+
+
+int Underlayer::setAdminEmsIpAddress ( const char *set_value )
+{
+ if (NULL == set_value)
+ {
+ return -1;
+ }
+
+ return spidlib_write_config_param(SPIDLIB_CONFIG_SNMP_PATH, SPIDLIB_ADMIN_EMS_IP_ADDRESS_ID_NAME_KEY,
+ set_value);
+}
+
+
+int Underlayer::getAdminResetCause ( admin_reset_cause_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ // TODO
+ return -1;
+}
+
+
+int Underlayer::getAdminStatus ( unsigned char *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ // TODO
+ return 0;
+}
+
+
+int Underlayer::saveConfiguration ( )
+{
+ return spidlib_save_config();
+}
+
+
+// RfGroup
+
+
+int Underlayer::getRfMasterOutputLevel ( int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_output_level(get_value);
+}
+
+
+int Underlayer::setRfMasterOutputLevel ( int set_value )
+{
+ // Spidlib output level range is 103 - 129 dBuV
+ if (set_value < RF_OUTPUT_LEVEL_MIN_VALUE)
+ {
+ set_value = RF_OUTPUT_LEVEL_MIN_VALUE;
+ }
+ else if (set_value > RF_OUTPUT_LEVEL_MAX_VALUE)
+ {
+ set_value = RF_OUTPUT_LEVEL_MAX_VALUE;
+ }
+
+ return spidlib_set_output_level(set_value);
+}
+
+
+// MacGroup
+
+
+int Underlayer::getMacVlanEnable ( spidlib_boolean_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_vlan_enable(get_value);
+}
+
+
+int Underlayer::setMacVlanEnable ( spidlib_boolean_t set_value )
+{
+ return spidlib_set_vlan_enable(set_value);
+}
+
+
+int Underlayer::getMacVlanIdLimitation ( int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_vlan_id_limitation(get_value);
+}
+
+
+int Underlayer::setMacVlanIdLimitation ( int set_value )
+{
+ return spidlib_set_vlan_id_limitation(set_value);
+}
+
+
+int Underlayer::getMacVlan ( spidlib_vlan_link_t vlan_direction, spidlib_vlan_rule_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_vlan(vlan_direction, get_value);
+}
+
+
+int Underlayer::getMacVlanCommon ( spidlib_vlan_common_rule_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_vlan_common(get_value);
+}
+
+
+int Underlayer::getMacVlanAll ( spidlib_vlan_link_t vlan_direction, spidlib_vlan_rule_t *get_value, int *nb_rules )
+{
+ if ((NULL == nb_rules) || (NULL == get_value))
+ {
+ return -1;
+ }
+
+ return spidlib_get_vlan_all(vlan_direction, get_value, nb_rules);
+}
+
+
+int Underlayer::getMacVlanCommonAll ( spidlib_vlan_common_rule_t *get_value, int *nb_rules )
+{
+ if ((NULL == nb_rules) || (NULL == get_value))
+ {
+ return -1;
+ }
+
+ return spidlib_get_vlan_common_all(get_value, nb_rules);
+}
+
+
+int Underlayer::setMacVlan ( spidlib_vlan_link_t vlan_direction, const spidlib_vlan_rule_t *set_value )
+{
+ if (NULL == set_value)
+ {
+ return -1;
+ }
+
+ return spidlib_set_vlan(vlan_direction, set_value);
+}
+
+
+int Underlayer::setMacVlanCommon ( const spidlib_vlan_common_rule_t *set_value )
+{
+ if (NULL == set_value)
+ {
+ return -1;
+ }
+
+ return spidlib_set_vlan_common(set_value);
+}
+
+
+int Underlayer::getMacBroadcastRestrictionEn ( spidlib_boolean_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ char enabled[16];
+ if (spidlib_read_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_BROADCAST_LIMIT_EN_KEY, enabled, sizeof(enabled)) != 0)
+ {
+ *get_value = SPIDLIB_FALSE;
+ }
+ else if (SPIDLIB_GET_BOOLEAN(enabled))
+ {
+ *get_value = SPIDLIB_TRUE;
+ }
+ else
+ {
+ *get_value = SPIDLIB_FALSE;
+ }
+
+ return 0;
+}
+
+int Underlayer::getMacBroadcastRestriction ( int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ char value[16];
+ if (spidlib_read_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_BROADCAST_LIMIT_KEY, value, sizeof(value)) != 0)
+ {
+ *get_value = -1;
+ }
+ else if (sscanf(value, "%d", get_value) != 1)
+ {
+ *get_value = -1;
+ }
+
+ return 0;
+}
+
+
+int Underlayer::setMacBroadcastRestrictionEn ( spidlib_boolean_t set_value )
+{
+ if (set_value == SPIDLIB_TRUE)
+ {
+ if (spidlib_write_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_BROADCAST_LIMIT_EN_KEY, "yes") != 0)
+ {
+ syslog(LOG_WARNING, "Error writing broadcast restriction enable to config file");
+ return -1;
+ }
+ }
+ else if (set_value == SPIDLIB_FALSE)
+ {
+ if (spidlib_write_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_BROADCAST_LIMIT_EN_KEY, "no") != 0)
+ {
+ syslog(LOG_WARNING, "Error writing broadcast restriction enable to config file");
+ return -1;
+ }
+ }
+ else
+ {
+ syslog(LOG_WARNING, "Unknown spidlib boolean value for broadcast restriction enable: %d", set_value);
+ return -1;
+ }
+
+ return 0;
+}
+
+int Underlayer::setMacBroadcastRestriction ( int set_value )
+{
+ char value[16];
+ sprintf(value, "%d", set_value);
+
+ if (spidlib_write_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_BROADCAST_LIMIT_KEY, value) != 0)
+ {
+ syslog(LOG_WARNING, "Error writing broadcast restriction to config file");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int Underlayer::getMacUnknownRestrictionEn ( spidlib_boolean_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ char enabled[16];
+ if (spidlib_read_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_UNKNOWN_LIMIT_EN_KEY, enabled, sizeof(enabled)) != 0)
+ {
+ *get_value = SPIDLIB_FALSE;
+ }
+ else if (SPIDLIB_GET_BOOLEAN(enabled))
+ {
+ *get_value = SPIDLIB_TRUE;
+ }
+ else
+ {
+ *get_value = SPIDLIB_FALSE;
+ }
+
+ return 0;
+}
+
+int Underlayer::getMacUnknownRestriction ( int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ char value[16];
+ if (spidlib_read_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_UNKNOWN_LIMIT_KEY, value, sizeof(value)) != 0)
+ {
+ *get_value = -1;
+ }
+ else if (sscanf(value, "%d", get_value) != 1)
+ {
+ *get_value = -1;
+ }
+
+ return 0;
+}
+
+
+int Underlayer::setMacUnknownRestrictionEn ( spidlib_boolean_t set_value )
+{
+ if (set_value == SPIDLIB_TRUE)
+ {
+ if (spidlib_write_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_UNKNOWN_LIMIT_EN_KEY, "yes") != 0)
+ {
+ syslog(LOG_WARNING, "Error writing unknown restriction enable to config file");
+ return -1;
+ }
+ }
+ else if (set_value == SPIDLIB_FALSE)
+ {
+ if (spidlib_write_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_UNKNOWN_LIMIT_EN_KEY, "no") != 0)
+ {
+ syslog(LOG_WARNING, "Error writing unknown restriction enable to config file");
+ return -1;
+ }
+ }
+ else
+ {
+ syslog(LOG_WARNING, "Unknown spidlib boolean value for unknown restriction enable: %d", set_value);
+ return -1;
+ }
+
+ return 0;
+}
+
+int Underlayer::setMacUnknownRestriction ( int set_value )
+{
+ char value[16];
+ sprintf(value, "%d", set_value);
+
+ if (spidlib_write_config_param(SPIDLIB_CONFIG_SYSTEM_PATH, SPIDLIB_ADMIN_UNKNOWN_LIMIT_KEY, value) != 0)
+ {
+ syslog(LOG_WARNING, "Error writing unknown restriction to config file");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int Underlayer::getMacPortIsolation ( spidlib_boolean_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ if (spidlib_get_plc_mac_port_isolation(get_value) != 0)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int Underlayer::setMacPortIsolation ( spidlib_boolean_t set_value )
+{
+ if (spidlib_set_plc_mac_port_isolation(set_value) != 0)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+
+// commonSoftwareGroup
+
+
+enum mib_softUpgRc Underlayer::softwareMasterUpload ( char *ftp_ip, uint16_t ftp_port, char *login, char *passwd, char *master_file)
+{
+ enum mib_softUpgRc ret = RC_UPG_GENERIC_ERROR;
+
+ if ((NULL == ftp_ip)
+ || (NULL == login)
+ || (NULL == passwd)
+ || (NULL == master_file))
+ {
+ return RC_UPG_INVALID_PARAMETER;
+ }
+
+ char md5_file_constructed[256];
+ char file_no_ext[256];
+
+ /* Check file provided doesn't have an extension otherwise remove it */
+ int size_name = strlen(master_file);
+ if (master_file[size_name - 4] == '.')
+ {
+ memcpy(file_no_ext, master_file, size_name - 4);
+ file_no_ext[size_name -4] = '\0';
+ sprintf(md5_file_constructed, "%s.md5", file_no_ext);
+ }
+ else
+ sprintf(md5_file_constructed, "%s.md5", master_file);
+
+ syslog(LOG_WARNING, "softwareMasterUpload: the md5 file of the image looked for on the FTP server is %s", md5_file_constructed);
+
+ /* Upgrade the master software */
+ ret = mib_upgradeSecureSoftware(ftp_ip, ftp_port, login, passwd, master_file, md5_file_constructed); // this function calls 'boottable_secure_create()'
+
+ return ret;
+};
+
+enum mib_softUpgRc Underlayer::softwareSlaveUpload ( char *ftp_ip, uint16_t ftp_port, char *login, char *passwd, char *slave_file)
+{
+ enum mib_softUpgRc ret = RC_UPG_GENERIC_ERROR;
+
+ if ((NULL == ftp_ip)
+ || (NULL == login)
+ || (NULL == passwd)
+ || (NULL == slave_file))
+ {
+ return RC_UPG_INVALID_PARAMETER;
+ }
+
+ /* Upload the slave software on the master via FTP */
+ char localPath[] = SPIDLIB_TEMP_SLAVE_IMAGE_PATH;
+ char commandBuffer[512];
+ // in case of previous upload was unsuccessfull, erase download folder
+ /*sprintf(commandBuffer, "rm -rf %s", localPath);
+ system(commandBuffer);*/
+ remove (localPath);
+ // get the slave file by FTP
+ sprintf(commandBuffer, "ftpget -u %s -p %s %s %s %s", login, passwd, ftp_ip, localPath, slave_file);
+ syslog(LOG_DEBUG, "softwareUpload: %s", commandBuffer);
+ spidlib_system(commandBuffer);
+ // check that slave file has been downloaded
+ struct stat fileStat;
+ memset(&fileStat, 0, sizeof(struct stat));
+ sprintf(commandBuffer, "%s", localPath);
+ if ( (stat(commandBuffer, &fileStat) < 0)
+ || (0 == fileStat.st_size) )
+ {
+ return RC_UPG_INVALID_PARAMETER;
+ }
+
+ return ret;
+};
+
+
+// TODO: for online slaves, call the SMM function smm_get_vlan() / smm_set_vlan()
+
+
+// commonSlaveGroup
+
+
+/*int Underlayer::getWhiteList ( spidlib_white_list_register_t *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_white_list(get_value);
+}
+
+
+int Underlayer::getWhiteListAll ( spidlib_white_list_register_t *get_value, int *nb_registered )
+{
+ if ( (NULL == get_value) || (NULL == nb_registered) )
+ {
+ return -1;
+ }
+
+ return spidlib_get_white_list_all(get_value, nb_registered);
+}
+
+
+int Underlayer::setWhiteList ( const spidlib_white_list_register_t *set_value )
+{
+ if (NULL == set_value)
+ {
+ return -1;
+ }
+
+ return spidlib_set_white_list(set_value);
+}*/
+
+
+int Underlayer::onlineAllReset ( )
+{
+ int ret = 0;
+
+ SystemManager::instance()->refreshPlcHosts(true /* lightrefresh */);
+
+ for (int index=0; index<PLCP_MAX_HOST; index++)
+ {
+ if (SystemManager::instance()->isHostActive(index) && (memcmp(SystemManager::instance()->PlcHost(index).macAddress, "\xff\xff\xff\xff\xff\xff", 6) != 0))
+ {
+ ret += smm_reboot((const unsigned char *)SystemManager::instance()->PlcHost(index).macAddress, SMM_MAX_RETRIES);
+ }
+ }
+
+ return ret;
+}
+
+
+int Underlayer::getMacLimit ( unsigned int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ return spidlib_get_plc_mac_limit(get_value);
+}
+
+
+int Underlayer::setMacLimit ( unsigned int set_value )
+{
+ int ret = 0;
+
+ // for all online slaves (commonOnlineAllExtMACLimitation)
+ for (int index=0; index<PLCP_MAX_HOST; index++)
+ {
+ if ((SystemManager::instance()->isHostActive(index))
+ && (SystemManager::instance()->isHostAuthorized(index)))
+ {
+ ret += smm_set_mac_limit((const unsigned char *)SystemManager::instance()->PlcHost(index).macAddress, SMM_MAX_RETRIES, set_value);
+ }
+ }
+
+ // save locally the online slaves mac limit which has been set
+ if (0 == ret)
+ {
+ ret = spidlib_set_plc_mac_limit(set_value);
+ }
+
+ return ret;
+}
+
+
+int Underlayer::getMacLimit ( const unsigned char *mac_address, unsigned int *get_value )
+{
+ if ( (NULL == mac_address) || (NULL == get_value) )
+ {
+ return -1;
+ }
+
+ // for one slave (commonOnlineExtPCLimitation)
+ return smm_get_mac_limit(mac_address, SMM_MAX_RETRIES, get_value);
+}
+
+
+int Underlayer::setMacLimit ( const unsigned char *mac_address, unsigned int set_value )
+{
+ if (NULL == mac_address)
+ {
+ return -1;
+ }
+
+ // for one slave (commonOnlineExtPCLimitation)
+ return smm_set_mac_limit(mac_address, SMM_MAX_RETRIES, set_value);
+}
+
+
+int Underlayer::getOnlineAllRfOutputLevel ( int *get_value )
+{
+ if (NULL == get_value)
+ {
+ return -1;
+ }
+
+ //TODO
+ return 0;
+}
+
+
+int Underlayer::setOnlineAllRfOutputLevel ( int set_value )
+{
+ int ret = 0;
+
+ // Spidlib output level range is 103 - 129 dBuV
+ if (set_value < RF_OUTPUT_LEVEL_MIN_VALUE)
+ {
+ set_value = RF_OUTPUT_LEVEL_MIN_VALUE;
+ }
+ else if (set_value > RF_OUTPUT_LEVEL_MAX_VALUE)
+ {
+ set_value = RF_OUTPUT_LEVEL_MAX_VALUE;
+ }
+
+ // Send SMM set requests to all online slaves
+ for (int index=0; index<PLCP_MAX_HOST; index++)
+ {
+ if ((SystemManager::instance()->isHostActive(index))
+ && (SystemManager::instance()->isHostAuthorized(index)))
+ {
+ ret += smm_set_plc_output_level((const unsigned char *)SystemManager::instance()->PlcHost(index).macAddress,
+ SMM_MAX_RETRIES,
+ set_value);
+ }
+ }
+
+ return ret;
+}
+
+
+int Underlayer::getOnlineIp ( const unsigned char *mac_address, struct online_ip* ip )
+{
+ if (NULL == mac_address)
+ {
+ return -1;
+ }
+
+ return smm_get_ip(mac_address,
+ SMM_MAX_RETRIES,
+ INTERFACE_BR0, /* Be careful, it's not the same value as _DEFAULT_SNMP_BRIDGE_IF_INDEX */
+ &(ip->address),
+ &(ip->mask),
+ &(ip->broadcast),
+ &(ip->gateway),
+ &(ip->mode));
+}
+
+
+int Underlayer::setOnlineIp ( const unsigned char *mac_address, const struct online_ip* ip )
+{
+ if (NULL == mac_address)
+ {
+ return -1;
+ }
+
+ return smm_set_ip(mac_address,
+ SMM_MAX_RETRIES,
+ INTERFACE_BR0, /* Be careful, it's not the same value as _DEFAULT_SNMP_BRIDGE_IF_INDEX */
+ &(ip->address),
+ &(ip->mask),
+ &(ip->broadcast),
+ &(ip->gateway),
+ ip->mode);
+}
+
+
+int Underlayer::getOnlineModelNumber ( const unsigned char *mac_address, char *online_model_number, size_t len )
+{
+ if ((NULL == mac_address) || (NULL == online_model_number) || (0 == len))
+ {
+ return -1;
+ }
+
+ return smm_get_model_number(mac_address,
+ SMM_MAX_RETRIES,
+ online_model_number,
+ len);
+}
+
+int Underlayer::getOnlinePortAmount ( const unsigned char *mac_address, spidcom_nvram_t *nvram)
+{
+
+ if ((NULL == mac_address) || (NULL == nvram))
+ {
+ return -1;
+ }
+
+ return smm_get_nvram(mac_address, SMM_MAX_RETRIES, nvram);
+}
+
+
+int Underlayer::getOnlineInfo ( const unsigned char *mac_address, unsigned int* current_image, unsigned int* archi, unsigned int* eth_port, smm_image_info_t* info )
+{
+ if ((NULL == mac_address) || (NULL == info) || (NULL == current_image))
+ {
+ return -1;
+ }
+
+ return smm_image_info(mac_address,
+ SMM_MAX_RETRIES,
+ current_image, archi, eth_port, info);
+}
+
+int Underlayer::getOnlinePlcStatus (const unsigned char * mac_address, unsigned int* bssid, unsigned int* tei, unsigned int* nb_hosts, spidlib_plc_mode_t* mode, int* gain, int* attenuation)
+{
+ return smm_plc_status(mac_address,
+ SMM_MAX_RETRIES,
+ bssid, tei, nb_hosts, mode, gain, attenuation);
+}
+
+
+int Underlayer::onlineReset ( const unsigned char *mac_address )
+{
+ if (NULL == mac_address)
+ {
+ return -1;
+ }
+
+ return smm_reboot(mac_address, SMM_MAX_RETRIES);
+}
+
+
+int Underlayer::getOnlineOutputLevel ( const unsigned char *mac_address, int *get_value )
+{
+ if ((NULL == mac_address) || (NULL == get_value))
+ {
+ return -1;
+ }
+
+ return smm_get_plc_output_level(mac_address, SMM_MAX_RETRIES, get_value);
+}
+
+
+int Underlayer::setOnlineOutputLevel ( const unsigned char *mac_address, int set_value )
+{
+ if (NULL == mac_address)
+ {
+ return -1;
+ }
+
+ return smm_set_plc_output_level(mac_address, SMM_MAX_RETRIES, set_value);
+}
+
+int Underlayer::getConfFileParam ( char* get_value, const char* param, const char* file, int length )
+{
+ if (NULL == get_value || file == NULL)
+ {
+ return -1;
+ }
+ return spidlib_read_config_param(file, param, get_value, length);
+}
+
+int Underlayer::writeConfFileParam ( const char* get_value, const char* param, const char* file )
+{
+ if (NULL == get_value || file == NULL)
+ {
+ return -1;
+ }
+ return spidlib_write_config_param(file, param, get_value);
+}