sign: Resolve a few FIXMEs

* Rename track_stream_stats to is_tracking_stream_stats for consistency
with other bool params
* Change signature magic value to CODA
* Resolve notify memory leak
This commit is contained in:
Srivats P 2017-12-03 11:26:09 +05:30
parent ee4bcb5b80
commit 81e7e735bc
8 changed files with 22 additions and 32 deletions

View File

@ -99,7 +99,7 @@ public:
OstProto::TransmitMode transmitMode()
{ return d.transmit_mode(); }
bool trackStreamStats()
{ return d.track_stream_stats(); }
{ return d.is_tracking_stream_stats(); }
double averagePacketRate()
{ return avgPacketsPerSec_; }
double averageBitRate()

View File

@ -67,7 +67,7 @@ PortConfigDialog::PortConfigDialog(
qDebug("reservedBy_ = %d", reservedBy_);
exclusiveControlButton->setChecked(portConfig_.is_exclusive_control());
streamStatsButton->setChecked(portConfig_.track_stream_stats());
streamStatsButton->setChecked(portConfig_.is_tracking_stream_stats());
// Disable UI elements based on portState
if (portState.is_transmit_on()) {
@ -105,7 +105,7 @@ void PortConfigDialog::accept()
}
pc.set_is_exclusive_control(exclusiveControlButton->isChecked());
pc.set_track_stream_stats(streamStatsButton->isChecked());
pc.set_is_tracking_stream_stats(streamStatsButton->isChecked());
// Update fields that have changed, clear the rest
if (pc.transmit_mode() != portConfig_.transmit_mode())
@ -123,10 +123,10 @@ void PortConfigDialog::accept()
else
portConfig_.clear_is_exclusive_control();
if (pc.track_stream_stats() != portConfig_.track_stream_stats())
portConfig_.set_track_stream_stats(pc.track_stream_stats());
if (pc.is_tracking_stream_stats() != portConfig_.is_tracking_stream_stats())
portConfig_.set_is_tracking_stream_stats(pc.is_tracking_stream_stats());
else
portConfig_.clear_track_stream_stats();
portConfig_.clear_is_tracking_stream_stats();
QDialog::accept();
}

View File

@ -726,7 +726,7 @@ void PortsWindow::on_actionPort_Configuration_triggered()
// which says copy only modifiable fields
//plm->port(current).protoDataCopyInto(&config);
config.set_transmit_mode(port.transmitMode());
config.set_track_stream_stats(port.trackStreamStats());
config.set_is_tracking_stream_stats(port.trackStreamStats());
config.set_is_exclusive_control(port.hasExclusiveControl());
config.set_user_name(port.userName().toStdString());

View File

@ -205,7 +205,7 @@ message Port {
optional bool is_exclusive_control = 6;
optional TransmitMode transmit_mode = 7 [default = kSequentialTransmit];
optional string user_name = 8;
optional bool track_stream_stats = 9; // FIXME: rename to is_XXX ?
optional bool is_tracking_stream_stats = 9;
}
message PortConfigList {

View File

@ -84,7 +84,7 @@ public:
static quint32 magic();
static bool packetGuid(const uchar *pkt, int pktLen, uint *guid);
private:
static const quint32 kSignMagic = 0xa1b2c3d4; // FIXME
static const quint32 kSignMagic = 0x1d10c0da; // coda! (unicode - 0x1d10c)
static const quint8 kTypeLenEnd = 0x00;
static const quint8 kTypeLenGuid = 0x61;
OstProto::Sign data;

View File

@ -78,8 +78,9 @@ bool AbstractPort::canModify(const OstProto::Port &port, bool *dirty)
allow = !isTransmitOn();
}
if (port.has_track_stream_stats()
&& (port.track_stream_stats() != data_.track_stream_stats())) {
if (port.has_is_tracking_stream_stats()
&& (port.is_tracking_stream_stats()
!= data_.is_tracking_stream_stats())) {
*dirty = true;
allow = !isTransmitOn();
}
@ -104,8 +105,8 @@ bool AbstractPort::modify(const OstProto::Port &port)
if (port.has_transmit_mode())
data_.set_transmit_mode(port.transmit_mode());
if (port.has_track_stream_stats())
ret |= setTrackStreamStats(port.track_stream_stats());
if (port.has_is_tracking_stream_stats())
ret |= setTrackStreamStats(port.is_tracking_stream_stats());
if (port.has_user_name()) {
data_.set_user_name(port.user_name());
@ -182,7 +183,7 @@ void AbstractPort::addNote(QString note)
bool AbstractPort::setTrackStreamStats(bool enable)
{
data_.set_track_stream_stats(enable);
data_.set_is_tracking_stream_stats(enable);
return true;
}

View File

@ -158,8 +158,8 @@ void MyService::modifyPort(::google::protobuf::RpcController* /*controller*/,
notif->set_notif_type(OstProto::portConfigChanged);
emit notification(notif->notif_type(), SharedProtobufMessage(notif));
}
// FIXME: potential memory leak of notif
else
delete notif;
}
void MyService::getStreamIdList(::google::protobuf::RpcController* controller,

View File

@ -60,18 +60,7 @@ env.user = 'tc'
env.password = 'tc'
env.host_string = 'localhost:50022'
tshark = get_tshark(minversion = '1.2.0') # FIXME: do we need a minversion?
# setup protocol number dictionary
# FIXME: remove if not reqd.
proto_number = {}
proto_number['mac'] = ost_pb.Protocol.kMacFieldNumber
proto_number['vlan'] = ost_pb.Protocol.kVlanFieldNumber
proto_number['eth2'] = ost_pb.Protocol.kEth2FieldNumber
proto_number['ip4'] = ost_pb.Protocol.kIp4FieldNumber
proto_number['ip6'] = ost_pb.Protocol.kIp6FieldNumber
proto_number['udp'] = ost_pb.Protocol.kUdpFieldNumber
proto_number['payload'] = ost_pb.Protocol.kPayloadFieldNumber
tshark = get_tshark(minversion = '2')
# setup logging
log = logging.getLogger(__name__)
@ -162,9 +151,9 @@ def ports(request, drone):
# Enable stream stats on ports
portConfig = ost_pb.PortConfigList()
portConfig.port.add().port_id.id = ports.x_num;
portConfig.port[0].track_stream_stats = True;
portConfig.port[0].is_tracking_stream_stats = True;
portConfig.port.add().port_id.id = ports.y_num;
portConfig.port[1].track_stream_stats = True;
portConfig.port[1].is_tracking_stream_stats = True;
print('Enabling Stream Stats tracking on ports X and Y');
drone.modifyPort(portConfig);
@ -511,7 +500,7 @@ def test_unidir(drone, ports, dut, dut_ports, dut_ip, emul_ports, dgid_list,
continue
filter='frame[-9:9]==00.' \
+ re.sub('..', '\g<0>.', format(guid, '06x')) \
+ '61.a1.b2.c3.d4 && !icmp && !icmpv6'
+ '61.1d.10.c0.da && !icmp && !icmpv6'
print(filter)
cap_pkts = subprocess.check_output([tshark, '-n', '-r', 'capX.pcap',
'-Y', filter])
@ -553,7 +542,7 @@ def test_unidir(drone, ports, dut, dut_ports, dut_ip, emul_ports, dgid_list,
continue
filter='frame[-9:9]==00.' \
+ re.sub('..', '\g<0>.', format(guid, '06x')) \
+ '61.a1.b2.c3.d4 && !icmp && !icmpv6'
+ '61.1d.10.c0.da && !icmp && !icmpv6'
print(filter)
cap_pkts = subprocess.check_output([tshark, '-n', '-r', 'capY.pcap',
'-Y', filter])