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"
|
|
|
|
|
|
|
|
#define MAX_MAC_ITER_COUNT 256
|
|
|
|
|
|
|
|
MacConfigForm::MacConfigForm(QWidget *parent)
|
|
|
|
: AbstractProtocolConfigForm(parent)
|
|
|
|
{
|
|
|
|
QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
|
|
|
|
|
|
|
|
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
|
2015-04-16 11:50:07 -05:00
|
|
|
leDstMac->setValidator(new QRegExpValidator(reMac, this));
|
|
|
|
leSrcMac->setValidator(new QRegExpValidator(reMac, this));
|
|
|
|
leDstMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
|
|
|
leSrcMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
leDstMac->setText(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstAddr,
|
|
|
|
AbstractProtocol::FieldTextValue
|
|
|
|
).toString());
|
|
|
|
cmbDstMacMode->setCurrentIndex(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstMacMode,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toUInt());
|
|
|
|
leDstMacCount->setText(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstMacCount,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toString());
|
|
|
|
leDstMacStep->setText(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_dstMacStep,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toString());
|
|
|
|
|
|
|
|
leSrcMac->setText(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcAddr,
|
|
|
|
AbstractProtocol::FieldTextValue
|
|
|
|
).toString());
|
|
|
|
cmbSrcMacMode->setCurrentIndex(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcMacMode,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toUInt());
|
|
|
|
leSrcMacCount->setText(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcMacCount,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toString());
|
|
|
|
leSrcMacStep->setText(
|
|
|
|
proto->fieldData(
|
|
|
|
MacProtocol::mac_srcMacStep,
|
|
|
|
AbstractProtocol::FieldValue
|
|
|
|
).toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MacConfigForm::storeWidget(AbstractProtocol *proto)
|
|
|
|
{
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstAddr,
|
|
|
|
leDstMac->text().remove(QChar(' ')));
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstMacMode,
|
|
|
|
cmbDstMacMode->currentIndex());
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstMacCount,
|
|
|
|
leDstMacCount->text());
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_dstMacStep,
|
|
|
|
leDstMacStep->text());
|
|
|
|
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcAddr,
|
|
|
|
leSrcMac->text().remove(QChar(' ')));
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcMacMode,
|
|
|
|
cmbSrcMacMode->currentIndex());
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcMacCount,
|
|
|
|
leSrcMacCount->text());
|
|
|
|
proto->setFieldData(
|
|
|
|
MacProtocol::mac_srcMacStep,
|
|
|
|
leSrcMacStep->text());
|
|
|
|
}
|
|
|
|
|