Feature (contd.): Variable Fields - renamed variable_fields as singular; this makes it consistent with other repeated variables in protocol.proto and in any case the C++/Python generated code "sounds" better with a repeated field named in its singular form, rather than plural
This commit is contained in:
parent
641a4f3c89
commit
6bb64a3b26
@ -123,13 +123,13 @@ quint32 AbstractProtocol::protocolNumber() const
|
||||
*/
|
||||
void AbstractProtocol::commonProtoDataCopyInto(OstProto::Protocol &protocol) const
|
||||
{
|
||||
protocol.clear_variable_fields();
|
||||
for (int i = 0; i < _data.variable_fields_size(); i++)
|
||||
protocol.clear_variable_field();
|
||||
for (int i = 0; i < _data.variable_field_size(); i++)
|
||||
{
|
||||
OstProto::VariableField *vf;
|
||||
|
||||
vf = protocol.add_variable_fields();
|
||||
vf->CopyFrom(_data.variable_fields(i));
|
||||
vf = protocol.add_variable_field();
|
||||
vf->CopyFrom(_data.variable_field(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,13 +141,13 @@ void AbstractProtocol::commonProtoDataCopyInto(OstProto::Protocol &protocol) con
|
||||
*/
|
||||
void AbstractProtocol::commonProtoDataCopyFrom(const OstProto::Protocol &protocol)
|
||||
{
|
||||
_data.clear_variable_fields();
|
||||
for (int i = 0; i < protocol.variable_fields_size(); i++)
|
||||
_data.clear_variable_field();
|
||||
for (int i = 0; i < protocol.variable_field_size(); i++)
|
||||
{
|
||||
OstProto::VariableField *vf;
|
||||
|
||||
vf = _data.add_variable_fields();
|
||||
vf->CopyFrom(protocol.variable_fields(i));
|
||||
vf = _data.add_variable_field();
|
||||
vf->CopyFrom(protocol.variable_field(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ _exit:
|
||||
*/
|
||||
int AbstractProtocol::variableFieldCount() const
|
||||
{
|
||||
return _data.variable_fields_size();
|
||||
return _data.variable_field_size();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -398,7 +398,7 @@ int AbstractProtocol::variableFieldCount() const
|
||||
*/
|
||||
void AbstractProtocol::appendVariableField(const OstProto::VariableField &vf)
|
||||
{
|
||||
_data.add_variable_fields()->CopyFrom(vf);
|
||||
_data.add_variable_field()->CopyFrom(vf);
|
||||
|
||||
// Update the cached value
|
||||
_frameVariableCount = lcm(_frameVariableCount, vf.count());
|
||||
@ -411,27 +411,27 @@ void AbstractProtocol::removeVariableField(int index)
|
||||
{
|
||||
OstProto::Protocol temp;
|
||||
|
||||
if (index >= _data.variable_fields_size()) {
|
||||
if (index >= _data.variable_field_size()) {
|
||||
qWarning("%s: %s variableField[%d] out of range; count: %d)",
|
||||
__FUNCTION__, qPrintable(shortName()),
|
||||
index, _data.variable_fields_size());
|
||||
index, _data.variable_field_size());
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: this is inefficient - evaluate using RepeatedPtrField?
|
||||
for (int i = 0; i < _data.variable_fields_size(); i++) {
|
||||
for (int i = 0; i < _data.variable_field_size(); i++) {
|
||||
if (i == index)
|
||||
continue;
|
||||
temp.add_variable_fields()->CopyFrom(_data.variable_fields(i));
|
||||
temp.add_variable_field()->CopyFrom(_data.variable_field(i));
|
||||
}
|
||||
|
||||
_data.clear_variable_fields();
|
||||
_data.clear_variable_field();
|
||||
_frameVariableCount = 1;
|
||||
for (int i = 0; i < temp.variable_fields_size(); i++) {
|
||||
_data.add_variable_fields()->CopyFrom(temp.variable_fields(i));
|
||||
for (int i = 0; i < temp.variable_field_size(); i++) {
|
||||
_data.add_variable_field()->CopyFrom(temp.variable_field(i));
|
||||
// Recalculate the cached value
|
||||
_frameVariableCount = lcm(_frameVariableCount,
|
||||
_data.variable_fields(i).count());
|
||||
_data.variable_field(i).count());
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,9 +441,9 @@ void AbstractProtocol::removeVariableField(int index)
|
||||
*/
|
||||
const OstProto::VariableField& AbstractProtocol::variableField(int index) const
|
||||
{
|
||||
Q_ASSERT(index < _data.variable_fields_size());
|
||||
Q_ASSERT(index < _data.variable_field_size());
|
||||
|
||||
return _data.variable_fields(index);
|
||||
return _data.variable_field(index);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -452,13 +452,13 @@ const OstProto::VariableField& AbstractProtocol::variableField(int index) const
|
||||
*/
|
||||
OstProto::VariableField* AbstractProtocol::mutableVariableField(int index)
|
||||
{
|
||||
if ((index < 0) || (index >= _data.variable_fields_size()))
|
||||
if ((index < 0) || (index >= _data.variable_field_size()))
|
||||
return NULL;
|
||||
|
||||
// Invalidate the cached value as the caller may potentially modify it
|
||||
_frameVariableCount = -1;
|
||||
|
||||
return _data.mutable_variable_fields(index);
|
||||
return _data.mutable_variable_field(index);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -688,9 +688,9 @@ QByteArray AbstractProtocol::protocolFrameValue(int streamIndex, bool forCksum)
|
||||
}
|
||||
|
||||
// Overwrite proto with the variable fields, if any
|
||||
for (int i = 0; i < _data.variable_fields_size(); i++)
|
||||
for (int i = 0; i < _data.variable_field_size(); i++)
|
||||
{
|
||||
OstProto::VariableField vf = _data.variable_fields(i);
|
||||
OstProto::VariableField vf = _data.variable_field(i);
|
||||
varyProtocolFrameValue(proto, streamIndex, vf);
|
||||
}
|
||||
|
||||
@ -739,9 +739,9 @@ int AbstractProtocol::protocolFrameVariableCount() const
|
||||
return _frameVariableCount;
|
||||
|
||||
_frameVariableCount = 1;
|
||||
for (int i = 0; i < _data.variable_fields_size(); i++)
|
||||
for (int i = 0; i < _data.variable_field_size(); i++)
|
||||
_frameVariableCount = lcm(_frameVariableCount,
|
||||
_data.variable_fields(i).count());
|
||||
_data.variable_field(i).count());
|
||||
|
||||
return _frameVariableCount;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ message VariableField {
|
||||
message Protocol {
|
||||
|
||||
required ProtocolId protocol_id = 1;
|
||||
repeated VariableField variable_fields = 2;
|
||||
repeated VariableField variable_field = 2;
|
||||
|
||||
extensions 100 to 199; // Reserved for Ostinato Use
|
||||
extensions 200 to 500; // Available for use by protocols
|
||||
|
@ -137,7 +137,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kIp6FieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter8
|
||||
vf.offset = 7
|
||||
vf.mask = 0xff
|
||||
@ -203,7 +203,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kVlanFieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter8
|
||||
vf.offset = 2
|
||||
vf.mask = 0xe0
|
||||
@ -270,7 +270,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kVlanFieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter16
|
||||
vf.offset = 2
|
||||
vf.mask = 0x0fff
|
||||
@ -342,7 +342,7 @@ try:
|
||||
p.Extensions[arp].sender_hw_addr = 0x001122334455
|
||||
p.Extensions[arp].sender_proto_addr = 0x01020304
|
||||
p.Extensions[arp].target_proto_addr = 0x0a0b0c01
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter32
|
||||
vf.offset = 24
|
||||
vf.mask = 0x0000ff00
|
||||
@ -411,7 +411,7 @@ try:
|
||||
p.protocol_id.id = ost_pb.Protocol.kIp4FieldNumber
|
||||
p.Extensions[ip4].src_ip = 0x01020304
|
||||
p.Extensions[ip4].dst_ip = 0x05060708
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter8
|
||||
vf.offset = 8
|
||||
#vf.mask = 0xFF
|
||||
@ -480,7 +480,7 @@ try:
|
||||
p.protocol_id.id = ost_pb.Protocol.kIp4FieldNumber
|
||||
p.Extensions[ip4].src_ip = 0x01020304
|
||||
p.Extensions[ip4].dst_ip = 0x05060708
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter16
|
||||
vf.offset = 6
|
||||
vf.mask = 0x1FFF
|
||||
@ -549,7 +549,7 @@ try:
|
||||
p.protocol_id.id = ost_pb.Protocol.kIp4FieldNumber
|
||||
p.Extensions[ip4].src_ip = 0x01020304
|
||||
p.Extensions[ip4].dst_ip = 0x05060708
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter32
|
||||
vf.offset = 16
|
||||
vf.mask = 0x00FF0000
|
||||
@ -630,7 +630,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kPayloadFieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter32
|
||||
vf.offset = 0
|
||||
vf.mode = ost_pb.VariableField.kIncrement
|
||||
@ -700,7 +700,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kTcpFieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter32
|
||||
vf.offset = 4
|
||||
vf.value = 1000
|
||||
@ -773,7 +773,7 @@ try:
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kIcmpFieldNumber
|
||||
p.Extensions[icmp].identifier = 0xabcd
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter16
|
||||
vf.offset = 6
|
||||
vf.value = 1
|
||||
@ -847,14 +847,14 @@ try:
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kUdpFieldNumber
|
||||
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter16
|
||||
vf.offset = 0
|
||||
vf.value = 5000
|
||||
vf.mode = ost_pb.VariableField.kIncrement
|
||||
vf.count = 10
|
||||
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter16
|
||||
vf.offset = 2
|
||||
vf.value = 6000
|
||||
@ -925,7 +925,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kVlanFieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter16
|
||||
vf.offset = 2
|
||||
vf.value = 3
|
||||
@ -939,7 +939,7 @@ try:
|
||||
p.protocol_id.id = ost_pb.Protocol.kIp4FieldNumber
|
||||
p.Extensions[ip4].src_ip = 0x01020304
|
||||
p.Extensions[ip4].dst_ip = 0x05060708
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter32
|
||||
vf.offset = 12
|
||||
vf.mask = 0x0000ff00
|
||||
@ -950,7 +950,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kTcpFieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter16
|
||||
vf.offset = 2
|
||||
vf.value = 6666
|
||||
@ -959,7 +959,7 @@ try:
|
||||
|
||||
p = s.protocol.add()
|
||||
p.protocol_id.id = ost_pb.Protocol.kPayloadFieldNumber
|
||||
vf = p.variable_fields.add()
|
||||
vf = p.variable_field.add()
|
||||
vf.type = ost_pb.VariableField.kCounter8
|
||||
vf.offset = 0
|
||||
vf.mode = ost_pb.VariableField.kIncrement
|
||||
|
Loading…
Reference in New Issue
Block a user