2015-04-16 11:50:07 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010,2013-2014 Srivats P.
|
|
|
|
|
|
|
|
This file is part of "Ostinato"
|
|
|
|
|
|
|
|
This is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "macconfig.h"
|
|
|
|
#include "mac.h"
|
|
|
|
|
|
|
|
MacConfigForm::MacConfigForm(QWidget *parent)
|
|
|
|
: AbstractProtocolConfigForm(parent)
|
|
|
|
{
|
|
|
|
|
|
|
|
setupUi(this);
|
2016-03-18 08:53:26 -05:00
|
|
|
resolveInfo->hide();
|
|
|
|
#if 0
|
|
|
|
// not working for some reason
|
|
|
|
resolveInfo->setPixmap(resolveInfo->style()->standardIcon(
|
|
|
|
QStyle::SP_MessageBoxInformation).pixmap(128));
|
|
|
|
#endif
|
2017-10-24 07:51:56 -05:00
|
|
|
leDstMacCount->setMinimum(1);
|
|
|
|
leSrcMacCount->setMinimum(1);
|
|
|
|
leDstMacStep->setMinimum(0);
|
|
|
|
leSrcMacStep->setMinimum(0);
|
2015-04-16 11:50:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MacConfigForm::~MacConfigForm()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MacConfigForm* MacConfigForm::createInstance()
|
|
|
|
{
|
|
|
|
MacConfigForm *f = new MacConfigForm;
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MacConfigForm::on_cmbDstMacMode_currentIndexChanged(int index)
|
|
|
|
{
|
2016-03-08 09:21:02 -06:00
|
|
|
switch (index) {
|
|
|
|
case OstProto::Mac::e_mm_resolve:
|
|
|
|
leDstMac->setEnabled(false);
|
|
|
|
leDstMacCount->setEnabled(false);
|
|
|
|
leDstMacStep->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case OstProto::Mac::e_mm_fixed:
|
|
|
|
leDstMac->setEnabled(true);
|
|
|
|
leDstMacCount->setEnabled(false);
|
|
|
|
leDstMacStep->setEnabled(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
leDstMac->setEnabled(true);
|
|
|
|
leDstMacCount->setEnabled(true);
|
|
|
|
leDstMacStep->setEnabled(true);
|
|
|
|
break;
|
2015-04-16 11:50:07 -05:00
|
|
|
}
|
2016-03-18 08:53:26 -05:00
|
|
|
resolveInfo->setVisible(
|
|
|
|
cmbDstMacMode->currentIndex() == OstProto::Mac::e_mm_resolve
|
|
|
|
|| cmbSrcMacMode->currentIndex() == OstProto::Mac::e_mm_resolve);
|
2015-04-16 11:50:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MacConfigForm::on_cmbSrcMacMode_currentIndexChanged(int index)
|
|
|
|
{
|
2016-03-08 09:21:02 -06:00
|
|
|
switch (index) {
|
|
|
|
case OstProto::Mac::e_mm_resolve:
|
|
|
|
leSrcMac->setEnabled(false);
|
|
|
|
leSrcMacCount->setEnabled(false);
|
|
|
|
leSrcMacStep->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case OstProto::Mac::e_mm_fixed:
|
|
|
|
leSrcMac->setEnabled(true);
|
|
|
|
leSrcMacCount->setEnabled(false);
|
|
|
|
leSrcMacStep->setEnabled(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
leSrcMac->setEnabled(true);
|
|
|
|
leSrcMacCount->setEnabled(true);
|
|
|
|
leSrcMacStep->setEnabled(true);
|
|
|
|
break;
|
2015-04-16 11:50:07 -05:00
|
|
|
}
|
2016-03-18 08:53:26 -05:00
|
|
|
resolveInfo->setVisible(
|
|
|
|
cmbDstMacMode->currentIndex() == OstProto::Mac::e_mm_resolve
|
|
|
|
|| cmbSrcMacMode->currentIndex() == OstProto::Mac::e_mm_resolve);
|
2015-04-16 11:50:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MacConfigForm::loadWidget(AbstractProtocol *proto)
|
|
|
|
{
|
2017-10-24 07:51:56 -05:00
|
|
|
leDstMac->setValue(
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstAddr,
|
2017-10-24 07:51:56 -05:00
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toULongLong());
|
2015-04-16 11:50:07 -05:00
|
|
|
cmbDstMacMode->setCurrentIndex(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstMacMode,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toUInt());
|
2017-10-24 07:51:56 -05:00
|
|
|
leDstMacCount->setValue(
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstMacCount,
|
|
|
|
AbstractProtocol::FieldValue
|
2017-10-24 07:51:56 -05:00
|
|
|
).toUInt());
|
|
|
|
leDstMacStep->setValue(
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstMacStep,
|
|
|
|
AbstractProtocol::FieldValue
|
2017-10-24 07:51:56 -05:00
|
|
|
).toUInt());
|
2015-04-16 11:50:07 -05:00
|
|
|
|
2017-10-24 07:51:56 -05:00
|
|
|
leSrcMac->setValue(
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcAddr,
|
2017-10-24 07:51:56 -05:00
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toULongLong());
|
2015-04-16 11:50:07 -05:00
|
|
|
cmbSrcMacMode->setCurrentIndex(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcMacMode,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toUInt());
|
2017-10-24 07:51:56 -05:00
|
|
|
leSrcMacCount->setValue(
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcMacCount,
|
|
|
|
AbstractProtocol::FieldValue
|
2017-10-24 07:51:56 -05:00
|
|
|
).toUInt());
|
|
|
|
leSrcMacStep->setValue(
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcMacStep,
|
|
|
|
AbstractProtocol::FieldValue
|
2017-10-24 07:51:56 -05:00
|
|
|
).toUInt());
|
2015-04-16 11:50:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MacConfigForm::storeWidget(AbstractProtocol *proto)
|
|
|
|
{
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstAddr,
|
2017-10-24 07:51:56 -05:00
|
|
|
leDstMac->value());
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstMacMode,
|
|
|
|
cmbDstMacMode->currentIndex());
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstMacCount,
|
2017-10-24 07:51:56 -05:00
|
|
|
leDstMacCount->value());
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstMacStep,
|
2017-10-24 07:51:56 -05:00
|
|
|
leDstMacStep->value());
|
2015-04-16 11:50:07 -05:00
|
|
|
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcAddr,
|
2017-10-24 07:51:56 -05:00
|
|
|
leSrcMac->value());
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcMacMode,
|
|
|
|
cmbSrcMacMode->currentIndex());
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcMacCount,
|
2017-10-24 07:51:56 -05:00
|
|
|
leSrcMacCount->value());
|
2015-04-16 11:50:07 -05:00
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcMacStep,
|
2017-10-24 07:51:56 -05:00
|
|
|
leSrcMacStep->value());
|
2015-04-16 11:50:07 -05:00
|
|
|
}
|
|
|
|
|