snapshot before rewriting SSM report code
This commit is contained in:
parent
82bcc756f0
commit
19eb4a1713
207
common/gmp.cpp
207
common/gmp.cpp
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "gmp.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <qendian.h>
|
||||
|
||||
GmpConfigForm::GmpConfigForm(QWidget *parent)
|
||||
@ -34,24 +35,26 @@ GmpConfigForm::GmpConfigForm(QWidget *parent)
|
||||
msgTypeCombo->addItem(kIgmpV2Leave, "IGMPv2 Leave");
|
||||
msgTypeCombo->addItem(kIgmpV3Query, "IGMPv3 Query");
|
||||
msgTypeCombo->addItem(kIgmpV3Report, "IGMPv3 Report");
|
||||
|
||||
auxData->setValidator(new QRegExpValidator(
|
||||
QRegExp("[0-9A-Fa-f]*"), this));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_addSource_clicked()
|
||||
GmpConfigForm::~GmpConfigForm()
|
||||
{
|
||||
QListWidgetItem *item=new QListWidgetItem("0.0.0.0");
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
sourceList->insertItem(sourceList->currentRow(), item);
|
||||
// delete UserRole itemdata for grpRecords
|
||||
for (int i = 0; i < groupList->count(); i++)
|
||||
{
|
||||
QListWidgetItem *item = groupList->item(i);
|
||||
|
||||
if (!overrideSourceCount->isChecked())
|
||||
sourceCount->setText(QString().setNum(sourceList->count()));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_deleteSource_clicked()
|
||||
{
|
||||
delete sourceList->takeItem(sourceList->currentRow());
|
||||
|
||||
if (!overrideSourceCount->isChecked())
|
||||
sourceCount->setText(QString().setNum(sourceList->count()));
|
||||
if (item)
|
||||
{
|
||||
OstProto::Gmp::GroupRecord *rec = (OstProto::Gmp::GroupRecord*)
|
||||
item->data(Qt::UserRole).value<void*>();
|
||||
item->setData(Qt::UserRole, QVariant());
|
||||
delete rec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_msgTypeCombo_currentIndexChanged(int /*index*/)
|
||||
@ -91,6 +94,135 @@ void GmpConfigForm::on_msgTypeCombo_currentIndexChanged(int /*index*/)
|
||||
}
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_addSource_clicked()
|
||||
{
|
||||
QListWidgetItem *item=new QListWidgetItem(_defaultSourceIp);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
sourceList->insertItem(sourceList->currentRow(), item);
|
||||
|
||||
if (!overrideSourceCount->isChecked())
|
||||
sourceCount->setText(QString().setNum(sourceList->count()));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_deleteSource_clicked()
|
||||
{
|
||||
delete sourceList->takeItem(sourceList->currentRow());
|
||||
|
||||
if (!overrideSourceCount->isChecked())
|
||||
sourceCount->setText(QString().setNum(sourceList->count()));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_addGroupRecord_clicked()
|
||||
{
|
||||
OstProto::Gmp::GroupRecord *record = new OstProto::Gmp::GroupRecord;
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
|
||||
item->setData(Qt::UserRole, QVariant::fromValue((void*)record));
|
||||
item->setText("xxx"); // FIXME
|
||||
|
||||
groupList->insertItem(groupList->currentRow(), item);
|
||||
|
||||
if (!overrideGroupRecordCount->isChecked())
|
||||
groupRecordCount->setText(QString().setNum(groupList->count()));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_deleteGroupRecord_clicked()
|
||||
{
|
||||
QListWidgetItem *item = groupList->takeItem(groupList->currentRow());
|
||||
if (item)
|
||||
{
|
||||
delete (OstProto::Gmp::GroupRecord*)item->data(Qt::UserRole)
|
||||
.value<void*>();
|
||||
delete item;
|
||||
}
|
||||
|
||||
if (!overrideGroupRecordCount->isChecked())
|
||||
groupRecordCount->setText(QString().setNum(groupList->count()));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_groupList_currentItemChanged(QListWidgetItem *current,
|
||||
QListWidgetItem *previous)
|
||||
{
|
||||
OstProto::Gmp::GroupRecord *prevRec;
|
||||
OstProto::Gmp::GroupRecord *currRec;
|
||||
|
||||
qDebug("in %s", __FUNCTION__);
|
||||
|
||||
// save previous record ...
|
||||
if (previous == NULL)
|
||||
goto _load_current_record;
|
||||
|
||||
prevRec = (OstProto::Gmp::GroupRecord*)previous->data(Qt::UserRole)
|
||||
.value<void*>();
|
||||
|
||||
prevRec->set_type(OstProto::Gmp::GroupRecord::RecordType(
|
||||
groupRecordType->currentIndex()+1));
|
||||
// FIXME: groupRecordAddress, sources
|
||||
|
||||
prevRec->set_is_override_source_count(
|
||||
overrideGroupRecordSourceCount->isChecked());
|
||||
prevRec->set_source_count(groupRecordSourceCount->text().toUInt());
|
||||
|
||||
prevRec->set_is_override_aux_data_length(
|
||||
overrideAuxDataLength->isChecked());
|
||||
prevRec->set_aux_data(QString(QByteArray::fromHex(
|
||||
QByteArray().append(auxData->text()))).toStdString());
|
||||
|
||||
_load_current_record:
|
||||
// ... and load current record
|
||||
if (current == NULL)
|
||||
goto _exit;
|
||||
|
||||
currRec = (OstProto::Gmp::GroupRecord*)current->data(Qt::UserRole)
|
||||
.value<void*>();
|
||||
|
||||
groupRecordType->setCurrentIndex(int(currRec->type()) - 1);
|
||||
// FIXME: groupRecordAddress, sources
|
||||
|
||||
overrideGroupRecordSourceCount->setChecked(
|
||||
currRec->is_override_source_count());
|
||||
if (overrideGroupRecordSourceCount->isChecked())
|
||||
{
|
||||
groupRecordSourceCount->setText(
|
||||
QString().setNum(currRec->source_count()));
|
||||
}
|
||||
|
||||
overrideAuxDataLength->setChecked(currRec->is_override_aux_data_length());
|
||||
if (overrideAuxDataLength->isChecked())
|
||||
auxDataLength->setText(QString().setNum(currRec->aux_data_length()));
|
||||
auxData->setText(QString(QByteArray().append(
|
||||
QString().fromStdString(currRec->aux_data())).toHex()));
|
||||
_exit:
|
||||
groupRecord->setEnabled(current != NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_addGroupRecordSource_clicked()
|
||||
{
|
||||
QListWidgetItem *item=new QListWidgetItem(_defaultSourceIp);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
groupRecordSourceList->insertItem(groupRecordSourceList->currentRow(),item);
|
||||
|
||||
if (!overrideGroupRecordSourceCount->isChecked())
|
||||
groupRecordSourceCount->setText(QString().setNum(
|
||||
groupRecordSourceList->count()));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_deleteGroupRecordSource_clicked()
|
||||
{
|
||||
delete groupRecordSourceList->takeItem(groupRecordSourceList->currentRow());
|
||||
|
||||
if (!overrideGroupRecordSourceCount->isChecked())
|
||||
groupRecordSourceCount->setText(QString().setNum(
|
||||
groupRecordSourceList->count()));
|
||||
}
|
||||
|
||||
void GmpConfigForm::on_auxData_textChanged(const QString &text)
|
||||
{
|
||||
if (!overrideAuxDataLength->isChecked())
|
||||
auxDataLength->setText(QString().setNum(auxData->text().length()/2));
|
||||
}
|
||||
|
||||
GmpProtocol::GmpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
: AbstractProtocol(stream, parent)
|
||||
{
|
||||
@ -115,6 +247,16 @@ int GmpProtocol::fieldCount() const
|
||||
|
||||
int GmpProtocol::frameFieldCount() const
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
// TODO: optimize!!!!!
|
||||
for (int i = 0; i < FIELD_COUNT; i++)
|
||||
{
|
||||
if (fieldFlags(i).testFlag(AbstractProtocol::FrameField))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
#if 0
|
||||
switch(msgType())
|
||||
{
|
||||
// IGMP
|
||||
@ -144,6 +286,7 @@ int GmpProtocol::frameFieldCount() const
|
||||
default:
|
||||
return FIELD_COUNT_ASM_ALL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
AbstractProtocol::FieldFlags GmpProtocol::fieldFlags(int index) const
|
||||
@ -225,7 +368,7 @@ QVariant GmpProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
case FieldValue:
|
||||
return type;
|
||||
case FieldTextValue:
|
||||
return QString("%1").arg(type);
|
||||
return QString("%1").arg(quint8(type));
|
||||
case FieldFrameValue:
|
||||
return QByteArray(1, quint8(type));
|
||||
default:
|
||||
@ -335,7 +478,7 @@ QVariant GmpProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
switch(attrib)
|
||||
{
|
||||
case FieldName:
|
||||
return QString("Querier's Robustness Variable (QRV)");
|
||||
return QString("QRV");
|
||||
case FieldValue:
|
||||
return qrv;
|
||||
case FieldTextValue:
|
||||
@ -356,7 +499,7 @@ QVariant GmpProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
switch(attrib)
|
||||
{
|
||||
case FieldName:
|
||||
return QString("Querier's Robustness Variable (QRV)");
|
||||
return QString("QQIC");
|
||||
case FieldValue:
|
||||
return qqi;
|
||||
case FieldTextValue:
|
||||
@ -690,18 +833,6 @@ bool GmpProtocol::isProtocolFrameValueVariable() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QWidget* GmpProtocol::configWidget()
|
||||
{
|
||||
/* Lazy creation of the configWidget */
|
||||
if (configForm == NULL)
|
||||
{
|
||||
configForm = new GmpConfigForm;
|
||||
loadConfigWidget();
|
||||
}
|
||||
|
||||
return configForm;
|
||||
}
|
||||
|
||||
void GmpProtocol::loadConfigWidget()
|
||||
{
|
||||
configWidget();
|
||||
@ -727,11 +858,14 @@ void GmpProtocol::loadConfigWidget()
|
||||
configForm->qrv->setText(fieldData(kQrv, FieldValue).toString());
|
||||
configForm->qqi->setText(fieldData(kQqic, FieldValue).toString());
|
||||
|
||||
configForm->sourceList->clear();
|
||||
configForm->sourceList->addItems(
|
||||
fieldData(kSources, FieldValue).toStringList());
|
||||
|
||||
configForm->overrideSourceCount->setChecked(
|
||||
fieldData(kIsOverrideSourceCount, FieldValue).toBool());
|
||||
configForm->sourceCount->setText(
|
||||
fieldData(kSourceCount, FieldValue).toString());
|
||||
// TODO: sources
|
||||
|
||||
configForm->overrideGroupRecordCount->setChecked(
|
||||
fieldData(kIsOverrideGroupRecordCount, FieldValue).toBool());
|
||||
@ -756,21 +890,28 @@ void GmpProtocol::storeConfigWidget()
|
||||
setFieldData(kGroupAddress, configForm->groupAddress->text());
|
||||
setFieldData(kGroupMode, configForm->groupMode->currentIndex());
|
||||
setFieldData(kGroupCount, configForm->groupCount->text());
|
||||
setFieldData(kGroupPrefix, configForm->groupPrefix->text());
|
||||
setFieldData(kGroupPrefix, configForm->groupPrefix->text().remove('/'));
|
||||
|
||||
setFieldData(kSFlag, configForm->sFlag->isChecked());
|
||||
setFieldData(kQrv, configForm->qrv->text());
|
||||
setFieldData(kQqic, configForm->qqi->text());
|
||||
|
||||
QStringList list;
|
||||
for (int i = 0; i < configForm->sourceList->count(); i++)
|
||||
list.append(configForm->sourceList->item(i)->text());
|
||||
setFieldData(kSources, list);
|
||||
|
||||
// XXX: sourceCount should be AFTER sources
|
||||
setFieldData(kIsOverrideSourceCount,
|
||||
configForm->overrideSourceCount->isChecked());
|
||||
setFieldData(kSourceCount, configForm->sourceCount->text());
|
||||
// TODO: Sources
|
||||
|
||||
// TODO: Group Records
|
||||
|
||||
// XXX: groupRecordCount should be AFTER groupRecords
|
||||
setFieldData(kIsOverrideGroupRecordCount,
|
||||
configForm->overrideGroupRecordCount->isChecked());
|
||||
setFieldData(kGroupRecordCount, configForm->groupRecordCount->text());
|
||||
// TODO: Group Records
|
||||
#if 0
|
||||
setFieldData(kA, configForm->gmpA->text());
|
||||
setFieldData(kB, configForm->gmpB->text());
|
||||
|
12
common/gmp.h
12
common/gmp.h
@ -60,10 +60,21 @@ class GmpConfigForm : public QWidget, public Ui::Gmp
|
||||
Q_OBJECT
|
||||
public:
|
||||
GmpConfigForm(QWidget *parent = 0);
|
||||
~GmpConfigForm();
|
||||
protected:
|
||||
QString _defaultSourceIp;
|
||||
private slots:
|
||||
void on_msgTypeCombo_currentIndexChanged(int index);
|
||||
void on_addSource_clicked();
|
||||
void on_deleteSource_clicked();
|
||||
|
||||
void on_addGroupRecord_clicked();
|
||||
void on_deleteGroupRecord_clicked();
|
||||
void on_groupList_currentItemChanged(QListWidgetItem *current,
|
||||
QListWidgetItem *previous);
|
||||
void on_addGroupRecordSource_clicked();
|
||||
void on_deleteGroupRecordSource_clicked();
|
||||
void on_auxData_textChanged(const QString &text);
|
||||
};
|
||||
|
||||
class GmpProtocol : public AbstractProtocol
|
||||
@ -87,7 +98,6 @@ public:
|
||||
|
||||
virtual bool isProtocolFrameValueVariable() const;
|
||||
|
||||
virtual QWidget* configWidget();
|
||||
virtual void loadConfigWidget();
|
||||
virtual void storeConfigWidget();
|
||||
|
||||
|
455
common/gmp.ui
455
common/gmp.ui
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>586</width>
|
||||
<height>281</height>
|
||||
<width>497</width>
|
||||
<height>355</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -182,7 +182,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="ssmWidget" >
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page" >
|
||||
<layout class="QHBoxLayout" >
|
||||
@ -297,14 +297,14 @@
|
||||
<item>
|
||||
<widget class="QToolButton" name="addSource" >
|
||||
<property name="text" >
|
||||
<string>A</string>
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="deleteSource" >
|
||||
<property name="text" >
|
||||
<string>D</string>
|
||||
<string>--</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -351,6 +351,19 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -359,7 +372,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -381,18 +394,48 @@
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QTableWidget" name="groupList" >
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Group Address</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_14" >
|
||||
<property name="text" >
|
||||
<string>Group Records</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>groupRecordAddress</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="addGroupRecord" >
|
||||
<property name="text" >
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="deleteGroupRecord" >
|
||||
<property name="text" >
|
||||
<string>--</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="groupList" />
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
@ -415,162 +458,218 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Record Type</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>recordType</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QComboBox" name="recordType" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Is Include</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Is Exclude</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>To Include</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>To Exclude</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Allow New</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Block Old</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_7" >
|
||||
<property name="text" >
|
||||
<string>Group Address</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>groupRecordAddress</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="groupRecordAddress" />
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3" >
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_12" >
|
||||
<property name="text" >
|
||||
<string>Source List</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>groupRecordAddress</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QCheckBox" name="overrideGroupRecordSourceCount" >
|
||||
<property name="text" >
|
||||
<string>Count</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="QLineEdit" name="groupRecordSourceCount" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4" >
|
||||
<widget class="QTextEdit" name="groupRecordSourceList" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3" >
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_8" >
|
||||
<property name="text" >
|
||||
<string>Aux Data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QCheckBox" name="overrideAuxDataLength" >
|
||||
<property name="text" >
|
||||
<string>Length</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="QLineEdit" name="auxDataLength" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4" >
|
||||
<widget class="QLineEdit" name="auxData" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QWidget" native="1" name="groupRecord" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Record Type</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>groupRecordType</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="groupRecordType" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Is Include</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Is Exclude</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>To Include</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>To Exclude</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Allow New</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Block Old</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_7" >
|
||||
<property name="text" >
|
||||
<string>Group Address</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>groupRecordAddress</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="groupRecordAddress" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12" >
|
||||
<property name="text" >
|
||||
<string>Source List</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>groupRecordAddress</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="addGroupRecordSource" >
|
||||
<property name="text" >
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="deleteGroupRecordSource" >
|
||||
<property name="text" >
|
||||
<string>--</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="groupRecordSourceList" />
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="overrideGroupRecordSourceCount" >
|
||||
<property name="text" >
|
||||
<string>Number of Sources</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="groupRecordSourceCount" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_8" >
|
||||
<property name="text" >
|
||||
<string>Aux Data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QCheckBox" name="overrideAuxDataLength" >
|
||||
<property name="text" >
|
||||
<string>Length</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="QLineEdit" name="auxDataLength" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4" >
|
||||
<widget class="QLineEdit" name="auxData" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -586,8 +685,8 @@
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>101</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
@ -610,14 +709,12 @@
|
||||
<tabstop>groupMode</tabstop>
|
||||
<tabstop>groupCount</tabstop>
|
||||
<tabstop>groupPrefix</tabstop>
|
||||
<tabstop>groupList</tabstop>
|
||||
<tabstop>overrideGroupRecordCount</tabstop>
|
||||
<tabstop>groupRecordCount</tabstop>
|
||||
<tabstop>recordType</tabstop>
|
||||
<tabstop>groupRecordType</tabstop>
|
||||
<tabstop>groupRecordAddress</tabstop>
|
||||
<tabstop>overrideGroupRecordSourceCount</tabstop>
|
||||
<tabstop>groupRecordSourceCount</tabstop>
|
||||
<tabstop>groupRecordSourceList</tabstop>
|
||||
<tabstop>overrideAuxDataLength</tabstop>
|
||||
<tabstop>auxDataLength</tabstop>
|
||||
<tabstop>auxData</tabstop>
|
||||
|
@ -20,12 +20,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "igmp.h"
|
||||
|
||||
#include <QHostAddress>
|
||||
#include <QItemDelegate>
|
||||
#include <qendian.h>
|
||||
|
||||
class IpAddressDelegate : public QItemDelegate
|
||||
{
|
||||
public:
|
||||
IpAddressDelegate(QObject *parent = 0)
|
||||
: QItemDelegate(parent) { }
|
||||
~IpAddressDelegate() {}
|
||||
QWidget* createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *ipEdit;
|
||||
|
||||
ipEdit = static_cast<QLineEdit*>(QItemDelegate::createEditor(
|
||||
parent, option, index));
|
||||
|
||||
ipEdit->setInputMask("009.009.009.009;"); // FIXME: use validator
|
||||
|
||||
return ipEdit;
|
||||
}
|
||||
};
|
||||
|
||||
IgmpConfigForm::IgmpConfigForm(QWidget *parent)
|
||||
: GmpConfigForm(parent)
|
||||
{
|
||||
_defaultSourceIp = "0.0.0.0";
|
||||
|
||||
sourceList->setItemDelegate(new IpAddressDelegate(this));
|
||||
groupRecordSourceList->setItemDelegate(new IpAddressDelegate(this));
|
||||
}
|
||||
|
||||
IgmpProtocol::IgmpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
@ -90,7 +114,7 @@ QVariant IgmpProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
{
|
||||
case kRsvdMrtCode:
|
||||
{
|
||||
quint8 mrt = 0, mrc;
|
||||
quint8 mrt = 0, mrc = 0;
|
||||
|
||||
if (msgType() == kIgmpV3Query)
|
||||
{
|
||||
@ -111,7 +135,7 @@ QVariant IgmpProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
case FieldValue:
|
||||
return mrt;
|
||||
case FieldTextValue:
|
||||
return QString("%1 ms").arg(mrt);
|
||||
return QString("%1").arg(mrt);
|
||||
case FieldFrameValue:
|
||||
return QByteArray(1, mrc);
|
||||
default:
|
||||
@ -156,13 +180,19 @@ QVariant IgmpProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
case FieldName:
|
||||
return QString("Source List");
|
||||
case FieldValue:
|
||||
return QVariant(); // FIXME
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
for (int i = 0; i < data.sources_size(); i++)
|
||||
list.append(QHostAddress(data.sources(i).v4()).toString());
|
||||
return list;
|
||||
}
|
||||
case FieldFrameValue:
|
||||
{
|
||||
QByteArray fv;
|
||||
fv.resize(4 * data.sources_size());
|
||||
for (int i = 0; i < data.sources_size(); i++)
|
||||
qToBigEndian(data.sources(i), (uchar*) (fv.data()+4*i));
|
||||
qToBigEndian(data.sources(i).v4(), (uchar*)(fv.data()+4*i));
|
||||
return fv;
|
||||
}
|
||||
case FieldTextValue:
|
||||
@ -292,8 +322,17 @@ bool IgmpProtocol::setFieldData(int index, const QVariant &value,
|
||||
break;
|
||||
}
|
||||
case kSources:
|
||||
//TODO
|
||||
{
|
||||
QStringList list = value.toStringList();
|
||||
|
||||
data.clear_sources();
|
||||
foreach(QString str, list)
|
||||
{
|
||||
quint32 ip = QHostAddress(str).toIPv4Address();
|
||||
data.add_sources()->set_v4(ip);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kGroupRecords:
|
||||
//TODO
|
||||
@ -308,6 +347,18 @@ _exit:
|
||||
return isOk;
|
||||
}
|
||||
|
||||
QWidget* IgmpProtocol::configWidget()
|
||||
{
|
||||
/* Lazy creation of the configWidget */
|
||||
if (configForm == NULL)
|
||||
{
|
||||
configForm = new IgmpConfigForm;
|
||||
loadConfigWidget();
|
||||
}
|
||||
|
||||
return configForm;
|
||||
}
|
||||
|
||||
void IgmpProtocol::loadConfigWidget()
|
||||
{
|
||||
GmpProtocol::loadConfigWidget();
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
virtual bool setFieldData(int index, const QVariant &value,
|
||||
FieldAttrib attrib = FieldValue);
|
||||
|
||||
virtual QWidget* configWidget();
|
||||
virtual void loadConfigWidget();
|
||||
virtual void storeConfigWidget();
|
||||
|
||||
|
@ -19,12 +19,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "mld.h"
|
||||
|
||||
#include "ipv6addressvalidator.h"
|
||||
|
||||
#include <QHostAddress>
|
||||
#include <QItemDelegate>
|
||||
#include <qendian.h>
|
||||
|
||||
class IpAddressDelegate : public QItemDelegate
|
||||
{
|
||||
public:
|
||||
IpAddressDelegate(QObject *parent = 0)
|
||||
: QItemDelegate(parent) { }
|
||||
~IpAddressDelegate() {}
|
||||
QWidget* createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *ipEdit;
|
||||
|
||||
ipEdit = static_cast<QLineEdit*>(QItemDelegate::createEditor(
|
||||
parent, option, index));
|
||||
|
||||
// FIXME: const problem!!!
|
||||
//ipEdit->setValidator(new IPv6AddressValidator(this));
|
||||
|
||||
return ipEdit;
|
||||
}
|
||||
};
|
||||
|
||||
MldConfigForm::MldConfigForm(QWidget *parent)
|
||||
: GmpConfigForm(parent)
|
||||
{
|
||||
_defaultSourceIp = "::";
|
||||
sourceList->setItemDelegate(new IpAddressDelegate(this));
|
||||
groupRecordSourceList->setItemDelegate(new IpAddressDelegate(this));
|
||||
}
|
||||
|
||||
MldProtocol::MldProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
@ -292,6 +319,18 @@ _exit:
|
||||
return isOk;
|
||||
}
|
||||
|
||||
QWidget* MldProtocol::configWidget()
|
||||
{
|
||||
/* Lazy creation of the configWidget */
|
||||
if (configForm == NULL)
|
||||
{
|
||||
configForm = new MldConfigForm;
|
||||
loadConfigWidget();
|
||||
}
|
||||
|
||||
return configForm;
|
||||
}
|
||||
|
||||
void MldProtocol::loadConfigWidget()
|
||||
{
|
||||
GmpProtocol::loadConfigWidget();
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
virtual bool setFieldData(int index, const QVariant &value,
|
||||
FieldAttrib attrib = FieldValue);
|
||||
|
||||
virtual QWidget* configWidget();
|
||||
virtual void loadConfigWidget();
|
||||
virtual void storeConfigWidget();
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user