2008-06-21 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Added 'const' modifiers to lot of 'char *' declarations; I used
the widely spread
| const char * ...
layout as far as possible. But for the list-of-strings variables,
I applied the more consistent and easier to read
| char const * const VAR[]
format.
Function/method declarations were updated to work with these
constant char-arrays.
diff -up kismet-2008-05-R1/packetracker.cc.~1~ kismet-2008-05-R1/packetracker.cc
--- kismet-2008-05-R1/packetracker.cc.~1~ 2007-10-06 23:09:03.000000000 +0200
+++ kismet-2008-05-R1/packetracker.cc 2008-06-21 18:11:56.000000000 +0200
@@ -1194,7 +1194,7 @@ void Packetracker::ProcessDataPacket(kis
}
unsigned int ipdata_dirty = 0;
- char *means = NULL;
+ const char *means = NULL;
if (info->proto.type == proto_dhcp_server &&
(client->ipdata.atype < address_dhcp ||
@@ -1294,7 +1294,7 @@ void Packetracker::ProcessDataPacket(kis
// Handle netstumbler packets
if (alertracker->PotentialAlert(arefs[NETSTUMBLER_AREF]) > 0) {
- char *nsversion;
+ const char *nsversion;
switch (info->proto.prototype_extra) {
case 22:
@@ -1320,8 +1320,8 @@ void Packetracker::ProcessDataPacket(kis
info->proto.type == proto_ttls || info->proto.type == proto_tls) {
// Handle EAP packets
- char *eapcode;
- char *eaptype;
+ const char *eapcode;
+ const char *eaptype;
switch (info->proto.prototype_extra) {
case EAP_CODE_REQUEST:
@@ -1373,7 +1373,7 @@ void Packetracker::ProcessDataPacket(kis
} else if (info->proto.type == proto_isakmp) {
// Handle ISAKMP traffic
- char *isakmpcode;
+ const char *isakmpcode;
switch (info->proto.prototype_extra) {
case ISAKMP_EXCH_NONE:
isakmpcode = "NONE";
@@ -2394,7 +2394,7 @@ int Packetracker::WriteXMLNetworks(strin
}
if (net->ipdata.atype > address_factory) {
- char *addrtype;
+ const char *addrtype;
switch (net->ipdata.atype) {
case address_dhcp:
addrtype = "dhcp";
@@ -2425,7 +2425,7 @@ int Packetracker::WriteXMLNetworks(strin
for (unsigned int cltr = 0; cltr < net->client_vec.size(); cltr++) {
wireless_client *cli = net->client_vec[cltr];
- char *clitype;
+ const char *clitype;
switch (cli->type) {
case client_fromds:
clitype = "fromds";
@@ -2527,7 +2527,7 @@ int Packetracker::WriteXMLNetworks(strin
if (cli->ipdata.atype > address_factory) {
- char *addrtype;
+ const char *addrtype;
switch (cli->ipdata.atype) {
case address_dhcp:
addrtype = "dhcp";
diff -up kismet-2008-05-R1/panelfront.cc.~1~ kismet-2008-05-R1/panelfront.cc
--- kismet-2008-05-R1/panelfront.cc.~1~ 2008-02-06 22:34:25.000000000 +0100
+++ kismet-2008-05-R1/panelfront.cc 2008-06-21 18:17:43.000000000 +0200
@@ -54,7 +54,7 @@
#if (defined(HAVE_LIBNCURSES) && defined(HAVE_LIBPANEL) && defined(BUILD_PANEL))
-char *KismetHelpText[] = {
+char const * const KismetHelpText[] = {
"KISMET PANELS INTERFACE",
"QUICK REFERENCE",
" Key Action",
@@ -138,7 +138,7 @@ char *KismetHelpText[] = {
// Narrow text
-char *KismetHelpTextNarrow[] = {
+char const * const KismetHelpTextNarrow[] = {
"KISMET PANELS INTERFACE",
"KISMET NETWORK PANEL",
"Key Action",
@@ -171,7 +171,7 @@ char *KismetHelpTextNarrow[] = {
};
-char *KismetHelpDetails[] = {
+char const * const KismetHelpDetails[] = {
"NETWORK DETAILS",
"This panel lists in depth information about",
"the selected network or group, which may or",
@@ -188,7 +188,7 @@ char *KismetHelpDetails[] = {
};
-char *KismetSortText[] = {
+char const * const KismetSortText[] = {
"Key Sort Key Sort",
" a Auto-fit (standard) c Channel",
" f First time seen F First time seen (descending)",
@@ -202,7 +202,7 @@ char *KismetSortText[] = {
};
-char *KismetSortTextNarrow[] = {
+char const * const KismetSortTextNarrow[] = {
"Key Sort Key Sort",
" a Auto-fit c Channel",
" f First time F First time (d)",
@@ -215,7 +215,7 @@ char *KismetSortTextNarrow[] = {
NULL
};
-char *KismetClientSortText[] = {
+char const * const KismetClientSortText[] = {
"Key Sort Key Sort",
" a Auto-fit (standard) c Channel",
" f First time seen F First time seen (descending)",
@@ -227,7 +227,7 @@ char *KismetClientSortText[] = {
NULL
};
-char *KismetClientSortTextNarrow[] = {
+char const * const KismetClientSortTextNarrow[] = {
"Key Sort Key Sort",
" a Auto-fit c Channel",
" f First time F First time (d)",
@@ -239,7 +239,7 @@ char *KismetClientSortTextNarrow[] = {
NULL
};
-char *KismetHelpPower[] = {
+char const * const KismetHelpPower[] = {
"KISMET POWER",
"This panel lists the overall signal (S) and "
"noise (N) levels reported by the wireless card, if",
@@ -250,7 +250,7 @@ char *KismetHelpPower[] = {
};
-char *KismetHelpRate[] = {
+char const * const KismetHelpRate[] = {
"KISMET PACKET RATE",
"This panel displays a moving graph of the rate at which",
"packets are seen. The graph covers the last 5 minutes.",
@@ -260,7 +260,7 @@ char *KismetHelpRate[] = {
};
-char *KismetHelpGps[] = {
+char const * const KismetHelpGps[] = {
"KISMET NETWORK FOLLOW",
"This panel estimates the center of a network, the current",
"direction of travel, and the direction of the network center",
@@ -273,7 +273,7 @@ char *KismetHelpGps[] = {
};
-char *KismetHelpStats[] = {
+char const * const KismetHelpStats[] = {
"KISMET NETWORK STATISTICS",
"This panel displays overall statistics about the wireless",
"networks seen, including how many are encrypted with WEP",
@@ -286,7 +286,7 @@ char *KismetHelpStats[] = {
};
-char *KismetHelpDump[] = {
+char const * const KismetHelpDump[] = {
"KISMET STRING DUMP",
"This panel displays printable strings from uencrypted data",
"packets. This is basially equivalent to the 'strings' command",
@@ -302,7 +302,7 @@ char *KismetHelpDump[] = {
};
-char *KismetHelpPack[] = {
+char const * const KismetHelpPack[] = {
"KISMET PACKET DUMP",
"This panel displays information about the packet types seen.",
"It is divided into 2 segments - The upper quarter displays a",
@@ -348,7 +348,7 @@ char *KismetHelpPack[] = {
NULL
};
-char *KismetHelpAlert[] = {
+char const * const KismetHelpAlert[] = {
"KISMET ALERTS",
"This panel tracks alert conditions, such as NetStumbler clients",
"or DOS attacks.",
@@ -358,7 +358,7 @@ char *KismetHelpAlert[] = {
NULL
};
-char *KismetClientHelpText[] = {
+char const * const KismetClientHelpText[] = {
"KISMET CLIENT LIST",
"QUICK REFERENCE",
" Key Action",
@@ -386,7 +386,7 @@ char *KismetClientHelpText[] = {
NULL,
};
-char *KismetClientHelpDetails[] = {
+char const * const KismetClientHelpDetails[] = {
"CLIENT DETAILS",
"This panel lists in depth information about",
"the selected client, which may or may not be",
@@ -400,7 +400,7 @@ char *KismetClientHelpDetails[] = {
NULL
};
-char *KismetHelpServer[] = {
+char const * const KismetHelpServer[] = {
"KISMET SERVERS",
" Key Action",
" Up Scroll list up",
@@ -423,7 +423,7 @@ char *KismetHelpServer[] = {
NULL
};
-char *KismetIntroText[] = {
+char const * const KismetIntroText[] = {
"",
"Welcome to the Kismet panels frontend.",
"Context help is available for all displays, press 'H' at any time",
@@ -1187,7 +1187,7 @@ PanelFront::kis_window *PanelFront::Spaw
}
// Spawn a text helpbox with the included help stuff
-void PanelFront::SpawnHelp(char **in_helptext) {
+void PanelFront::SpawnHelp(char const * const *in_helptext) {
kis_window *kwin = new kis_window;
// Fill in the window a bit
diff -up kismet-2008-05-R1/server_protocols.cc.~1~ kismet-2008-05-R1/server_protocols.cc
--- kismet-2008-05-R1/server_protocols.cc.~1~ 2008-03-16 18:59:00.000000000 +0100
+++ kismet-2008-05-R1/server_protocols.cc 2008-06-21 18:13:30.000000000 +0200
@@ -23,23 +23,23 @@
#include "server_protocols.h"
#include "server_globals.h"
-char *INFO_fields_text[] = {
+char const * const INFO_fields_text[] = {
"networks", "packets", "crypt", "weak",
"noise", "dropped", "rate", "signal",
NULL
};
-char *STATUS_fields_text[] = {
+char const * const STATUS_fields_text[] = {
"text",
NULL
};
-char *ALERT_fields_text[] = {
+char const * const ALERT_fields_text[] = {
"sec", "usec", "header", "bssid", "source", "dest", "other", "channel", "text",
NULL
};
-char *PACKET_fields_text[] = {
+char const * const PACKET_fields_text[] = {
"type", "subtype", "timesec", "encrypted",
"weak", "beaconrate", "sourcemac", "destmac",
"bssid", "ssid", "prototype", "sourceip",
@@ -48,52 +48,52 @@ char *PACKET_fields_text[] = {
NULL
};
-char *STRING_fields_text[] = {
+char const * const STRING_fields_text[] = {
"bssid", "sourcemac", "text",
NULL
};
-char *CISCO_fields_text[] = {
+char const * const CISCO_fields_text[] = {
"placeholder",
NULL
};
-char *KISMET_fields_text[] = {
+char const * const KISMET_fields_text[] = {
"version", "starttime", "servername", "timestamp", "channelhop", "newversion",
NULL
};
-char *PROTOCOLS_fields_text[] = {
+char const * const PROTOCOLS_fields_text[] = {
"protocols",
NULL
};
-char *CAPABILITY_fields_text[] = {
+char const * const CAPABILITY_fields_text[] = {
"capabilities",
NULL
};
-char *TIME_fields_text[] = {
+char const * const TIME_fields_text[] = {
"timesec",
NULL
};
-char *TERMINATE_fields_text[] = {
+char const * const TERMINATE_fields_text[] = {
"text",
NULL
};
-char *GPS_fields_text[] = {
+char const * const GPS_fields_text[] = {
"lat", "lon", "alt", "spd", "heading", "fix",
NULL
};
-char *REMOVE_fields_text[] = {
+char const * const REMOVE_fields_text[] = {
"bssid",
NULL
};
-char *NETWORK_fields_text[] = {
+char const * const NETWORK_fields_text[] = {
"bssid", "type", "ssid", "beaconinfo",
"llcpackets", "datapackets", "cryptpackets",
"weakpackets", "channel", "wep", "firsttime",
@@ -114,7 +114,7 @@ char *NETWORK_fields_text[] = {
NULL
};
-char *CLIENT_fields_text[] = {
+char const * const CLIENT_fields_text[] = {
"bssid", "mac", "type", "firsttime", "lasttime",
"manufkey", "manufscore",
"datapackets", "cryptpackets", "weakpackets",
@@ -131,22 +131,22 @@ char *CLIENT_fields_text[] = {
NULL
};
-char *ERROR_fields_text[] = {
+char const * const ERROR_fields_text[] = {
"text",
NULL
};
-char *ACK_fields_text[] = {
+char const * const ACK_fields_text[] = {
"cmdnum",
NULL
};
-char *WEPKEY_fields_text[] = {
+char const * const WEPKEY_fields_text[] = {
"origin", "bssid", "key", "encrypted", "failed",
NULL
};
-char *CARD_fields_text[] = {
+char const * const CARD_fields_text[] = {
"interface", "type", "username", "channel", "id", "packets", "hopping",
NULL
};
diff -up kismet-2008-05-R1/tcpserver.cc.~1~ kismet-2008-05-R1/tcpserver.cc
--- kismet-2008-05-R1/tcpserver.cc.~1~ 2007-01-26 17:26:57.000000000 +0100
+++ kismet-2008-05-R1/tcpserver.cc 2008-06-21 18:15:29.000000000 +0200
@@ -567,7 +567,7 @@ int TcpServer::SendMainProtocols(int in_
return SendToClient(in_fd, in_ref, (void *) &protocol_map);
}
-int TcpServer::RegisterProtocol(string in_header, int in_required, char **in_fields,
+int TcpServer::RegisterProtocol(string in_header, int in_required, char const * const *in_fields,
int (*in_printer)(PROTO_PARMS),
void (*in_enable)(int)) {
// First, see if we're already registered and return a -1 if we are. You can't
diff -up kismet-2008-05-R1/gpsmap.cc.~1~ kismet-2008-05-R1/gpsmap.cc
--- kismet-2008-05-R1/gpsmap.cc.~1~ 2008-06-21 18:23:33.000000000 +0200
+++ kismet-2008-05-R1/gpsmap.cc 2008-06-21 18:29:56.000000000 +0200
@@ -162,7 +162,7 @@ const uint8_t track_decay = 0x1F;
const unsigned int horiz_throttle = 75000;
// Image colors
-const char *netcolors[] = {
+char const * const netcolors[] = {
"#000000",
"#FF0000", "#FF0072", "#FF00E5", "#D400FF",
"#5D00FF", "#0087FF", "#00F2FF", "#00FF94",
@@ -174,7 +174,7 @@ const char *netcolors[] = {
// Channel colors
/*
-char *channelcolors[] = {
+char const * const channelcolors[] = {
"#FF0000", "#FF8000", "#FFFF00",
"#80FF00", "#00FF00", "#00FF80",
"#00FFFF", "#0080FF", "#0000FF",
@@ -182,7 +182,7 @@ char *channelcolors[] = {
"#808080", "#CCCCCC"
};
*/
-char *channelcolors[] = {
+char const * const channelcolors[] = {
"#FF0000", "#FF6000", "#A08000",
"#80A000", "#60FF00", "#00FF00",
"#00FF60", "#00A080", "#0080A0",
@@ -191,7 +191,7 @@ char *channelcolors[] = {
int channelcolor_max = 14;
// Origional
-char *powercolors_Orig[] = {
+char const * const powercolors_Orig[] = {
"#FF0000", "#FFD500", "#FFCC00",
"#F2FF00", "#7BFF00", "#00FFB6",
"#00FFFF", "#005DFF", "#A100FF",
@@ -199,7 +199,7 @@ char *powercolors_Orig[] = {
};
const int power_steps_Orig = 10;
// Blue powercolors
-char *powercolors_Blue[] = {
+char const * const powercolors_Blue[] = {
"#A0A0FF",
"#9B9BFA",
"#9696F5",
@@ -236,7 +236,7 @@ char *powercolors_Blue[] = {
const int power_steps_Blue = 32;
// Math progression
-char *powercolors_Math[] = {
+char const * const powercolors_Math[] = {
"#FF0000", "#FF8000", "#FFFF00",
"#80FF00", "#00FF00", "#00FF80",
"#00FFFF", "#0080FF", "#0000FF",
@@ -244,7 +244,7 @@ char *powercolors_Math[] = {
};
const int power_steps_Math = 12;
// Weather Radar
-char *powercolors_Radar[] = {
+char const * const powercolors_Radar[] = {
"#50E350", "#39C339", "#208420",
"#145A14", "#C8C832", "#DC961E",
"#811610", "#B31A17", "#E61E1E"
@@ -256,7 +256,7 @@ const int power_max = 255;
int powercolor_index = 0;
// Label gravity
-char *label_gravity_list[] = {
+char const * const label_gravity_list[] = {
"northwest", "north", "northeast",
"west", "center", "east",
"southwest", "south", "southeast"
@@ -411,7 +411,7 @@ int mapsource = -1;
int power_resolution = 5;
// Interpolation colors
// strength colors
-char **power_colors = NULL;
+char const * const *power_colors = NULL;
int power_steps = 0;
// Center resolution (size of circle)
int center_resolution = 2;
diff -up kismet-2008-05-R1/kismet_server.cc.~1~ kismet-2008-05-R1/kismet_server.cc
--- kismet-2008-05-R1/kismet_server.cc.~1~ 2008-06-21 18:23:33.000000000 +0200
+++ kismet-2008-05-R1/kismet_server.cc 2008-06-21 18:25:09.000000000 +0200
@@ -230,14 +230,14 @@ int retain_monitor;
int netcryptdetect = 0;
// Shutdown/restore networkmanager (if we can)
-int networkmanager_control(char *cmd) {
+int networkmanager_control(const char *cmd) {
#ifdef HAVE_DBUS
DBusMessage* msg;
DBusConnection* conn;
DBusError err;
- char *name = "org.freedesktop.NetworkManager";
- char *path = "/org/freedesktop/NetworkManager";
+ const char *name = "org.freedesktop.NetworkManager";
+ const char *path = "/org/freedesktop/NetworkManager";
// initialise the error value
dbus_error_init(&err);
diff -up kismet-2008-05-R1/panelfront.h.~1~ kismet-2008-05-R1/panelfront.h
--- kismet-2008-05-R1/panelfront.h.~1~ 2008-06-21 18:23:33.000000000 +0200
+++ kismet-2008-05-R1/panelfront.h 2008-06-21 18:27:48.000000000 +0200
@@ -58,28 +58,28 @@
#define ACS_VLINE '|'
#endif
-extern char *KismetHelpText[];
-extern char *KismetHelpTextNarrow[];
-extern char *KismetHelpDetails[];
-extern char *KismetSortText[];
-extern char *KismetSortTextNarrow[];
+extern char const * const KismetHelpText[];
+extern char const * const KismetHelpTextNarrow[];
+extern char const * const KismetHelpDetails[];
+extern char const * const KismetSortText[];
+extern char const * const KismetSortTextNarrow[];
#define SORT_SIZE 10
-extern char *KismetHelpPower[];
-extern char *KismetHelpRate[];
-extern char *KismetHelpGps[];
-extern char *KismetHelpStats[];
-extern char *KismetHelpDump[];
-extern char *KismetHelpPack[];
-extern char *KismetHelpAlert[];
-extern char *KismetHelpServer[];
-
-extern char *KismetClientHelpText[];
-extern char *KismetClientHelpDetails[];
-extern char *KismetClientSortText[];
-extern char *KismetClientSortTextNarrow[];
+extern char const * const KismetHelpPower[];
+extern char const * const KismetHelpRate[];
+extern char const * const KismetHelpGps[];
+extern char const * const KismetHelpStats[];
+extern char const * const KismetHelpDump[];
+extern char const * const KismetHelpPack[];
+extern char const * const KismetHelpAlert[];
+extern char const * const KismetHelpServer[];
+
+extern char const * const KismetClientHelpText[];
+extern char const * const KismetClientHelpDetails[];
+extern char const * const KismetClientSortText[];
+extern char const * const KismetClientSortTextNarrow[];
#define CLIENT_SORT_SIZE 8
-extern char *KismetIntroText[];
+extern char const * const KismetIntroText[];
// These are in the kismet_curses.cc main code
extern int sound;
@@ -318,7 +318,7 @@ protected:
key_handler in_input, int in_x = -1, int in_y = -1);
// Spawn a help popup
- void SpawnHelp(char **in_helptext);
+ void SpawnHelp(char const * const in_helptext[]);
// Kill a window
void DestroyWindow(kis_window *in_window);
diff -up kismet-2008-05-R1/server_protocols.h.~1~ kismet-2008-05-R1/server_protocols.h
--- kismet-2008-05-R1/server_protocols.h.~1~ 2008-06-21 18:23:33.000000000 +0200
+++ kismet-2008-05-R1/server_protocols.h 2008-06-21 18:24:28.000000000 +0200
@@ -139,25 +139,25 @@ enum CARD_fields {
};
// Builtin client/server field contents
-extern char *KISMET_fields_text[];
-extern char *CAPABILITY_fields_text[];
-extern char *PROTOCOLS_fields_text[];
-extern char *ERROR_fields_text[];
-extern char *NETWORK_fields_text[];
-extern char *CLIENT_fields_text[];
-extern char *GPS_fields_text[];
-extern char *TIME_fields_text[];
-extern char *INFO_fields_text[];
-extern char *REMOVE_fields_text[];
-extern char *STATUS_fields_text[];
-extern char *ALERT_fields_text[];
-extern char *ACK_fields_text[];
-extern char *PACKET_fields_text[];
-extern char *STRING_fields_text[];
-extern char *TERMINATE_fields_text[];
-extern char *CISCO_fields_text[];
-extern char *WEPKEY_fields_text[];
-extern char *CARD_fields_text[];
+extern char const * const KISMET_fields_text[];
+extern char const * const CAPABILITY_fields_text[];
+extern char const * const PROTOCOLS_fields_text[];
+extern char const * const ERROR_fields_text[];
+extern char const * const NETWORK_fields_text[];
+extern char const * const CLIENT_fields_text[];
+extern char const * const GPS_fields_text[];
+extern char const * const TIME_fields_text[];
+extern char const * const INFO_fields_text[];
+extern char const * const REMOVE_fields_text[];
+extern char const * const STATUS_fields_text[];
+extern char const * const ALERT_fields_text[];
+extern char const * const ACK_fields_text[];
+extern char const * const PACKET_fields_text[];
+extern char const * const STRING_fields_text[];
+extern char const * const TERMINATE_fields_text[];
+extern char const * const CISCO_fields_text[];
+extern char const * const WEPKEY_fields_text[];
+extern char const * const CARD_fields_text[];
// Client/server protocol data structures. These get passed as void *'s to each of the
// protocol functions.
diff -up kismet-2008-05-R1/tcpserver.h.~1~ kismet-2008-05-R1/tcpserver.h
--- kismet-2008-05-R1/tcpserver.h.~1~ 2008-06-21 18:23:33.000000000 +0200
+++ kismet-2008-05-R1/tcpserver.h 2008-06-21 18:26:04.000000000 +0200
@@ -128,7 +128,7 @@ public:
// of protocol. (ie, send all networks when the client enables the *NETWORK
// protocol)
// It returns the index number of the sentence added.
- int RegisterProtocol(string in_header, int in_required, char **in_fields,
+ int RegisterProtocol(string in_header, int in_required, char const * const in_fields[],
int (*in_printer)(PROTO_PARMS),
void (*in_enable)(int));
int FetchProtocolRef(string in_header);