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)
|
||||
{
|
||||
case sign_magic:
|
||||
case sign_tlv_guid:
|
||||
case sign_tlv_end:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -113,7 +115,49 @@ QVariant SignProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
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:
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
--+-------+
|
||||
. . .| Magic |
|
||||
| (32) |
|
||||
--+-------+
|
||||
---+--------+-------+
|
||||
. . .| TLV(s) | Magic |
|
||||
| (8+) | (32) |
|
||||
---+--------+-------+
|
||||
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
|
||||
@ -38,7 +50,9 @@ public:
|
||||
enum samplefield
|
||||
{
|
||||
// Frame Fields
|
||||
sign_magic = 0,
|
||||
sign_tlv_end = 0,
|
||||
sign_tlv_guid,
|
||||
sign_magic,
|
||||
|
||||
// Meta Fields
|
||||
// - None
|
||||
@ -64,9 +78,13 @@ public:
|
||||
virtual AbstractProtocol::FieldFlags fieldFlags(int index) const;
|
||||
virtual QVariant fieldData(int index, FieldAttrib attrib,
|
||||
int streamIndex = 0) const;
|
||||
virtual bool setFieldData(int index, const QVariant &value,
|
||||
FieldAttrib attrib = FieldValue);
|
||||
|
||||
private:
|
||||
static const quint32 kSignMagic = 0xa1b2c3d4; // FIXME
|
||||
static const quint8 kTypeLenEnd = 0x00;
|
||||
static const quint8 kTypeLenGuid = 0x61;
|
||||
OstProto::Sign data;
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@ package OstProto;
|
||||
|
||||
// Sign Protocol
|
||||
message Sign {
|
||||
optional uint32 stream_guid = 1;
|
||||
}
|
||||
|
||||
extend Protocol {
|
||||
|
@ -6,23 +6,52 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>32</height>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Signature: No configurable fields</string>
|
||||
<string>Stream GUID</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
<property name="buddy" >
|
||||
<cstring>guid</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -37,9 +37,17 @@ SignConfigForm* SignConfigForm::createInstance()
|
||||
|
||||
void SignConfigForm::loadWidget(AbstractProtocol *proto)
|
||||
{
|
||||
guid->setText(
|
||||
proto->fieldData(
|
||||
SignProtocol::sign_tlv_guid,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
}
|
||||
|
||||
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.ip4_pb2 import ip4, Ip4
|
||||
from protocols.payload_pb2 import payload, Payload
|
||||
from protocols.sign_pb2 import sign
|
||||
|
||||
# Convenience class to interwork with OstEmul::Ip6Address() and
|
||||
# the python ipaddress module
|
||||
@ -335,7 +336,7 @@ def stream(request, drone, ports):
|
||||
s.protocol.add().protocol_id.id = ost_pb.Protocol.kPayloadFieldNumber
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kSignFieldNumber
|
||||
# FIXME: p.Extensions[sign].stream_guid = 101
|
||||
p.Extensions[sign].stream_guid = 101
|
||||
|
||||
def fin():
|
||||
# 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__())
|
||||
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
|
||||
log.info('getting Y capture buffer')
|
||||
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')
|
||||
cap_pkts = subprocess.check_output([tshark, '-n', '-r', 'capture.pcap'])
|
||||
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')
|
||||
|
||||
# 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:
|
||||
raise
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user