Kismet Wireless

Kismet Forums

 

Posted by:krisp
Subject:Patch to sort by signal dBm
Date:21:08:21 08/02/2011

Hi,

The signal readings from my atheros bullet2 appear to be logical, and I missed being able to sort by signal, so here's a patch to add it back in.

also available @ http://krisp.com/~krisp/kismet_sort-signal.diff

-----------------------------------------

diff -rupN kismet-2011-01-R1.orig/kis_panel_network.cc kismet-2011-01-R1/kis_panel_network.cc
--- kismet-2011-01-R1.orig/kis_panel_network.cc 2010-08-13 15:17:03.000000000 -0400
+++ kismet-2011-01-R1/kis_panel_network.cc 2011-02-08 11:16:59.181520269 -0500
@@ -675,6 +675,8 @@ int Kis_Netlist::UpdateSortPrefs() {
sort_mode = netsort_ssid;
else if (sort == "packets")
sort_mode = netsort_packets;
+ else if (sort == "signal")
+ sort_mode = netsort_sdbm;
else if (sort == "packets_desc")
sort_mode = netsort_packets_desc;
else if (sort == "crypt_type")
@@ -2310,6 +2312,10 @@ void Kis_Netlist::UpdateTrigger(void) {
stable_sort(draw_vec->begin(), draw_vec->end(),
KisNetlist_Sort_Ssid());
break;
+ case netsort_sdbm:
+ stable_sort(draw_vec->begin(), draw_vec->end(),
+ KisNetlist_Sort_Sdbm());
+ break;
case netsort_packets:
stable_sort(draw_vec->begin(), draw_vec->end(),
KisNetlist_Sort_Packets());
diff -rupN kismet-2011-01-R1.orig/kis_panel_network.h kismet-2011-01-R1/kis_panel_network.h
--- kismet-2011-01-R1.orig/kis_panel_network.h 2009-11-05 18:07:44.000000000 -0500
+++ kismet-2011-01-R1/kis_panel_network.h 2011-02-08 11:13:33.313520525 -0500
@@ -161,7 +161,7 @@ enum netsort_opts {
netsort_autofit, netsort_recent, netsort_type, netsort_channel,
netsort_first, netsort_first_desc, netsort_last, netsort_last_desc,
netsort_bssid, netsort_ssid, netsort_packets, netsort_packets_desc,
- netsort_crypt
+ netsort_crypt, netsort_sdbm
};

/* color array positions */
diff -rupN kismet-2011-01-R1.orig/kis_panel_sort.h kismet-2011-01-R1/kis_panel_sort.h
--- kismet-2011-01-R1.orig/kis_panel_sort.h 2009-04-29 15:22:32.000000000 -0400
+++ kismet-2011-01-R1/kis_panel_sort.h 2011-02-08 12:31:55.838021282 -0500
@@ -139,6 +139,26 @@ public:
}
};

+class KisNetlist_Sort_Sdbm {
+public:
+ inline bool operator()(Kis_Display_NetGroup *x,
+ Kis_Display_NetGroup *y) const {
+ Netracker::tracked_network *xm = x->FetchNetwork();
+ Netracker::tracked_network *ym = y->FetchNetwork();
+
+ if (xm == NULL || ym == NULL )
+ return 0;
+
+ if (time(0) - xm->last_time > 5)
+ return 0;
+
+ if (time(0) - ym->last_time > 5)
+ return 1;
+
+ return xm->snrdata.last_signal_dbm > ym->snrdata.last_signal_dbm;
+ }
+};
+
class KisNetlist_Sort_Packets {
public:
inline bool operator()(Kis_Display_NetGroup *x,
diff -rupN kismet-2011-01-R1.orig/kis_panel_windows.cc kismet-2011-01-R1/kis_panel_windows.cc
--- kismet-2011-01-R1.orig/kis_panel_windows.cc 2010-12-03 11:22:01.000000000 -0500
+++ kismet-2011-01-R1/kis_panel_windows.cc 2011-02-08 11:23:53.157520349 -0500
@@ -159,6 +159,7 @@ Kis_Main_Panel::Kis_Main_Panel(GlobalReg
mi_sort_last_d = menu->AddMenuItem("Latest Seen (descending)", mn_sort, 'L');
mi_sort_bssid = menu->AddMenuItem("BSSID", mn_sort, 'b');
mi_sort_ssid = menu->AddMenuItem("SSID", mn_sort, 's');
+ mi_sort_sdbm = menu->AddMenuItem("Signal", mn_sort, 'S');
mi_sort_packets = menu->AddMenuItem("Packets", mn_sort, 'p');
mi_sort_packets_d = menu->AddMenuItem("Packets (descending)", mn_sort, 'P');

@@ -172,6 +173,7 @@ Kis_Main_Panel::Kis_Main_Panel(GlobalReg
menu->SetMenuItemCheckSymbol(mi_sort_last_d, '*');
menu->SetMenuItemCheckSymbol(mi_sort_bssid, '*');
menu->SetMenuItemCheckSymbol(mi_sort_ssid, '*');
+ menu->SetMenuItemCheckSymbol(mi_sort_sdbm, '*');
menu->SetMenuItemCheckSymbol(mi_sort_packets, '*');
menu->SetMenuItemCheckSymbol(mi_sort_packets_d, '*');

@@ -1133,6 +1135,8 @@ void Kis_Main_Panel::MenuAction(int opt)
kpinterface->prefs->SetOpt("NETLIST_SORT", "bssid", time(0));
} else if (opt == mi_sort_ssid) {
kpinterface->prefs->SetOpt("NETLIST_SORT", "ssid", time(0));
+ } else if (opt == mi_sort_sdbm) {
+ kpinterface->prefs->SetOpt("NETLIST_SORT", "signal", time(0));
} else if (opt == mi_sort_packets) {
kpinterface->prefs->SetOpt("NETLIST_SORT", "packets", time(0));
} else if (opt == mi_sort_packets_d) {
@@ -1324,6 +1328,7 @@ void Kis_Main_Panel::UpdateSortMenu() {
menu->SetMenuItemChecked(mi_sort_last_d, so == netsort_last_desc);
menu->SetMenuItemChecked(mi_sort_bssid, so == netsort_bssid);
menu->SetMenuItemChecked(mi_sort_ssid, so == netsort_ssid);
+ menu->SetMenuItemChecked(mi_sort_sdbm, so == netsort_sdbm);
menu->SetMenuItemChecked(mi_sort_packets, so == netsort_packets);
menu->SetMenuItemChecked(mi_sort_packets_d, so == netsort_packets_desc);
}
@@ -3118,6 +3123,8 @@ Kis_Clientlist_Panel::Kis_Clientlist_Pan
menu->SetMenuItemCheckSymbol(mi_sort_last, '*');
mi_sort_last_d = menu->AddMenuItem("Latest Seen (descending)", mn_sort, 'L');
menu->SetMenuItemCheckSymbol(mi_sort_last_d, '*');
+ mi_sort_sdbm = menu->AddMenuItem("Signal", mn_sort, 'S');
+ menu->SetMenuItemCheckSymbol(mi_sort_sdbm, '*');
mi_sort_mac = menu->AddMenuItem("MAC", mn_sort, 's');
menu->SetMenuItemCheckSymbol(mi_sort_mac, '*');
mi_sort_packets = menu->AddMenuItem("Packets", mn_sort, 'p');
diff -rupN kismet-2011-01-R1.orig/kis_panel_windows.h kismet-2011-01-R1/kis_panel_windows.h
--- kismet-2011-01-R1.orig/kis_panel_windows.h 2010-01-01 13:57:32.000000000 -0500
+++ kismet-2011-01-R1/kis_panel_windows.h 2011-02-08 11:34:05.374020292 -0500
@@ -127,7 +127,7 @@ protected:

int mn_sort, mi_sort_auto, mi_sort_type, mi_sort_chan, mi_sort_crypt, mi_sort_first,
mi_sort_first_d, mi_sort_last, mi_sort_last_d, mi_sort_bssid, mi_sort_ssid,
- mi_sort_packets, mi_sort_packets_d;
+ mi_sort_packets, mi_sort_packets_d, mi_sort_sdbm;
int mn_sort_appended;

int mn_view, mi_shownetworks, mi_showclients, mi_showsummary, mi_showstatus,
@@ -450,7 +450,7 @@ protected:
int mn_preferences, mi_clicolprefs, mi_cliextraprefs;
int mn_sort, mi_sort_auto, mi_sort_type, mi_sort_first, mi_sort_first_d,
mi_sort_last, mi_sort_last_d, mi_sort_mac,
- mi_sort_packets, mi_sort_packets_d;
+ mi_sort_packets, mi_sort_packets_d, mi_sort_sdbm;
int mn_view, mi_addnote, mi_details;

int grapheventid;


Reply to this message