sign: add stream GUID to sign protocol
This commit is contained in:
parent
bf92ea09df
commit
783db4e832
@ -76,6 +76,8 @@ AbstractProtocol::FieldFlags SignProtocol::fieldFlags(int index) const
|
|||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case sign_magic:
|
case sign_magic:
|
||||||
|
case sign_tlv_guid:
|
||||||
|
case sign_tlv_end:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -113,7 +115,49 @@ QVariant SignProtocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case sign_tlv_guid:
|
||||||
|
{
|
||||||
|
quint32 guid = data.stream_guid() & 0xFFFFFF;
|
||||||
|
switch(attrib)
|
||||||
|
{
|
||||||
|
case FieldName:
|
||||||
|
return QString("Stream GUID");
|
||||||
|
case FieldValue:
|
||||||
|
return guid;
|
||||||
|
case FieldTextValue:
|
||||||
|
return QString("%1").arg(guid);
|
||||||
|
case FieldFrameValue:
|
||||||
|
{
|
||||||
|
QByteArray fv;
|
||||||
|
fv.resize(4);
|
||||||
|
fv[0] = (guid >> 16) & 0xff;
|
||||||
|
fv[1] = (guid >> 8) & 0xff;
|
||||||
|
fv[2] = (guid >> 0) & 0xff;
|
||||||
|
fv[3] = kTypeLenGuid;
|
||||||
|
return fv;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case sign_tlv_end:
|
||||||
|
{
|
||||||
|
switch(attrib)
|
||||||
|
{
|
||||||
|
case FieldName:
|
||||||
|
return QString("End TLV");
|
||||||
|
case FieldValue:
|
||||||
|
return 0;
|
||||||
|
case FieldTextValue:
|
||||||
|
return QString("NA");
|
||||||
|
case FieldFrameValue:
|
||||||
|
return QByteArray(1, kTypeLenEnd);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__,
|
qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__,
|
||||||
@ -123,3 +167,32 @@ QVariant SignProtocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
|
|
||||||
return AbstractProtocol::fieldData(index, attrib, streamIndex);
|
return AbstractProtocol::fieldData(index, attrib, streamIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SignProtocol::setFieldData(int index, const QVariant &value,
|
||||||
|
FieldAttrib attrib)
|
||||||
|
{
|
||||||
|
bool isOk = false;
|
||||||
|
|
||||||
|
if (attrib != FieldValue)
|
||||||
|
goto _exit;
|
||||||
|
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case sign_tlv_guid:
|
||||||
|
{
|
||||||
|
uint guid = value.toUInt(&isOk);
|
||||||
|
if (isOk)
|
||||||
|
data.set_stream_guid(guid & 0xFFFFFF);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__,
|
||||||
|
index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,11 +25,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Sign Protocol is expected at the end of the frame (just before the Eth FCS)
|
Sign Protocol is expected at the end of the frame (just before the Eth FCS)
|
||||||
--+-------+
|
---+--------+-------+
|
||||||
. . .| Magic |
|
. . .| TLV(s) | Magic |
|
||||||
| (32) |
|
| (8+) | (32) |
|
||||||
--+-------+
|
---+--------+-------+
|
||||||
Figures in brackets represent field width in bits
|
Figures in brackets represent field width in bits
|
||||||
|
|
||||||
|
TLVs are encoded as
|
||||||
|
+-------+-----+------+
|
||||||
|
| Value | Len | Type |
|
||||||
|
| (...) | (3) | (5) |
|
||||||
|
+-------+-----+------+
|
||||||
|
Len does NOT include the one byte of TypeLen
|
||||||
|
Size of the value field varies between 0 to 7 bytes
|
||||||
|
|
||||||
|
Defined TLVs
|
||||||
|
Type = 0, Len = 0 (0x00): End of TLVs
|
||||||
|
Type = 1, Len = 3 (0x61): Stream GUID
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SignProtocol : public AbstractProtocol
|
class SignProtocol : public AbstractProtocol
|
||||||
@ -38,7 +50,9 @@ public:
|
|||||||
enum samplefield
|
enum samplefield
|
||||||
{
|
{
|
||||||
// Frame Fields
|
// Frame Fields
|
||||||
sign_magic = 0,
|
sign_tlv_end = 0,
|
||||||
|
sign_tlv_guid,
|
||||||
|
sign_magic,
|
||||||
|
|
||||||
// Meta Fields
|
// Meta Fields
|
||||||
// - None
|
// - None
|
||||||
@ -64,9 +78,13 @@ public:
|
|||||||
virtual AbstractProtocol::FieldFlags fieldFlags(int index) const;
|
virtual AbstractProtocol::FieldFlags fieldFlags(int index) const;
|
||||||
virtual QVariant fieldData(int index, FieldAttrib attrib,
|
virtual QVariant fieldData(int index, FieldAttrib attrib,
|
||||||
int streamIndex = 0) const;
|
int streamIndex = 0) const;
|
||||||
|
virtual bool setFieldData(int index, const QVariant &value,
|
||||||
|
FieldAttrib attrib = FieldValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const quint32 kSignMagic = 0xa1b2c3d4; // FIXME
|
static const quint32 kSignMagic = 0xa1b2c3d4; // FIXME
|
||||||
|
static const quint8 kTypeLenEnd = 0x00;
|
||||||
|
static const quint8 kTypeLenGuid = 0x61;
|
||||||
OstProto::Sign data;
|
OstProto::Sign data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ package OstProto;
|
|||||||
|
|
||||||
// Sign Protocol
|
// Sign Protocol
|
||||||
message Sign {
|
message Sign {
|
||||||
|
optional uint32 stream_guid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
extend Protocol {
|
extend Protocol {
|
||||||
|
@ -6,23 +6,52 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>32</height>
|
<height>64</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QGridLayout" >
|
||||||
<item>
|
<item row="0" column="0" >
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Signature: No configurable fields</string>
|
<string>Stream GUID</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment" >
|
<property name="buddy" >
|
||||||
<set>Qt::AlignCenter</set>
|
<cstring>guid</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QLineEdit" name="guid" />
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2" >
|
||||||
|
<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="1" column="1" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -37,9 +37,17 @@ SignConfigForm* SignConfigForm::createInstance()
|
|||||||
|
|
||||||
void SignConfigForm::loadWidget(AbstractProtocol *proto)
|
void SignConfigForm::loadWidget(AbstractProtocol *proto)
|
||||||
{
|
{
|
||||||
|
guid->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
SignProtocol::sign_tlv_guid,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignConfigForm::storeWidget(AbstractProtocol *proto)
|
void SignConfigForm::storeWidget(AbstractProtocol *proto)
|
||||||
{
|
{
|
||||||
|
proto->setFieldData(
|
||||||
|
SignProtocol::sign_tlv_guid,
|
||||||
|
guid->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from rpc import RpcError
|
|||||||
from protocols.mac_pb2 import mac, Mac
|
from protocols.mac_pb2 import mac, Mac
|
||||||
from protocols.ip4_pb2 import ip4, Ip4
|
from protocols.ip4_pb2 import ip4, Ip4
|
||||||
from protocols.payload_pb2 import payload, Payload
|
from protocols.payload_pb2 import payload, Payload
|
||||||
|
from protocols.sign_pb2 import sign
|
||||||
|
|
||||||
# Convenience class to interwork with OstEmul::Ip6Address() and
|
# Convenience class to interwork with OstEmul::Ip6Address() and
|
||||||
# the python ipaddress module
|
# the python ipaddress module
|
||||||
@ -335,7 +336,7 @@ def stream(request, drone, ports):
|
|||||||
s.protocol.add().protocol_id.id = ost_pb.Protocol.kPayloadFieldNumber
|
s.protocol.add().protocol_id.id = ost_pb.Protocol.kPayloadFieldNumber
|
||||||
p = s.protocol.add()
|
p = s.protocol.add()
|
||||||
p.protocol_id.id = ost_pb.Protocol.kSignFieldNumber
|
p.protocol_id.id = ost_pb.Protocol.kSignFieldNumber
|
||||||
# FIXME: p.Extensions[sign].stream_guid = 101
|
p.Extensions[sign].stream_guid = 101
|
||||||
|
|
||||||
def fin():
|
def fin():
|
||||||
# delete streams
|
# delete streams
|
||||||
@ -446,13 +447,6 @@ def test_unidir(drone, ports, dut, dut_ports, dut_ip, emul_ports, dgid_list,
|
|||||||
log.info('--> (y_stats)' + y_stats.__str__())
|
log.info('--> (y_stats)' + y_stats.__str__())
|
||||||
assert(y_stats.port_stats[0].rx_pkts >= 20)
|
assert(y_stats.port_stats[0].rx_pkts >= 20)
|
||||||
|
|
||||||
# verify stream stats
|
|
||||||
stream_stats_list = drone.getStreamStats(stream_guids)
|
|
||||||
log.info('--> (stream_stats)' + stream_stats_list.__str__())
|
|
||||||
assert (len(stream_stats_list.stream_stats) > 0)
|
|
||||||
|
|
||||||
# FIXME: verify stream stats
|
|
||||||
|
|
||||||
# dump Y capture buffer
|
# dump Y capture buffer
|
||||||
log.info('getting Y capture buffer')
|
log.info('getting Y capture buffer')
|
||||||
buff = drone.getCaptureBuffer(ports.y.port_id[0])
|
buff = drone.getCaptureBuffer(ports.y.port_id[0])
|
||||||
@ -460,8 +454,22 @@ def test_unidir(drone, ports, dut, dut_ports, dut_ip, emul_ports, dgid_list,
|
|||||||
log.info('dumping Y capture buffer')
|
log.info('dumping Y capture buffer')
|
||||||
cap_pkts = subprocess.check_output([tshark, '-n', '-r', 'capture.pcap'])
|
cap_pkts = subprocess.check_output([tshark, '-n', '-r', 'capture.pcap'])
|
||||||
print(cap_pkts)
|
print(cap_pkts)
|
||||||
|
filter="frame[-9:9]==00.00.00.65.61.a1.b2.c3.d4"
|
||||||
|
print(filter)
|
||||||
|
log.info('dumping Y capture buffer (filtered)')
|
||||||
|
cap_pkts = subprocess.check_output([tshark, '-n', '-r', 'capture.pcap',
|
||||||
|
'-Y', filter])
|
||||||
|
print(cap_pkts)
|
||||||
|
assert cap_pkts.count('\n') == 10
|
||||||
os.remove('capture.pcap')
|
os.remove('capture.pcap')
|
||||||
|
|
||||||
|
# verify stream stats
|
||||||
|
stream_stats_list = drone.getStreamStats(stream_guids)
|
||||||
|
log.info('--> (stream_stats)' + stream_stats_list.__str__())
|
||||||
|
assert (len(stream_stats_list.stream_stats) > 0)
|
||||||
|
|
||||||
|
# FIXME: verify stream stats
|
||||||
|
|
||||||
except RpcError as e:
|
except RpcError as e:
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user