Added "non promiscuous mode" to port notes as a limitation

This commit is contained in:
Srivats P. 2011-03-02 22:21:23 +05:30
parent 73afecc07a
commit 24dc621145
2 changed files with 13 additions and 8 deletions

View File

@ -90,18 +90,21 @@ void PcapPort::updateNotes()
{
QString notes;
if ((!monitorRx_->isPromiscuous()) || (!monitorTx_->isPromiscuous()))
notes.append("<li>Non Promiscuous Mode</li>");
if (!monitorRx_->isDirectional() && !hasExclusiveControl())
notes.append("<i>Rx Frames/Bytes</i>: Includes non Ostinato Tx pkts also (Tx by Ostinato are not included)<br>");
notes.append("<li><i>Rx Frames/Bytes</i>: Includes non Ostinato Tx pkts also (Tx by Ostinato are not included)</li>");
if (!monitorTx_->isDirectional() && !hasExclusiveControl())
notes.append("<i>Tx Frames/Bytes</i>: Only Ostinato Tx pkts (Tx by others NOT included)<br>");
notes.append("<li><i>Tx Frames/Bytes</i>: Only Ostinato Tx pkts (Tx by others NOT included)</li>");
if (notes.isEmpty())
data_.set_notes("");
else
data_.set_notes(QString("<b>Limitation(s)</b>"
"<p>%1<br>"
"Rx/Tx Rates are also subject to above limitation(s)</p>").
"<ul>%1</ul>"
"Rx/Tx Rates are also subject to above limitation(s)").
arg(notes).toStdString());
}
@ -109,22 +112,22 @@ PcapPort::PortMonitor::PortMonitor(const char *device, Direction direction,
AbstractPort::PortStats *stats)
{
int ret;
int flag = PCAP_OPENFLAG_PROMISCUOUS;
char errbuf[PCAP_ERRBUF_SIZE] = "";
direction_ = direction;
isDirectional_ = true;
isPromisc_ = true;
stats_ = stats;
_retry:
handle_ = pcap_open_live(device, 64 /* FIXME */, flag,
handle_ = pcap_open_live(device, 64 /* FIXME */, int(isPromisc_),
1000 /* ms */, errbuf);
if (handle_ == NULL)
{
if (flag && QString(errbuf).contains("promiscuous"))
if (isPromisc_ && QString(errbuf).contains("promiscuous"))
{
qDebug("%s:can't set promiscuous mode, trying non-promisc", device);
flag = 0;
isPromisc_ = false;
goto _retry;
}
else

View File

@ -78,12 +78,14 @@ protected:
pcap_t* handle() { return handle_; }
Direction direction() { return direction_; }
bool isDirectional() { return isDirectional_; }
bool isPromiscuous() { return isPromisc_; }
protected:
AbstractPort::PortStats *stats_;
private:
pcap_t *handle_;
Direction direction_;
bool isDirectional_;
bool isPromisc_;
};
class PortTransmitter: public QThread