aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2006-08-16 18:01:25 +0000
committerGerald Combs <gerald@wireshark.org>2006-08-16 18:01:25 +0000
commitf9661850d17e2ad47db2cc7e8b19eea3c990a9b4 (patch)
treed147d42347f9f0c1696934f807b64856060b2f20
parentb02d08fa7653949f5f66bee94bfa9e80f6f1badc (diff)
Add support for AirPcap, an upcoming wireless product from CACE. Support
is disabled by default, and can be enabled by setting AIRPCAP_CONFIG in config.nmake. The code is currently limited to Windows, but should be adaptable to other platforms. The official announcement won't come until next week, so you'll have to read the source for details. :) svn path=/trunk/; revision=18928
-rw-r--r--Makefile.common2
-rw-r--r--Makefile.nmake1
-rw-r--r--airpcap.h669
-rw-r--r--airpcap_loader.c740
-rw-r--r--airpcap_loader.h296
-rw-r--r--config.h.win322
-rw-r--r--config.nmake12
-rw-r--r--epan/dissectors/packet-radiotap.c45
-rw-r--r--gtk/Makefile.am4
-rw-r--r--gtk/Makefile.common2
-rw-r--r--gtk/airpcap_dlg.c1872
-rw-r--r--gtk/airpcap_dlg.h148
-rwxr-xr-xgtk/airpcap_gui_utils.c400
-rwxr-xr-xgtk/airpcap_gui_utils.h127
-rw-r--r--gtk/capture_dlg.c131
-rw-r--r--gtk/capture_dlg.h10
-rw-r--r--gtk/capture_if_dlg.c190
-rw-r--r--gtk/capture_info_dlg.c11
-rw-r--r--gtk/compat_macros.h3
-rw-r--r--gtk/gui_utils.c20
-rw-r--r--gtk/gui_utils.h8
-rw-r--r--gtk/keys.h66
-rw-r--r--gtk/main.c419
-rw-r--r--gtk/main.h5
-rw-r--r--gtk/menu.c20
-rw-r--r--gtk/recent.c20
-rw-r--r--gtk/recent.h1
-rw-r--r--image/toolbar/capture_airpcap_16.xpm275
-rw-r--r--image/toolbar/capture_capture_16.xpm170
-rw-r--r--image/toolbar/capture_details_16.xpm150
-rw-r--r--image/toolbar/capture_ethernet_16.xpm163
-rw-r--r--image/toolbar/capture_prepare_16.xpm178
-rw-r--r--image/toolbar/wep_closed_24.xpm240
33 files changed, 6335 insertions, 65 deletions
diff --git a/Makefile.common b/Makefile.common
index 12661f8b9f..c94f0d9248 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -136,6 +136,7 @@ EXTRA_wireshark_INCLUDES = \
# wireshark specifics
wireshark_SOURCES = \
$(WIRESHARK_COMMON_SRC) \
+ airpcap_loader.c \
alert_box.c \
capture.c \
capture_info.c \
@@ -154,6 +155,7 @@ wireshark_SOURCES = \
# corresponding headers
wireshark_INCLUDES = \
+ airpcap_loader.h \
alert_box.h \
capture.h \
capture_info.h \
diff --git a/Makefile.nmake b/Makefile.nmake
index 6a95e7d626..f9119ecfb5 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -236,6 +236,7 @@ config.h : config.h.win32 config.nmake
-e "s/@HAVE_LIBGCRYPT@/$(LIBGCRYPT_CONFIG)/" \
-e "s/@HAVE_LUA@/$(LUA_CONFIG)/" \
-e "s/@HAVE_LUA_5_1@/$(LUA_VERSION)/" \
+ -e "s/@HAVE_AIRPCAP@/$(LUA_VERSION)/" \
< config.h.win32 > $@
ps.c : rdps.exe print.ps
diff --git a/airpcap.h b/airpcap.h
new file mode 100644
index 0000000000..d44206cfd6
--- /dev/null
+++ b/airpcap.h
@@ -0,0 +1,669 @@
+/*
+ * Copyright (c) 2006 CACE Technologies, Davis (California)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#if !defined(AIRPCAP_H__EAE405F5_0171_9592_B3C2_C19EC426AD34__INCLUDED_)
+#define AIRPCAP_H__EAE405F5_0171_9592_B3C2_C19EC426AD34__INCLUDED_
+
+/* This disables a VS warning for zero-sized arrays. All the compilers we support have that feature */
+#pragma warning( disable : 4200)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ \mainpage AirPcap interface documentation
+
+ \section Introduction
+
+ This document describes the data structures and the functions exported by the CACE Technologies AirPcap library.
+ The AirPcap library provides low-level access to the AirPcap driver including advanced capabilities such as channel setting,
+ link type control and WEP configuration.<br>
+ This manual includes the following sections:
+
+ \note throughout this documentation, \i device refers to a physical USB AirPcap device, wile \i adapter is an open API
+ instance. Most of the AirPcap API operations are adapter-specific but some of them, like setting the channel, are
+ per-device and will be reflected on all the open adapters. These functions will have "Device" in their name, e.g.
+ AirpcapSetDeviceChannel().
+
+ \b Sections:
+
+ - \ref airpcapfuncs
+ - \ref airpcapdefs
+ - \ref radiotap
+*/
+
+/** @defgroup airpcapdefs AirPcap definitions and data structures
+ * @{
+ */
+
+/*!
+ \brief This string is the fixed prefix in the airpcap adapter name.
+ It can be used to parse the name field in an AirpcapDeviceDescription structure.
+*/
+#define AIRPCAP_DEVICE_NAME_PREFIX "\\\\.\\airpcap"
+
+/*!
+ \brief This string is the scanf modifier to extract the adapter number from an adapter name.
+ It can be used to parse the name field in an AirpcapDeviceDescription structure with scanf.
+*/
+#define AIRPCAP_DEVICE_NUMBER_EXTRACT_STRING "\\\\.\\airpcap%u"
+
+/*!
+ \brief Entry in the list returned by \ref AirpcapGetDeviceList();
+*/
+typedef struct _AirpcapDeviceDescription
+{
+ struct _AirpcapDeviceDescription *next; /* Next element in the list */
+ PCHAR Name; /* Device name */
+ PCHAR Description; /* Device description */
+} AirpcapDeviceDescription, *PAirpcapDeviceDescription;
+
+#define WEP_KEY_MAX_SIZE 32 /* Maximum size of a WEP key, in bytes. This is the size of an entry in the */
+ /* AirpcapWepKeysCollection structure */
+
+#ifndef __MINGW32__
+#pragma pack(push)
+#pragma pack(1)
+#endif /* __MINGW32__ */
+
+
+#define AIRPCAP_KEYTYPE_WEP 0 /* Key type: WEP. The key can have an arbitrary length smaller than 32 bytes. */
+#define AIRPCAP_KEYTYPE_TKIP 1 /* Key type: TKIP (WPA). NOT SUPPORTED YET. */
+#define AIRPCAP_KEYTYPE_CCMP 2 /* Key type: CCMP (WPA2). NOT SUPPORTED YET. */
+
+/*!
+ \brief WEP key container
+*/
+typedef struct _AirpcapKey
+{
+ UINT KeyType; /* Type of key, can be on of: \ref AIRPCAP_KEYTYPE_WEP, \ref AIRPCAP_KEYTYPE_TKIP, \ref AIRPCAP_KEYTYPE_CCMP. Only AIRPCAP_KEYTYPE_WEP is supported by the driver at the moment. */
+ UINT KeyLen; /* Length of the key, in bytes */
+ BYTE KeyData[WEP_KEY_MAX_SIZE]; /* Key Data */
+}
+#ifdef __MINGW32__
+__attribute__((__packed__))
+#endif /* __MINGW32__ */
+AirpcapKey, *PAirpcapKey;
+
+/*!
+ \brief Type of frame validation the adapter performs.
+ An adapter can be instructed to accept different kind of frames: correct frames only, frames with wrong Frame Check Sequence (FCS) only, all frames.
+*/
+typedef enum _AirpcapValidationType
+{
+ AIRPCAP_VT_ACCEPT_EVERYTHING = 1, /* Accept all the frames the device captures */
+ AIRPCAP_VT_ACCEPT_CORRECT_FRAMES = 2, /* Accept correct frames only, i.e. frames with correct Frame Check Sequence (FCS). */
+ AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES = 3, /* Accept corrupt frames only, i.e. frames with worng Frame Check Sequence (FCS). */
+ AIRPCAP_VT_UNKNOWN = 4 /* Unknown validation type. You should see it only in case of error. */
+}AirpcapValidationType, *PAirpcapValidationType;
+
+/*!
+ \brief Type of decryption the adapter performs.
+ An adapter can be instructed to turn decryption (based on the device-configured keys configured
+ with \ref AirpcapSetDeviceKeys()) on or off.
+*/
+typedef enum _AirpcapDecryptionState
+{
+ AIRPCAP_DECRYPTION_ON = 1, /* This adapter performs decryption */
+ AIRPCAP_DECRYPTION_OFF = 2 /* This adapter does not perform decryption */
+}AirpcapDecryptionState, *PAirpcapDecryptionState;
+
+
+/*!
+ \brief Storage for a MAC address
+*/
+typedef struct _AirpcapMacAddress
+{
+ BYTE Address[6]; /* MAC address bytes */
+}
+#ifdef __MINGW32__
+__attribute__((__packed__))
+#endif /* __MINGW32__ */
+AirpcapMacAddress, *PAirpcapMacAddress;
+
+/*!
+ \brief This structure is used to store a collection of WEP keys.
+ Note that the definition of the structure doesn't contain any key, so be careful to allocate a buffer
+ with the size of the key, like in the following example:
+
+ \code
+ PAirpcapKeysCollection KeysCollection;
+ UINT KeysCollectionSize;
+
+ KeysCollectionSize = sizeof(AirpcapKeysCollection) + NumKeys * sizeof(AirpcapKey);
+
+ KeysCollection = (PAirpcapKeysCollection)malloc(KeysCollectionSize);
+ if(!KeysCollection)
+ {
+ // Error
+ }
+ \endcode
+*/
+typedef struct _AirpcapKeysCollection
+{
+ UINT nKeys; /* Number of keys in the collection */
+ AirpcapKey Keys[0]; /* Array of nKeys keys. */
+} AirpcapKeysCollection, *PAirpcapKeysCollection;
+
+/*!
+ \brief Packet header.
+
+ This structure defines the BPF that preceeds every packet delivered to the application.
+*/
+typedef struct _AirpcapBpfHeader
+{
+ UINT TsSec; /* Timestamp associated with the captured packet. SECONDS. */
+ UINT TsUsec; /* Timestamp associated with the captured packet. MICROSECONDS. */
+ UINT Caplen; /* Length of captured portion. The captured portion <b>can be different</b> from the original packet, because it is possible (with a proper filter) to instruct the driver to capture only a portion of the packets. */
+ UINT Originallen; /* Original length of packet */
+ USHORT Hdrlen; /* Length of bpf header (this struct plus alignment padding). In some cases, a padding could be added between the end of this structure and the packet data for performance reasons. This field can be used to retrieve the actual data of the packet. */
+}
+#ifdef __MINGW32__
+__attribute__((__packed__))
+#endif /* __MINGW32__ */
+AirpcapBpfHeader, *PAirpcapBpfHeader;
+
+/* Helper macros to extract packets coming from the driver. Rounds up to the next even multiple of AIRPCAP_ALIGNMENT. */
+#define AIRPCAP_ALIGNMENT sizeof(int)
+#define AIRPCAP_WORDALIGN(x) (((x)+(AIRPCAP_ALIGNMENT-1))&~(AIRPCAP_ALIGNMENT-1))
+
+#ifndef __MINGW32__
+#pragma pack(pop)
+#endif /* __MINGW32__ */
+
+#define AIRPCAP_ERRBUF_SIZE 512 /* Size of the error buffer, in bytes */
+
+#ifndef __AIRPCAP_DRIVER__
+
+/*!
+ \brief Link type.
+ AirPcap supports two kind of 802.11 linktypes: plain 802.11 and radiotap.
+*/
+typedef enum _AirpcapLinkType
+{
+ AIRPCAP_LT_802_11 = 1, /* plain 802.11 linktype. Every packet in the buffer contains the raw 802.11 frame, including MAC FCS. */
+ AIRPCAP_LT_802_11_PLUS_RADIO = 2, /* 802.11 plus radiotap linktype. Every packet in the buffer contains a radiotap header followed by the 802.11 frame. MAC FCS is included. */
+ AIRPCAP_LT_UNKNOWN = 3 /* Unknown linktype. You should see it only in case of error. */
+}AirpcapLinkType, *PAirpcapLinkType;
+
+#if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_)
+#define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_
+/*!
+ \brief Adapter handle.
+*/
+typedef struct _AirpcapHandle AirpcapHandle, *PAirpcapHandle;
+#endif
+
+/*!
+ \brief Capture statistics.
+ Returned by \ref AirpcapGetStats();
+*/
+typedef struct _AirpcapStats
+{
+ UINT Recvs; /* Number of packets that the driver received by the adapter */
+ /* from the beginning of the current capture. This value includes the packets */
+ /* dropped because of buffer full. */
+ UINT Drops; /* number of packets that the driver dropped from the beginning of a capture. */
+ /* A packet is lost when the the buffer of the driver is full. */
+ UINT IfDrops; /* Packets dropped by the card before going to the USB bus. */
+ /* Not supported at the moment. */
+ UINT Capt; /* number of packets that pass the BPF filter, find place in the kernel buffer and */
+ /* therefore reach the application. */
+}AirpcapStats, *PAirpcapStats;
+
+/*@}*/
+
+/** @defgroup airpcapfuncs AirPcap functions
+ * @{
+ */
+
+/*!
+ \brief Return a string with the API version
+ \param VersionMajor Pointer to a variable that will be filled with the major version number.
+ \param VersionMinor Pointer to a variable that will be filled with the minor version number.
+ \param VersionRev Pointer to a variable that will be filled with the revision number.
+ \param VersionBuild Pointer to a variable that will be filled with the build number.
+*/
+void AirpcapGetVersion(PUINT VersionMajor, PUINT VersionMinor, PUINT VersionRev, PUINT VersionBuild);
+
+/*!
+ \brief Return the last error related to the specified handle
+ \param AdapterHandle Handle to an open adapter.
+ \return The string with the last error.
+*/
+PCHAR AirpcapGetLastError(PAirpcapHandle AdapterHandle);
+
+/*!
+ \brief Return the list of available devices
+ \param PPAllDevs Address to a caller allocated pointer. On success this pointer will receive the head of a list of available devices.
+ \param Ebuf String that will contain error information if FALSE is returned. The size of the string must be AIRPCAP_ERRBUF_SIZE bytes.
+ \return TRUE on success. FALSE is returned on failure, in which case Ebuf is filled in with an appropriate error message.
+
+ Here's a snppet of code that shows how to use AirpcapGetDeviceList():
+
+ \code
+ CHAR Ebuf[AIRPCAP_ERRBUF_SIZE];
+ AirpcapDeviceDescription *Desc, *tDesc;
+
+ if(AirpcapGetDeviceList(&Desc, Ebuf) == -1)
+ {
+ printf("Unable to get the list of devices: %s\n", Ebuf);
+ return -1;
+ }
+
+ for(tDesc = Desc; tDesc; tDesc = tDesc->next)
+ {
+ printf("%u) %s (%s)\n",
+ ++i,
+ tDesc->Name,
+ tDesc->Description);
+ }
+ \endcode
+*/
+BOOL AirpcapGetDeviceList(PAirpcapDeviceDescription *PPAllDevs, PCHAR Ebuf);
+
+/*!
+ \brief Free a list of devices returned by AirpcapGetDeviceList()
+ \param PAllDevs Head of the list of devices returned by \ref AirpcapGetDeviceList().
+*/
+VOID AirpcapFreeDeviceList(PAirpcapDeviceDescription PAllDevs);
+
+/*!
+ \brief Open an adapter
+ \param DeviceName Name of the device to open. Use \ref AirpcapGetDeviceList() to get the list of devices.
+ \param Ebuf String that will contain error information in case of failure. The size of the string must be AIRPCAP_ERRBUF_SIZE bytes.
+ \return A PAirpcapHandle handle on success. NULL is returned on failure, in which case Ebuf is filled in with an appropriate error message.
+*/
+PAirpcapHandle AirpcapOpen(PCHAR DeviceName, PCHAR Ebuf);
+
+/*!
+ \brief Close an adapter
+ \param AdapterHandle Handle to the adapter to close.
+*/
+VOID AirpcapClose(PAirpcapHandle AdapterHandle);
+
+/*!
+ \brief Set the link type of an adapter
+ \param AdapterHandle Handle to the adapter.
+ \param NewLinkType the "link type", i.e. the format of the frames that will be received from the adapter.
+ \return TRUE on success.
+
+ the "link type" determines how the driver will encode the packets captured from the network.
+ Aircap supports two link types:
+ - AIRPCAP_LT_802_11, to capture 802.11 frames (including control frames) without any
+ power information. Look at the Capture_no_radio example application in the developer's pack
+ for a reference on how to decode 802.11 frames with this link type.
+ - AIRPCAP_LT_802_11_PLUS_RADIO, to capture 802.11 frames (including control frames) with a radiotap header
+ that contains power and channel information. More information about the radiotap header can be found int the
+ \ref radiotap section. Moreover, the "Capture_radio" example application in
+ the developer's pack can be used as a reference on how to decode 802.11 frames with radiotap headers.
+*/
+BOOL AirpcapSetLinkType(PAirpcapHandle AdapterHandle, AirpcapLinkType NewLinkType);
+
+/*!
+ \brief Get the link type of the specified adapter
+ \param AdapterHandle Handle to the adapter.
+ \param PLinkType Pointer to a caller allocated AirpcapLinkType variable that will contain the link type of the adapter.
+ \return TRUE on success.
+
+ the "link type" determines how the driver will encode the packets captured from the network.
+ Aircap supports two link types:
+ - AIRPCAP_LT_802_11, to capture 802.11 frames (including control frames) without any
+ power information. Look at the Capture_no_radio example application in the developer's pack
+ for a reference on how to decode 802.11 frames with this link type.
+ - AIRPCAP_LT_802_11_PLUS_RADIO, to capture 802.11 frames (including control frames) with a radiotap header
+ that contains power and channel information. More information about the radiotap header can be found int the
+ \ref radiotap section. Moreover, the "Capture_radio" example application in
+ the developer's pack can be used as a reference on how to decode 802.11 frames with radiotap headers.
+*/
+BOOL AirpcapGetLinkType(PAirpcapHandle AdapterHandle, PAirpcapLinkType PLinkType);
+
+/*!
+ \brief Configures the adapter on whether to include the MAC Frame Check Sequence in the captured packets.
+ \param AdapterHandle Handle to the adapter.
+ \param IsFcsPresent TRUE if the packets should include the FCS. FALSE otherwise
+ \return TRUE on success.
+
+ In the default configuration, the adapter includes the FCS in the captured packets. The MAC Frame Check Sequence
+ is 4 bytes and is located at the end of the 802.11 packet, with both AIRPCAP_LT_802_11 and AIRPCAP_LT_802_11_PLUS_RADIO
+ link types.
+ When the FCS inclusion is turned on, and if the link type is AIRPCAP_LT_802_11_PLUS_RADIO, the radiotap header
+ that precedes each frame has two additional fields at the end: Padding and FCS. These two fields are not present
+ when FCS inclusion is off.
+*/
+BOOL AirpcapSetFcsPresence(PAirpcapHandle AdapterHandle, BOOL IsFcsPresent);
+
+/*!
+ \brief Returns TRUE if the specified adapter includes the MAC Frame Check Sequence in the captured packets
+ \param AdapterHandle Handle to the adapter.
+ \param PIsFcsPresent User-provided variable that will be set to true if the adapter is including the FCS.
+ \return TRUE if the operation is successful. FALSE otherwise.
+
+ In the default configuration, the adatper has FCS inclusion turned on. The MAC Frame Check Sequence is 4 bytes
+ and is located at the end of the 802.11 packet, with both AIRPCAP_LT_802_11 and AIRPCAP_LT_802_11_PLUS_RADIO
+ link types.
+ When the FCS inclusion is turned on, and if the link type is AIRPCAP_LT_802_11_PLUS_RADIO, the radiotap header
+ that precedes each frame has two additional fields at the end: Padding and FCS. These two fields are not present
+ when FCS inclusion is off.
+*/
+BOOL AirpcapGetFcsPresence(PAirpcapHandle AdapterHandle, PBOOL PIsFcsPresent);
+
+/*!
+ \brief Configures the adapter to accept or drop frames with an incorrect Frame Check sequence (FCS).
+ \param AdapterHandle Handle to the adapter.
+ \param ValidationType The type of validation the driver will perform. See the documentation of \ref AirpcapValidationType for details.
+ \return TRUE on success.
+
+ \note By default, the driver is configured in \ref AIRPCAP_VT_ACCEPT_EVERYTHING mode.
+*/
+BOOL AirpcapSetFcsValidation(PAirpcapHandle AdapterHandle, AirpcapValidationType ValidationType);
+
+/*!
+ \brief Checks if the specified adapter is configured to capture frames with incorrect an incorrect Frame Check Sequence (FCS).
+ \param AdapterHandle Handle to the adapter.
+ \param ValidationType Pointer to a user supplied variable that will contain the type of validation the driver will perform. See the documentation of \ref AirpcapValidationType for details.
+ \return TRUE if the operation is succesful. FALSE otherwise.
+
+ \note By default, the driver is configured in \ref AIRPCAP_VT_ACCEPT_EVERYTHING mode.
+*/
+BOOL AirpcapGetFcsValidation(PAirpcapHandle AdapterHandle, PAirpcapValidationType ValidationType);
+
+/*!
+ \brief Set the list of decryption keys that the driver is going to use with the specified device.
+ \param AdapterHandle Handle an open adapter instance.
+ \param KeysCollection Pointer to a \ref PAirpcapKeysCollection structure that contains the keys to be set in the driver.
+ \return TRUE if the operation is successful. FALSE otherwise.
+
+ The AirPcap driver is able to use a set of decryption keys to decrypt the traffic transmitted on a specific SSID. If one of the
+ keys corresponds to the one the frame has been encrypted with, the driver will perform decryption and return the cleartext frames
+ to the application.
+ The driver supports, for every device, multiple keys at the same time.
+
+ At this time, the only supported decryption method is WEP.
+
+ The configured decryption keys are device-specific: they will not be used by other airpcap devices besides the specified one.
+
+ The keys are applied to the packets in the same order they appear in the KeysCollection structure until the packet is
+ correctly decrypted, therefore putting frequently used keys at the beginning of the structure improves performance.
+
+ \note: this is a Device-related function: when you change the channel from an open capture instance, the change will be
+ immediately reflected on all the other capture instances.
+*/
+BOOL AirpcapSetDeviceKeys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
+
+/*!
+ \brief Returns the list of decryption keys in the driver that are currently associated with the specified device
+ \param AdapterHandle Handle to an open adapter instance.
+ \param KeysCollection User-allocated PAirpcapKeysCollection structure that will be filled with the keys.
+ \param PKeysCollectionSize \b IN: pointer to a user-allocated variable that contains the length of the KeysCollection structure, in bytes.
+ \b OUT: amount of data moved by the driver in the buffer pointed by KeysBuffer, in bytes.
+ \return TRUE if the operation is succesful. If an error occurs, the return value is FALSE and KeysCollectionSize is zero.
+ If the provided buffer is too small to contain the keys, the return value is FALSE and KeysCollectionSize contains the
+ needed KeysCollection length, in bytes. If the device doesn't have any decryption key configured, the return value is TRUE, and
+ KeysCollectionSize will be zero.
+
+ This function returns the list of decryption keys in the driver that are associated with the specified device.
+ The AirPcap driver is able to use a set of decryption keys to decrypt the traffic transmitted on a specific SSID. If one of the
+ keys corresponds to the one the frame has been encrypted with, the driver will perform decryption and return the cleartext frames
+ to the application.
+ The driver supports, for every device, multiple keys at the same time.
+
+ The configured decryption keys are device-specific, therefore AirpcapGetDeviceKeys() will return a different set of keys
+ when called on different devices.
+
+ At this time, the only supported decryption method is WEP.
+
+ \note: this is a Device-related function: when you change the channel from an open capture instance, the change will be
+ immediately reflected on all the other capture instances.
+*/
+BOOL AirpcapGetDeviceKeys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize);
+
+/*!
+ \brief Turns on or off the decryption of the incoming frames
+ \param AdapterHandle Handle to the adapter.
+ \param ValidationType Either \ref AIRPCAP_DECRYPTION_ON or \ref AIRPCAP_DECRYPTION_OFF
+ \return TRUE on success.
+
+ The decryption keys can be configured with the \ref AirpcapSetDeviceKeys() function.
+ \note By default, the driver is configured with \ref AIRPCAP_DECRYPTION_ON.
+*/
+BOOL AirpcapSetDecryptionState(PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable);
+
+/*!
+ \brief Tells if this open instance is configured to perform the decryption of the incoming frames
+ \param AdapterHandle Handle to the adapter.
+ \param ValidationType Pointer to a user supplied variable that will contain the decryption configuration. See \ref PAirpcapDecryptionState for details.
+ \return TRUE if the operation is succesful. FALSE otherwise.
+
+ The decryption keys can be configured with the \ref AirpcapSetDeviceKeys() function.
+ \note By default, the driver is configured with \ref AIRPCAP_DECRYPTION_ON.
+*/
+BOOL AirpcapGetDecryptionState(PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable);
+
+/*!
+ \brief Set the radio channel of a device
+ \param AdapterHandle Handle to the adapter.
+ \param Channel the new channel to set.
+ \return TRUE on success.
+
+ Valid channels are in the range 1-14. The default channel setting is 6.
+
+ \note: this is a Device-related function: when you change the channel from an open capture instance, the change will be
+ immediately reflected on all the other capture instances.
+*/
+BOOL AirpcapSetDeviceChannel(PAirpcapHandle AdapterHandle, UINT Channel);
+
+/*!
+ \brief Get the radio channel of a device
+ \param AdapterHandle Handle to the adapter.
+ \param PChannel Pointer to a user-supplied variable into which the function will copy the currently configured radio channel.
+ \return TRUE on success.
+
+ Valid channels are in the range 1-14. The default channel setting is 6.
+
+ \note: this is a Device-related function: when you change the channel from an open capture instance, the change will be
+ immediately reflected on all the other capture instances.
+*/
+BOOL AirpcapGetDeviceChannel(PAirpcapHandle AdapterHandle, PUINT PChannel);
+
+/*!
+ \brief Set the size of the kernel packet buffer for this adapter
+ \param AdapterHandle Handle to the adapter.
+ \param BufferSize New size, in bytes.
+ \return TRUE on success.
+
+ Every AirPcap open instance has an associated kernel buffer, whose default size is 1 Mbyte.
+ This function can be used to change the size of this buffer, and can be called at any time.
+ A bigger kernel buffer size decreases the risk of dropping packets during network bursts or when the
+ application is busy, at the cost of higher kernel memory usage.
+
+ \note: don't use this function unless you know what you are doing. Due to chaching issues and bigger non-paged
+ memory consumption, Bigger buffer sizes can decrease the capture performace instead of improving it.
+*/
+BOOL AirpcapSetKernelBuffer(PAirpcapHandle AdapterHandle, UINT BufferSize);
+
+/*!
+ \brief Get the size of the kernel packet buffer for this adapter
+ \param AdapterHandle Handle to the adapter.
+ \param PSizeBytes User-allocated variable that will be filled with the size of the kernel buffer.
+ \return TRUE on success.
+
+ Every AirPcap open instance has an associated kernel buffer, whose default size is 1 Mbyte.
+ This function can be used to get the size of this buffer.
+*/
+BOOL AirpcapGetKernelBufferSize(PAirpcapHandle AdapterHandle, PUINT PSizeBytes);
+
+/*!
+ \brief Saves the configuration of the specified adapter in the registry, so that it becomes the default for this adapter.
+ \param AdapterHandle Handle to the adapter.
+ \return TRUE on success. FALSE on failure.
+
+ Almost all the AirPcap calls that modify the configuration (\ref AirpcapSetLinkType(), \ref AirpcapSetFcsPresence(),
+ \ref AirpcapSetFcsValidation(), \ref AirpcapSetKernelBuffer(), \ref AirpcapSetMinToCopy())
+ affect only the referenced AirPcap open instance. This means that if you do another \ref AirpcapOpen() on the same
+ adapter, the configuration changes will not be remembered, and the new adapter handle will have default configuration
+ settings.
+
+ Exceptions to this rule are the \ref AirpcapSetDeviceChannel() and \ref AirpcapSetDeviceKeys() functions: a channel change is
+ reflected on all the open instances, and remembered until the next call to \ref AirpcapSetDeviceChannel(), until the adapter
+ is unplugged, or until the machine is powered off. Same thing for the configuration of the WEP keys.
+
+ AirpcapStoreCurConfigAsAdapterDefault() stores the configuration of the give open instance as the default for the adapter:
+ all the instances opened in the future will have the same configuration that this adapter currently has.
+ The configuration is stored in the registry, therefore it is remembered even when the adapter is unplugged or the
+ machine is turned off. However, an adapter doesn't bring its configuration with it from machine to machine.
+
+ the configuration information saved in the registry includes the following parameters:
+ - channel
+ - kernel buffer size
+ - mintocopy
+ - link type
+ - CRC presence
+ - Encryption keys
+ - Encryption Enabled/Disabled state
+
+ The configuration is adapter-specific. This means that changing the configuration of an adapter
+ doesn't modify the one of the other adapters that are currently used or that will be used in the future.
+
+ \note AirpcapStoreCurConfigAsAdapterDefault() must have exclusive access to the adapter -- it
+ will fail if more than one AirPcap handle is opened at the same time for this adapter.
+ AirpcapStoreCurConfigAsAdapterDefault() needs administrator privileges. It will fail if the calling user
+ is not a local machine administrator.
+*/
+BOOL AirpcapStoreCurConfigAsAdapterDefault(PAirpcapHandle AdapterHandle);
+
+/*!
+ \brief Set the BPF kernel filter for an adapter
+ \param AdapterHandle Handle to the adapter.
+ \param Instructions pointer to the first BPF instruction in the array. Corresponds to the bf_insns
+ in a bpf_program structure (see the WinPcap documentation at http://www.winpcap.org/devel.htm).
+ \param Len Number of instructions in the array pointed by the previous field. Corresponds to the bf_len in
+ a a bpf_program structure (see the WinPcap documentation at http://www.winpcap.org/devel.htm).
+ \return TRUE on success.
+
+ The AirPcap driver is able to perform kernel-level filtering using the standard BPF pseudo-machine format. You can read
+ the WinPcap documentation at http://www.winpcap.org/devel.htm for more details on the BPF filtering mechaism.
+
+ A filter can be automatically created by using the pcap_compile() function of the WinPcap API. This function
+ converts a human readable text expression with the tcpdump/libpcap syntax into a BPF program.
+ If your program doesn't link wpcap, but you need to generate the code for a particular filter, you can run WinDump
+ with the -d or -dd or -ddd flags to obtain the pseudocode.
+
+*/
+BOOL AirpcapSetFilter(PAirpcapHandle AdapterHandle, PVOID Instructions, UINT Len);
+
+/*!
+ \brief Return the MAC address of an adapter.
+ \param AdapterHandle Handle to the adapter.
+ \param PMacAddress Pointer to a user allocated MAC address.
+ The size of this buffer needs to be at least 6 bytes.
+ \return TRUE on success.
+*/
+BOOL AirpcapGetMacAddress(PAirpcapHandle AdapterHandle, PAirpcapMacAddress PMacAddress);
+
+/*!
+ \brief Set the mintocopy parameter for an open adapter
+ \param AdapterHandle Handle to the adapter.
+ \param MinToCopy is the mintocopy size in bytes.
+ \return TRUE on success.
+
+ When the number of bytes in the kernel buffer changes from less than mintocopy bytes to greater than or equal to mintocopy bytes,
+ the read event is signalled (see \ref AirpcapGetReadEvent()). A high value for mintocopy results in poor responsiveness since the
+ driver may signal the application "long" after the arrival of the packet. And a high value results in low CPU loading
+ by minimizing the number of user/kernel context switches.
+ A low MinToCopy results in good responsiveness since the driver will signal the application close to the arrival time of
+ the packet. This has higher CPU loading over the first approach.
+*/
+BOOL AirpcapSetMinToCopy(PAirpcapHandle AdapterHandle, UINT MinToCopy);
+
+/*!
+ \brief Gets an event that is signaled when that is signalled when packets are available in the kernel buffer (see \ref AirpcapSetMinToCopy()).
+ \param AdapterHandle Handle to the adapter.
+ \param PReadEvent Pointer to a user-supplied handle that in which the read event will be copied.
+ \return TRUE on success.
+
+ \note the event is signalled when at least mintocopy bytes are present in the kernel buffer (see \ref AirpcapSetMinToCopy()).
+ This event can be used by WaitForSingleObject() and WaitForMultipleObjects() to create blocking behavior when reading
+ packets from one or more adapters (see \ref AirpcapRead()).
+*/
+BOOL AirpcapGetReadEvent(PAirpcapHandle AdapterHandle, HANDLE* PReadEvent);
+
+/*!
+ \brief Fills a user-provided buffer with zero or more packets that have been captured on the referenced adapter.
+ \param AdapterHandle Handle to the adapter.
+ \param Buffer pointer to the buffer that will be filled with captured packets.
+ \param BufSize size of the input buffer that will contain the packets, in bytes.
+ \param PReceievedBytes Pointer to a user supplied variable that will receive the number of bytes copied by AirpcapRead.
+ Can be smaller than BufSize.
+ \return TRUE on success.
+
+ 802.11 frames are returned by the driver in buffers. Every 802.11 frame in the buffer is preceded by a \ref AirpcapBpfHeader structure.
+ The suggested way to use an AirPcap adapter is through the pcap API exported by wpcap.dll. If this is not
+ possible, the Capture_radio and Capture_no_radio examples in the AirPcap developer's pack show how to properly decode the
+ packets in the read buffer returned by AirpcapRead().
+
+ \note this function is NOT blocking. Blocking behavior can be obtained using the event returned
+ by \ref AirpcapGetReadEvent(). See also \ref AirpcapSetMinToCopy().
+*/
+BOOL AirpcapRead(PAirpcapHandle AdapterHandle, PBYTE Buffer, UINT BufSize, PUINT PReceievedBytes);
+
+/*!
+ \brief Get per-adapter WinPcap-compatible capture statistics.
+ \param AdapterHandle Handle to the adapter.
+ \param PStats pointer to a user-allocated AirpcapStats structure that will be filled with statistical information.
+ \return TRUE on success.
+*/
+BOOL AirpcapGetStats(PAirpcapHandle AdapterHandle, PAirpcapStats PStats);
+
+/*!
+ \brief Get the number of LEDs the referenced adapter has available.
+ \param AdapterHandle Handle to the adapter.
+ \param NumberOfLeds Number of LEDs available on this adapter.
+ \return TRUE on success.
+*/
+BOOL AirpcapGetLedsNumber(PAirpcapHandle AdapterHandle, PUINT NumberOfLeds);
+
+/*!
+ \brief Turn on one of the adapter's LEDs.
+ \param AdapterHandle Handle to the adapter.
+ \param LedNumber zero-based identifier of the LED to turn on.
+ \return TRUE on success.
+*/
+BOOL AirpcapTurnLedOn(PAirpcapHandle AdapterHandle, UINT LedNumber);
+
+/*!
+ \brief Turn off one of the adapter's LEDs.
+ \param AdapterHandle Handle to the adapter.
+ \param LedNumber zero-based identifier of the LED to turn off.
+ \return TRUE on success.
+*/
+BOOL AirpcapTurnLedOff(PAirpcapHandle AdapterHandle, UINT LedNumber);
+
+/*@}*/
+
+#endif /* __AIRPCAP_DRIVER__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined(AIRPCAP_H__EAE405F5_0171_9592_B3C2_C19EC426AD34__INCLUDED_) */
diff --git a/airpcap_loader.c b/airpcap_loader.c
new file mode 100644
index 0000000000..3c5768e890
--- /dev/null
+++ b/airpcap_loader.c
@@ -0,0 +1,740 @@
+/* airpcap_loader.c
+ *
+ * $Id$
+ *
+ * Ulf Lamping <ulf.lamping@web.de>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2000 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef _WIN32
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_LIBPCAP
+#include <glib.h>
+#include <gmodule.h>
+
+
+#include <wtap.h>
+#include <pcap.h>
+#endif
+
+#include "capture_ui_utils.h"
+#include <epan/prefs.h>
+
+#include "simple_dialog.h"
+
+#include <airpcap.h>
+#include "airpcap_loader.h"
+
+/*
+ * We load dinamically the dag library in order link it only when
+ * it's present on the system
+ */
+static HMODULE AirpcapLib;
+
+static AirpcapGetLastErrorHandler g_PAirpcapGetLastError;
+static AirpcapGetDeviceListHandler g_PAirpcapGetDeviceList;
+static AirpcapFreeDeviceListHandler g_PAirpcapFreeDeviceList;
+static AirpcapOpenHandler g_PAirpcapOpen;
+static AirpcapCloseHandler g_PAirpcapClose;
+static AirpcapGetLinkTypeHandler g_PAirpcapGetLinkType;
+static AirpcapSetLinkTypeHandler g_PAirpcapSetLinkType;
+static AirpcapSetKernelBufferHandler g_PAirpcapSetKernelBuffer;
+static AirpcapSetFilterHandler g_PAirpcapSetFilter;
+static AirpcapGetMacAddressHandler g_PAirpcapGetMacAddress;
+static AirpcapSetMinToCopyHandler g_PAirpcapSetMinToCopy;
+static AirpcapGetReadEventHandler g_PAirpcapGetReadEvent;
+static AirpcapReadHandler g_PAirpcapRead;
+static AirpcapGetStatsHandler g_PAirpcapGetStats;
+static AirpcapTurnLedOnHandler g_PAirpcapTurnLedOn;
+static AirpcapTurnLedOffHandler g_PAirpcapTurnLedOff;
+static AirpcapGetDeviceChannelHandler g_PAirpcapGetDeviceChannel;
+static AirpcapSetDeviceChannelHandler g_PAirpcapSetDeviceChannel;
+static AirpcapGetFcsPresenceHandler g_PAirpcapGetFcsPresence;
+static AirpcapSetFcsPresenceHandler g_PAirpcapSetFcsPresence;
+static AirpcapGetFcsValidationHandler g_PAirpcapGetFcsValidation;
+static AirpcapSetFcsValidationHandler g_PAirpcapSetFcsValidation;
+static AirpcapGetDeviceKeysHandler g_PAirpcapGetDeviceKeys;
+static AirpcapSetDeviceKeysHandler g_PAirpcapSetDeviceKeys;
+static AirpcapGetDecryptionStateHandler g_PAirpcapGetDecryptionState;
+static AirpcapSetDecryptionStateHandler g_PAirpcapSetDecryptionState;
+static AirpcapStoreCurConfigAsAdapterDefaultHandler g_PAirpcapStoreCurConfigAsAdapterDefault;
+/* HAVE_AIRPCAP_API */
+
+/* Airpcap interface list */
+GList *airpcap_if_list = NULL;
+
+/* Airpcap current selected interface */
+airpcap_if_info_t *airpcap_if_selected = NULL;
+
+/* Airpcap current active interface */
+airpcap_if_info_t *airpcap_if_active = NULL;
+
+/*
+ * Get an error message string for a CANT_GET_INTERFACE_LIST error from
+ * "get_airpcap_interface_list()".
+ */
+gchar *
+cant_get_airpcap_if_list_error_message(const char *err_str)
+{
+ return g_strdup_printf("Can't get list of Wireless interfaces: %s", err_str);
+}
+
+/*
+ * Airpcap wrapper, used to store the current settings for the selected adapter
+ */
+BOOL
+airpcap_if_store_cur_config_as_adapter_default(PAirpcapHandle ah)
+{
+ return g_PAirpcapStoreCurConfigAsAdapterDefault(ah);
+}
+
+/*
+ * Airpcap wrapper, used to open an airpcap adapter
+ */
+PAirpcapHandle
+airpcap_if_open(PCHAR name, PCHAR err)
+{
+ return g_PAirpcapOpen(name,err);
+}
+
+/*
+ * Airpcap wrapper, used to close an airpcap adapter
+ */
+VOID
+airpcap_if_close(PAirpcapHandle handle)
+{
+g_PAirpcapClose(handle);
+
+}
+
+/*
+ * Airpcap wrapper, used to turn on the led of an airpcap adapter
+ */
+BOOL
+airpcap_if_turn_led_on(PAirpcapHandle AdapterHandle, UINT LedNumber)
+{
+ return g_PAirpcapTurnLedOn(AdapterHandle,LedNumber);
+}
+
+/*
+ * Airpcap wrapper, used to turn off the led of an airpcap adapter
+ */
+BOOL
+airpcap_if_turn_led_off(PAirpcapHandle AdapterHandle, UINT LedNumber)
+{
+ return g_PAirpcapTurnLedOff(AdapterHandle,LedNumber);
+}
+
+/*
+ * Airpcap wrapper, used to get the channel of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_device_channel(PAirpcapHandle ah, PUINT ch)
+{
+ return g_PAirpcapGetDeviceChannel(ah,ch);
+}
+
+/*
+ * Airpcap wrapper, used to set the channel of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_device_channel(PAirpcapHandle ah, UINT ch)
+{
+ return g_PAirpcapSetDeviceChannel(ah,ch);
+}
+
+/*
+ * Airpcap wrapper, used to get the link type of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_link_type(PAirpcapHandle ah, PAirpcapLinkType lt)
+{
+ return g_PAirpcapGetLinkType(ah,lt);
+}
+
+/*
+ * Airpcap wrapper, used to set the link type of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_link_type(PAirpcapHandle ah, AirpcapLinkType lt)
+{
+ return g_PAirpcapSetLinkType(ah,lt);
+}
+
+/*
+ * Airpcap wrapper, used to get the fcs presence of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_fcs_presence(PAirpcapHandle ah, PBOOL fcs)
+{
+ return g_PAirpcapGetFcsPresence(ah,fcs);
+}
+
+/*
+ * Airpcap wrapper, used to set the fcs presence of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_fcs_presence(PAirpcapHandle ah, BOOL fcs)
+{
+ return g_PAirpcapSetFcsPresence(ah,fcs);
+}
+
+/*
+ * Airpcap wrapper, used to get the decryption enabling of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState PEnable)
+{
+ return g_PAirpcapGetDecryptionState(ah,PEnable);
+}
+
+/*
+ * Airpcap wrapper, used to set the decryption enabling of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState Enable)
+{
+ return g_PAirpcapSetDecryptionState(ah,Enable);
+}
+
+/*
+ * Airpcap wrapper, used to get the fcs validation of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val)
+{
+ return g_PAirpcapGetFcsValidation(ah,val);
+}
+
+/*
+ * Airpcap wrapper, used to set the fcs validation of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_fcs_validation(PAirpcapHandle ah, AirpcapValidationType val)
+{
+ return g_PAirpcapSetFcsValidation(ah,val);
+}
+
+/*
+ * Airpcap wrapper, used to save the settings for the selected_if
+ */
+BOOL
+airpcap_if_set_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection)
+{
+ return g_PAirpcapSetDeviceKeys(AdapterHandle,KeysCollection);
+}
+
+/*
+ * Airpcap wrapper, used to save the settings for the selected_if
+ */
+BOOL
+airpcap_if_get_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize)
+{
+ return g_PAirpcapGetDeviceKeys(AdapterHandle,KeysCollection,PKeysCollectionSize);
+}
+
+/*
+ * This function will create a new airpcap_if_info_t using a name and a description
+ */
+airpcap_if_info_t *
+airpcap_if_info_new(char *name, char *description)
+{
+PAirpcapHandle ad;
+char* ebuf = NULL;
+
+ airpcap_if_info_t *if_info;
+
+ if_info = g_malloc(sizeof (airpcap_if_info_t));
+ if_info->name = g_strdup(name);
+ if (description == NULL)
+ if_info->description = NULL;
+ else
+ if_info->description = g_strdup(description);
+ if_info->ip_addr = NULL;
+ if_info->loopback = FALSE;
+
+ /* Probably I have to switch on the leds!!! */
+ ad = airpcap_if_open(if_info->name, ebuf);
+ if(ad)
+ {
+ airpcap_if_get_fcs_validation(ad,&(if_info->CrcValidationOn));
+ airpcap_if_get_fcs_presence(ad,&(if_info->IsFcsPresent));
+ airpcap_if_get_link_type(ad,&(if_info->linkType));
+ airpcap_if_get_device_channel(ad,&(if_info->channel));
+ airpcap_if_turn_led_on(ad, 0);
+ airpcap_if_get_decryption_state(ad, &(if_info->DecryptionOn));
+ if_info->led = TRUE;
+ if_info->blinking = FALSE;
+ if_info->saved = TRUE; /* NO NEED TO BE SAVED */
+
+ /* get the keys, if everything is ok, close the adapter */
+ if(airpcap_if_load_keys(ad,if_info))
+ airpcap_if_close(ad);
+ }
+ return if_info;
+}
+
+/*
+ * Function used to load the WEP keys for a selected interface
+ */
+BOOL
+airpcap_if_load_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info)
+{
+if_info->keysCollectionSize = 0;
+if_info->keysCollection = NULL;
+
+if(!airpcap_if_get_device_keys(ad, NULL, &(if_info->keysCollectionSize)))
+ {
+ if(if_info->keysCollectionSize == 0)
+ {
+ if_info->keysCollection = NULL;
+ airpcap_if_close(ad);
+ return FALSE;
+ }
+
+ if_info->keysCollection = (PAirpcapKeysCollection)malloc(if_info->keysCollectionSize);
+ if(!if_info->keysCollection)
+ {
+ if_info->keysCollectionSize = 0;
+ if_info->keysCollection = NULL;
+ airpcap_if_close(ad);
+ return FALSE;
+ }
+
+ airpcap_if_get_device_keys(ad, if_info->keysCollection, &(if_info->keysCollectionSize));
+ return TRUE;
+ }
+airpcap_if_close(ad);
+return FALSE;
+}
+
+/*
+ * Function used to save the WEP keys for a selected interface
+ */
+void
+airpcap_if_save_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info)
+{
+ if(if_info->keysCollection != NULL)
+ g_PAirpcapSetDeviceKeys(ad,if_info->keysCollection);
+}
+
+/*
+ * Callback used to free an instance of airpcap_if_info_t
+ */
+static void
+free_airpcap_if_cb(gpointer data, gpointer user_data _U_)
+{
+ airpcap_if_info_t *if_info = data;
+
+ if (if_info->name != NULL)
+ g_free(if_info->name);
+
+ if (if_info->description != NULL)
+ g_free(if_info->description);
+
+ /* XXX - FREE THE WEP KEY LIST HERE!!!*/
+ if(if_info->keysCollection != NULL)
+ g_free(if_info->keysCollection);
+
+ if(if_info->ip_addr != NULL)
+ g_slist_free(if_info->ip_addr);
+
+ if(if_info != NULL)
+ g_free(if_info);
+}
+
+/*
+ * Function used to free the airpcap interface list
+ */
+void
+free_airpcap_interface_list(GList *if_list)
+{
+ g_list_foreach(if_list, free_airpcap_if_cb, NULL);
+ g_list_free(if_list);
+ if_list = NULL;
+}
+
+/*
+ * This function will use the airpcap.dll to find all the airpcap devices.
+ * Will return null if no device is found.
+ */
+GList*
+get_airpcap_interface_list(int *err, char *err_str)
+{
+ GList *il = NULL;
+ airpcap_if_info_t *if_info;
+ int i, n_adapts;
+ AirpcapDeviceDescription *devsList, *adListEntry;
+
+ if(!g_PAirpcapGetDeviceList(&devsList, err_str))
+ {
+ /* No interfaces, return il = NULL; */
+ *err = NO_AIRPCAP_INTERFACES_FOUND;
+ return il;
+ }
+
+ /*
+ * Count the adapters
+ */
+ adListEntry = devsList;
+ n_adapts = 0;
+ while(adListEntry)
+ {
+ n_adapts++;
+ adListEntry = adListEntry->next;
+ }
+
+ if(n_adapts == 0)
+ {
+ /* No interfaces, return il= NULL */
+ g_PAirpcapFreeDeviceList(devsList);
+ *err = NO_AIRPCAP_INTERFACES_FOUND;
+ return il;
+ }
+
+ /*
+ * Insert the adapters in our list
+ */
+ adListEntry = devsList;
+ for(i = 0; i < n_adapts; i++)
+ {
+ if_info = airpcap_if_info_new(adListEntry->Name, adListEntry->Description);
+ il = g_list_append(il, if_info);
+
+ adListEntry = adListEntry->next;
+ }
+
+ g_PAirpcapFreeDeviceList(devsList);
+
+ return il;
+}
+
+/*
+ * Used to retrieve the name of the interface given the description
+ * (the name is used in AirpcapOpen, the description is put in the combo box)
+ */
+gchar* get_airpcap_name_from_description(GList* if_list, gchar* description)
+{
+unsigned int ifn;
+GList* curr;
+airpcap_if_info_t* if_info;
+
+ifn = 0;
+if(if_list != NULL)
+ {
+ while( ifn < g_list_length(if_list) )
+ {
+ curr = g_list_nth(if_list, ifn);
+
+ if_info = NULL;
+ if(curr != NULL)
+ if_info = curr->data;
+ if(if_info != NULL)
+ if ( g_ascii_strcasecmp(if_info->description,description) == 0)
+ {
+ return if_info->name;
+ }
+ ifn++;
+ }
+ }
+return NULL;
+}
+
+/*
+ * Used to retrieve the interface given the name
+ * (the name is used in AirpcapOpen)
+ */
+airpcap_if_info_t* get_airpcap_if_by_name(GList* if_list, const gchar* name)
+{
+unsigned int ifn;
+GList* curr;
+airpcap_if_info_t* if_info;
+
+ifn = 0;
+if(if_list != NULL)
+ {
+ while( ifn < g_list_length(if_list) )
+ {
+ curr = g_list_nth(if_list, ifn);
+
+ if_info = NULL;
+ if(curr != NULL)
+ if_info = curr->data;
+ if(if_info != NULL)
+ if ( g_ascii_strcasecmp(if_info->name,name) == 0)
+ {
+ return if_info;
+ }
+ ifn++;
+ }
+ }
+return NULL;
+}
+
+/*
+ * Returns the ASCII string of a key given the key bites
+ */
+gchar*
+airpcap_get_key_string(AirpcapKey key)
+{
+unsigned int j = 0;
+gchar *s,*s1;
+
+s = NULL;
+s1 = NULL;
+
+if(key.KeyType == AIRPCAP_KEYTYPE_WEP)
+ {
+ s = g_strdup_printf("");
+ for(j = 0; j < key.KeyLen != 0; j++)
+ {
+ s1 = g_strdup_printf("%.2x", key.KeyData[j]);
+ g_strlcat(s,s1,WEP_KEY_MAX_SIZE);
+ }
+ }
+return s;
+}
+
+/*
+ * Used to retrieve the airpcap_if_info_t of the selected interface given the
+ * description (that is the entry of the combo box).
+ */
+gpointer get_airpcap_if_from_description(GList* if_list, const gchar* description)
+{
+unsigned int ifn;
+GList* curr;
+airpcap_if_info_t* if_info;
+
+ifn = 0;
+if(if_list != NULL)
+ {
+ while( ifn < g_list_length(if_list) )
+ {
+ curr = g_list_nth(if_list, ifn);
+
+ if_info = NULL;
+ if(curr != NULL)
+ if_info = curr->data;
+ if(if_info != NULL)
+ if ( g_ascii_strcasecmp(if_info->description,description) == 0)
+ {
+ return if_info;
+ }
+ ifn++;
+ }
+ }
+return NULL;
+}
+
+/*
+ * Used to retrieve the two chars string from interface
+ */
+gchar*
+airpcap_get_if_string_number(airpcap_if_info_t* if_info)
+{
+ gchar* number;
+ guint n;
+ int a;
+
+ a = sscanf(if_info->name,AIRPCAP_DEVICE_NUMBER_EXTRACT_STRING,&n);
+
+ number = g_strdup_printf("%.2u\0",n);
+
+ return number;
+}
+
+/*
+ * Used to retrieve the two chars string from interface
+ */
+gchar*
+airpcap_get_if_string_number_from_description(gchar* description)
+{
+ gchar* number;
+ gchar* pointer;
+
+ number = (gchar*)g_malloc(sizeof(gchar)*3);
+
+ pointer = g_strrstr(description,"#\0");
+
+ number[0] = *(pointer+1);
+ number[1] = *(pointer+2);
+ number[2] = '\0';
+
+ return number;
+}
+
+/*
+ * Returns the default airpcap interface of a list, NULL if list is empty
+ */
+airpcap_if_info_t*
+airpcap_get_default_if(GList* airpcap_if_list)
+{
+int ifn = 0;
+GList* popdown_if_list = NULL;
+GList* curr = NULL;
+
+ gchar* s;
+ airpcap_if_info_t* if_info;
+
+ s = g_strdup(get_if_name(prefs.capture_device));
+ if_info = get_airpcap_if_by_name(airpcap_if_list,g_strdup(get_if_name(prefs.capture_device)));
+ g_free(s);
+ return if_info;
+}
+
+/*
+ * Load the configuration for the specified interface
+ */
+void
+airpcap_load_selected_if_configuration(airpcap_if_info_t* if_info)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+
+if(if_info != NULL)
+ {
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, if_info->description), ebuf);
+
+ if(ad)
+ {
+ /* Stop blinking (if it was blinkig!)*/
+ if(if_info->blinking)
+ {
+ /* Turn on the light (if it was off) */
+ if(!(if_info->led)) airpcap_if_turn_led_on(ad, 0);
+ }
+
+ /* Apply settings... */
+ airpcap_if_get_device_channel(ad,&(if_info->channel));
+ airpcap_if_get_fcs_validation(ad,&(if_info->CrcValidationOn));
+ airpcap_if_get_fcs_presence(ad,&(if_info->IsFcsPresent));
+ airpcap_if_get_link_type(ad,&(if_info->linkType));
+ airpcap_if_get_decryption_state(ad, &(if_info->DecryptionOn));
+ /* get the keys, if everything is ok, close the adapter */
+ if(airpcap_if_load_keys(ad,if_info))
+ airpcap_if_close(ad);
+
+ if_info->saved = TRUE;
+ }
+ else
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, " Error in opening adapter for %s",if_info->description);
+ }
+ }
+}
+
+/*
+ * Save the configuration for the specified interface
+ */
+void
+airpcap_save_selected_if_configuration(airpcap_if_info_t* if_info)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+
+if(if_info != NULL)
+ {
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, if_info->description), ebuf);
+
+ if(ad)
+ {
+ /* Stop blinking (if it was blinkig!)*/
+ if(if_info->blinking)
+ {
+ /* Turn on the light (if it was off) */
+ if(!(if_info->led)) airpcap_if_turn_led_on(ad, 0);
+ }
+
+ /* Apply settings... */
+ airpcap_if_set_device_channel(ad,if_info->channel);
+ airpcap_if_set_fcs_validation(ad,if_info->CrcValidationOn);
+ airpcap_if_set_fcs_presence(ad,if_info->IsFcsPresent);
+ airpcap_if_set_link_type(ad,if_info->linkType);
+ airpcap_if_set_decryption_state(ad, if_info->DecryptionOn);
+ airpcap_if_save_keys(ad,if_info);
+
+ /* ... and save them */
+ if(!airpcap_if_store_cur_config_as_adapter_default(ad))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save Wireless configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
+ if_info->saved = FALSE;
+ airpcap_if_close(ad);
+ return;
+ }
+
+ if_info->saved = TRUE;
+ airpcap_if_close(ad);
+ }
+ else
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, " Error in opening adapter for %s",if_info->description);
+ }
+ }
+}
+
+/*
+ * Used to dinamically load the airpcap library in order link it only when
+ * it's present on the system
+ */
+BOOL load_airpcap(void)
+{
+ if((AirpcapLib = LoadLibrary(TEXT("airpcap.dll"))) == NULL)
+ {
+ /* Report the error but go on */
+ return FALSE;
+ }
+ else
+ {
+ if((g_PAirpcapGetLastError = (AirpcapGetLastErrorHandler) GetProcAddress(AirpcapLib, "AirpcapGetLastError")) == NULL) return FALSE;
+ if((g_PAirpcapGetDeviceList = (AirpcapGetDeviceListHandler) GetProcAddress(AirpcapLib, "AirpcapGetDeviceList")) == NULL) return FALSE;
+ if((g_PAirpcapFreeDeviceList = (AirpcapFreeDeviceListHandler) GetProcAddress(AirpcapLib, "AirpcapFreeDeviceList")) == NULL) return FALSE;
+ if((g_PAirpcapOpen = (AirpcapOpenHandler) GetProcAddress(AirpcapLib, "AirpcapOpen")) == NULL) return FALSE;
+ if((g_PAirpcapClose = (AirpcapCloseHandler) GetProcAddress(AirpcapLib, "AirpcapClose")) == NULL) return FALSE;
+ if((g_PAirpcapGetLinkType = (AirpcapGetLinkTypeHandler) GetProcAddress(AirpcapLib, "AirpcapGetLinkType")) == NULL) return FALSE;
+ if((g_PAirpcapSetLinkType = (AirpcapSetLinkTypeHandler) GetProcAddress(AirpcapLib, "AirpcapSetLinkType")) == NULL) return FALSE;
+ if((g_PAirpcapSetKernelBuffer = (AirpcapSetKernelBufferHandler) GetProcAddress(AirpcapLib, "AirpcapSetKernelBuffer")) == NULL) return FALSE;
+ if((g_PAirpcapSetFilter = (AirpcapSetFilterHandler) GetProcAddress(AirpcapLib, "AirpcapSetFilter")) == NULL) return FALSE;
+ if((g_PAirpcapGetMacAddress = (AirpcapGetMacAddressHandler) GetProcAddress(AirpcapLib, "AirpcapGetMacAddress")) == NULL) return FALSE;
+ if((g_PAirpcapSetMinToCopy = (AirpcapSetMinToCopyHandler) GetProcAddress(AirpcapLib, "AirpcapSetMinToCopy")) == NULL) return FALSE;
+ if((g_PAirpcapGetReadEvent = (AirpcapGetReadEventHandler) GetProcAddress(AirpcapLib, "AirpcapGetReadEvent")) == NULL) return FALSE;
+ if((g_PAirpcapRead = (AirpcapReadHandler) GetProcAddress(AirpcapLib, "AirpcapRead")) == NULL) return FALSE;
+ if((g_PAirpcapGetStats = (AirpcapGetStatsHandler) GetProcAddress(AirpcapLib, "AirpcapGetStats")) == NULL) return FALSE;
+ if((g_PAirpcapTurnLedOn = (AirpcapTurnLedOnHandler) GetProcAddress(AirpcapLib, "AirpcapTurnLedOn")) == NULL) return FALSE;
+ if((g_PAirpcapTurnLedOff = (AirpcapTurnLedOffHandler) GetProcAddress(AirpcapLib, "AirpcapTurnLedOff")) == NULL) return FALSE;
+ if((g_PAirpcapGetDeviceChannel = (AirpcapGetDeviceChannelHandler) GetProcAddress(AirpcapLib, "AirpcapGetDeviceChannel")) == NULL) return FALSE;
+ if((g_PAirpcapSetDeviceChannel = (AirpcapSetDeviceChannelHandler) GetProcAddress(AirpcapLib, "AirpcapSetDeviceChannel")) == NULL) return FALSE;
+ if((g_PAirpcapGetFcsPresence = (AirpcapGetFcsPresenceHandler) GetProcAddress(AirpcapLib, "AirpcapGetFcsPresence")) == NULL) return FALSE;
+ if((g_PAirpcapSetFcsPresence = (AirpcapSetFcsPresenceHandler) GetProcAddress(AirpcapLib, "AirpcapSetFcsPresence")) == NULL) return FALSE;
+ if((g_PAirpcapGetFcsValidation = (AirpcapGetFcsValidationHandler) GetProcAddress(AirpcapLib, "AirpcapGetFcsValidation")) == NULL) return FALSE;
+ if((g_PAirpcapSetFcsValidation = (AirpcapSetFcsValidationHandler) GetProcAddress(AirpcapLib, "AirpcapSetFcsValidation")) == NULL) return FALSE;
+ if((g_PAirpcapGetDeviceKeys = (AirpcapGetDeviceKeysHandler) GetProcAddress(AirpcapLib, "AirpcapGetDeviceKeys")) == NULL) return FALSE;
+ if((g_PAirpcapSetDeviceKeys = (AirpcapSetDeviceKeysHandler) GetProcAddress(AirpcapLib, "AirpcapSetDeviceKeys")) == NULL) return FALSE;
+ if((g_PAirpcapGetDecryptionState = (AirpcapGetDecryptionStateHandler) GetProcAddress(AirpcapLib, "AirpcapGetDecryptionState")) == NULL) return FALSE;
+ if((g_PAirpcapSetDecryptionState = (AirpcapSetDecryptionStateHandler) GetProcAddress(AirpcapLib, "AirpcapSetDecryptionState")) == NULL) return FALSE;
+ if((g_PAirpcapStoreCurConfigAsAdapterDefault = (AirpcapStoreCurConfigAsAdapterDefaultHandler) GetProcAddress(AirpcapLib, "AirpcapStoreCurConfigAsAdapterDefault")) == NULL) return FALSE;
+ return TRUE;
+ }
+}
+
+#endif /* _WIN32 */
diff --git a/airpcap_loader.h b/airpcap_loader.h
new file mode 100644
index 0000000000..0c5feec5fa
--- /dev/null
+++ b/airpcap_loader.h
@@ -0,0 +1,296 @@
+/* airpcap_loader.h
+ * Declarations of routines for the "About" dialog
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __AIRPCAP_LOADER_H__
+#define __AIRPCAP_LOADER_H__
+
+/* Error values from "get_airpcap_interface_list()". */
+#define CANT_GET_AIRPCAP_INTERFACE_LIST 0 /* error getting list */
+#define NO_AIRPCAP_INTERFACES_FOUND 1 /* list is empty */
+
+#define MAX_ENCRYPTION_KEYS 64
+
+typedef PCHAR (*AirpcapGetLastErrorHandler)(PAirpcapHandle AdapterHandle);
+typedef BOOL (*AirpcapGetDeviceListHandler)(PAirpcapDeviceDescription *PPAllDevs, PCHAR Ebuf);
+typedef VOID (*AirpcapFreeDeviceListHandler)(PAirpcapDeviceDescription PAllDevs);
+typedef PAirpcapHandle (*AirpcapOpenHandler)(PCHAR DeviceName, PCHAR Ebuf);
+typedef VOID (*AirpcapCloseHandler)(PAirpcapHandle AdapterHandle);
+typedef BOOL (*AirpcapGetLinkTypeHandler)(PAirpcapHandle AdapterHandle, PAirpcapLinkType PLinkType);
+typedef BOOL (*AirpcapSetLinkTypeHandler)(PAirpcapHandle AdapterHandle, AirpcapLinkType NewLinkType);
+typedef BOOL (*AirpcapSetKernelBufferHandler)(PAirpcapHandle AdapterHandle, UINT BufferSize);
+typedef BOOL (*AirpcapSetFilterHandler)(PAirpcapHandle AdapterHandle, PVOID Instructions, UINT Len);
+typedef BOOL (*AirpcapGetMacAddressHandler)(PAirpcapHandle AdapterHandle, PAirpcapMacAddress PMacAddress);
+typedef BOOL (*AirpcapSetMinToCopyHandler)(PAirpcapHandle AdapterHandle, UINT MinToCopy);
+typedef BOOL (*AirpcapGetReadEventHandler)(PAirpcapHandle AdapterHandle, HANDLE* PReadEvent);
+typedef BOOL (*AirpcapReadHandler)(PAirpcapHandle AdapterHandle, PBYTE Buffer, UINT BufSize, PUINT PReceievedBytes);
+typedef BOOL (*AirpcapGetStatsHandler)(PAirpcapHandle AdapterHandle, PAirpcapStats PStats);
+typedef BOOL (*AirpcapTurnLedOnHandler)(PAirpcapHandle AdapterHandle, UINT LedNumber);
+typedef BOOL (*AirpcapTurnLedOffHandler)(PAirpcapHandle AdapterHandle, UINT LedNumber);
+typedef BOOL (*AirpcapSetDeviceChannelHandler)(PAirpcapHandle AdapterHandle, UINT Channel);
+typedef BOOL (*AirpcapGetDeviceChannelHandler)(PAirpcapHandle AdapterHandle, PUINT PChannel);
+typedef BOOL (*AirpcapSetFcsPresenceHandler)(PAirpcapHandle AdapterHandle, BOOL IsFcsPresent);
+typedef BOOL (*AirpcapGetFcsPresenceHandler)(PAirpcapHandle AdapterHandle, PBOOL PIsFcsPresent);
+typedef BOOL (*AirpcapSetFcsValidationHandler)(PAirpcapHandle AdapterHandle, AirpcapValidationType ValidationType);
+typedef BOOL (*AirpcapGetFcsValidationHandler)(PAirpcapHandle AdapterHandle, PAirpcapValidationType PValidationType);
+typedef BOOL (*AirpcapSetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
+typedef BOOL (*AirpcapGetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize);
+typedef BOOL (*AirpcapSetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable);
+typedef BOOL (*AirpcapGetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable);
+typedef BOOL (*AirpcapStoreCurConfigAsAdapterDefaultHandler)(PAirpcapHandle AdapterHandle);
+/*
+ * The list of interfaces returned by "get_airpcap_interface_list()" is
+ * a list of these structures.
+ */
+typedef struct {
+ char *name; /* e.g. "eth0" */
+ char *description; /* from OS, e.g. "Local Area Connection" or NULL */
+ GSList *ip_addr; /* containing address values of if_addr_t */
+ gboolean loopback; /* TRUE if loopback, FALSE otherwise */
+ AirpcapLinkType linkType; /* The link layer type*/
+ UINT channel; /* Channel (1-14)*/
+ BOOL IsFcsPresent; /* Include 802.11 CRC in frames */
+ AirpcapValidationType CrcValidationOn; /* Capture Frames with Wrong CRC */
+ AirpcapDecryptionState DecryptionOn; /* TRUE if decryption is on, FALSE otherwise*/
+ PAirpcapKeysCollection keysCollection; /* WEP Key collection for the adapter */
+ UINT keysCollectionSize; /* Size of the key collection */
+ gboolean blinking; /* TRUE if is blinkng, FALSE otherwise*/
+ gboolean led; /* TRUE if on, FALSE if off*/
+ gboolean saved; /* TRUE if current configuration has been saved, FALSE otherwise */
+ gint tag; /* int for the gtk blinking callback */
+} airpcap_if_info_t;
+
+/* Airpcap interface list */
+extern GList *airpcap_if_list;
+
+/* Airpcap current selected interface */
+extern airpcap_if_info_t *airpcap_if_selected;
+
+/* Airpcap current active interface */
+extern airpcap_if_info_t *airpcap_if_active;
+
+/*
+ * Callback used to free an instance of airpcap_if_info_t
+ */
+static void
+free_airpcap_if_cb(gpointer data, gpointer user_data _U_);
+
+/*
+ * Used to retrieve the two chars string from interface
+ */
+gchar*
+airpcap_get_if_string_number_from_description(gchar* description);
+
+/*
+ * Function used to free the airpcap interface list
+ */
+void
+free_airpcap_interface_list(GList *if_list);
+
+/*
+ * Used to retrieve the interface given the name
+ * (the name is used in AirpcapOpen)
+ */
+airpcap_if_info_t* get_airpcap_if_by_name(GList* if_list, const gchar* name);
+
+/*
+ * Airpcap wrapper, used to store the current settings for the selected adapter
+ */
+BOOL
+airpcap_if_store_cur_config_as_adapter_default(PAirpcapHandle ah);
+
+/*
+ * Function used to load the WEP keys for a selected interface
+ */
+BOOL
+airpcap_if_load_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
+
+/*
+ * Function used to save the WEP keys for a selected interface
+ */
+void
+airpcap_if_save_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
+
+/*
+ * Airpcap wrapper, used to get the fcs validation of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val);
+
+/*
+ * Airpcap wrapper, used to set the fcs validation of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_fcs_validation(PAirpcapHandle ah, AirpcapValidationType val);
+
+/*
+ * Airpcap wrapper, used to get the decryption enabling of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState val);
+
+/*
+ * Airpcap wrapper, used to set the decryption enabling of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState val);
+
+/*
+ * Airpcap wrapper, used to get the fcs presence of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_fcs_presence(PAirpcapHandle ah, PBOOL ch);
+
+/*
+ * Airpcap wrapper, used to set the fcs presence of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_fcs_presence(PAirpcapHandle ah, BOOL ch);
+
+/*
+ * Airpcap wrapper, used to get the link type of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_link_type(PAirpcapHandle ah, PAirpcapLinkType lt);
+
+/*
+ * Airpcap wrapper, used to set the link type of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_link_type(PAirpcapHandle ah, AirpcapLinkType lt);
+
+/*
+ * Airpcap wrapper, used to get the channel of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_device_channel(PAirpcapHandle ah, PUINT ch);
+
+/*
+ * Airpcap wrapper, used to set the channel of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_device_channel(PAirpcapHandle ah, UINT ch);
+
+/*
+ * Airpcap wrapper, used to open an airpcap adapter
+ */
+PAirpcapHandle airpcap_if_open(PCHAR name, PCHAR err);
+
+/*
+ * Airpcap wrapper, used to close an airpcap adapter
+ */
+VOID airpcap_if_close(PAirpcapHandle handle);
+
+/*
+ * Airpcap wrapper, used to turn on the led of an airpcap adapter
+ */
+BOOL airpcap_if_turn_led_on(PAirpcapHandle AdapterHandle, UINT LedNumber);
+
+/*
+ * Airpcap wrapper, used to turn off the led of an airpcap adapter
+ */
+BOOL airpcap_if_turn_led_off(PAirpcapHandle AdapterHandle, UINT LedNumber);
+
+/*
+ * This function will create a new airpcap_if_info_t using a name and a description
+ */
+airpcap_if_info_t* airpcap_if_info_new(char *name, char *description);
+
+/* HAVE_AIRPCAP_API */
+
+/*
+ * Used to dinamically load the airpcap library in order link it only when
+ * it's present on the system.
+ */
+BOOL load_airpcap(void);
+
+/*
+ * Get an error message string for a CANT_GET_INTERFACE_LIST error from
+ * "get_airpcap_interface_list()".
+ */
+gchar*
+cant_get_airpcap_if_list_error_message(const char *err_str);
+
+/*
+ * This function will use the airpcap.dll to find all the airpcap devices.
+ * Will return null if no device is found.
+ */
+GList*
+get_airpcap_interface_list(int *err, char *err_str);
+
+/*
+ * Returns the ASCII string of a key given the key bites
+ */
+gchar*
+airpcap_get_key_string(AirpcapKey key);
+
+/*
+ * Load the configuration for the specified interface
+ */
+void
+airpcap_load_selected_if_configuration(airpcap_if_info_t* if_info);
+
+/*
+ * Save the configuration for the specified interface
+ */
+void
+airpcap_save_selected_if_configuration(airpcap_if_info_t* if_info);
+
+/*
+ * Used to retrieve the name of the interface given the description
+ * (the name is used in AirpcapOpen, the description is put in the combo box)
+ */
+gchar*
+get_airpcap_name_from_description(GList* if_list, gchar* description);
+
+/*
+ * Used to retrieve the airpcap_if_info_t of the selected interface given the
+ * description (that is the entry of the combo box).
+ */
+gpointer
+get_airpcap_if_from_description(GList* if_list, const gchar* description);
+
+/*
+ * Used to retrieve the two chars string from interface description
+ */
+gchar*
+airpcap_get_if_string_number(airpcap_if_info_t* if_info);
+
+/*
+ * Returns the default airpcap interface of a list, NULL if list is empty
+ */
+airpcap_if_info_t*
+airpcap_get_default_if(GList* airpcap_if_list);
+
+/*
+ * Airpcap wrapper, used to save the settings for the selected_if
+ */
+BOOL
+airpcap_if_set_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
+
+/*
+ * Airpcap wrapper, used to save the settings for the selected_if
+ */
+BOOL
+airpcap_if_get_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize);
+#endif
diff --git a/config.h.win32 b/config.h.win32
index f4f2e8a0d7..89af736e0e 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -61,6 +61,8 @@
@WPCAP_CONSTIFIED@
@HAVE_LIBWIRESHARKDLL@
+@HAVE_AIRPCAP@
+
/* availability of pcap_freecode() is handled at runtime */
#define HAVE_PCAP_FREECODE 1
diff --git a/config.nmake b/config.nmake
index 1945a6852a..920384601d 100644
--- a/config.nmake
+++ b/config.nmake
@@ -36,7 +36,7 @@ RC_WTAP_VERSION=0,3
# If you're not building with WinPcap at all, don't set it (comment
# out or remove the line that sets it).
#
-WINPCAP_VERSION=3.1
+WINPCAP_VERSION=4.0
#
# Directory, where your User's Guide reside, relative to the source dir.
@@ -202,7 +202,7 @@ LOCAL_LDFLAGS=/DEBUG
PDB_FILE=vc*.pdb
# Set up the path to the cygwin binaries
-CYGWIN_PATH=c:\cygwin\bin
+CYGWIN_PATH=c:\Programmi\cygwin\bin
# Set up the path to some required DLLs
DLL_PATH=$(GLIB_DIR)\bin;$(GETTEXT_DIR)\bin;$(ICONV_DIR)\bin
@@ -222,9 +222,9 @@ POD2MAN=$(SH) pod2man
POD2HTML=$(SH) pod2html
# command for python (native windows version)
-#PYTHON="C:/python23/python.exe"
+PYTHON="C:/Programmi/python24/python.exe"
# add native python to the path (not needed if cygwin's python is used)
-#PATH=c:\python23;$(PATH)
+PATH=c:\Programmi\python24;$(PATH)
# command for python (typically cygwin's python package)
PYTHON=env python
@@ -352,6 +352,10 @@ PANGO_LIB_DIR=1.4.0
PANGO_LIB_DIR=1.2.0
!ENDIF
+# Enable / disable AirPcap support
+
+# AIRPCAP_CONFIG=^#define HAVE_AIRPCAP 1
+AIRPCAP_CONFIG=
!IFDEF WINPCAP_VERSION
# Nmake uses carets to escape special characters
diff --git a/epan/dissectors/packet-radiotap.c b/epan/dissectors/packet-radiotap.c
index 5b32bf87a9..48a8c52236 100644
--- a/epan/dissectors/packet-radiotap.c
+++ b/epan/dissectors/packet-radiotap.c
@@ -73,6 +73,7 @@ enum ieee80211_radiotap_type {
IEEE80211_RADIOTAP_ANTENNA = 11,
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
+ IEEE80211_RADIOTAP_FCS = 14,
IEEE80211_RADIOTAP_EXT = 31
};
@@ -144,8 +145,10 @@ static int hf_radiotap_dbm_antnoise = -1;
static int hf_radiotap_db_antnoise = -1;
static int hf_radiotap_txpower = -1;
static int hf_radiotap_preamble = -1;
-static int hf_radiotap_fcs = -1;
+static int hf_radiotap_flags_fcs = -1;
static int hf_radiotap_datapad = -1;
+static int hf_radiotap_quality = -1;
+static int hf_radiotap_fcs = -1;
static gint ett_radiotap = -1;
static gint ett_radiotap_present = -1;
@@ -285,7 +288,7 @@ proto_register_radiotap(void)
FT_UINT32, BASE_DEC, VALS(preamble_type), 0x0, "", HFILL } },
/* XXX for debugging */
- { &hf_radiotap_fcs,
+ { &hf_radiotap_flags_fcs,
{ "FCS", "radiotap.flags.fcs",
FT_UINT32, BASE_DEC, VALS(truefalse_type), 0x0, "", HFILL } },
{ &hf_radiotap_datapad,
@@ -295,6 +298,12 @@ proto_register_radiotap(void)
{ &hf_radiotap_mactime,
{ "MAC timestamp", "radiotap.mactime",
FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } },
+ { &hf_radiotap_quality,
+ { "Signal Quality", "radiotap.quality",
+ FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } },
+ { &hf_radiotap_fcs,
+ { "802.11 FCS", "radiotap.fcs",
+ FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL } },
{ &hf_radiotap_channel_frequency,
{ "Channel frequency", "radiotap.channel.freq",
FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } },
@@ -388,6 +397,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint8 db, rflags;
guint32 present, next_present;
int bit;
+ gboolean has_fcs = FALSE;
if(check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "WLAN");
@@ -455,7 +465,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (tree) {
proto_tree_add_uint(radiotap_tree, hf_radiotap_preamble,
tvb, 0, 0, (rflags&IEEE80211_RADIOTAP_F_SHORTPRE) != 0);
- proto_tree_add_uint(radiotap_tree, hf_radiotap_fcs,
+ proto_tree_add_uint(radiotap_tree, hf_radiotap_flags_fcs,
tvb, 0, 0, (rflags&IEEE80211_RADIOTAP_F_FCS) != 0);
proto_tree_add_uint(radiotap_tree, hf_radiotap_datapad,
tvb, 0, 0, (rflags&IEEE80211_RADIOTAP_F_DATAPAD) != 0);
@@ -574,7 +584,6 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
length_remaining-=4;
break;
case IEEE80211_RADIOTAP_FHSS:
- case IEEE80211_RADIOTAP_LOCK_QUALITY:
case IEEE80211_RADIOTAP_TX_ATTENUATION:
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
if (length_remaining < 2)
@@ -595,6 +604,28 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset+=8;
length_remaining-=8;
break;
+ case IEEE80211_RADIOTAP_LOCK_QUALITY:
+ if (length_remaining < 2)
+ break;
+ if (tree) {
+ proto_tree_add_uint(radiotap_tree, hf_radiotap_quality,
+ tvb, offset, 2, tvb_get_letohs(tvb, offset));
+ }
+ offset+=2;
+ length_remaining-=2;
+ break;
+ case IEEE80211_RADIOTAP_FCS:
+ /*
+ * We don't show the FCS because, since it's already at the end of the frame,
+ * it would be redundant.
+ * However, we tell the 802.11 dissector that the packet does have fcs.
+ */
+ if (length_remaining < 2)
+ break;
+ has_fcs = TRUE;
+ offset+=2;
+ length_remaining-=2;
+ break;
default:
/*
* This indicates a field whose size we do not
@@ -605,8 +636,12 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
- if (rflags & IEEE80211_RADIOTAP_F_FCS)
+ /* does the frame contain the FCS? */
+ if ((has_fcs == TRUE) || (rflags & IEEE80211_RADIOTAP_F_FCS))
pinfo->pseudo_header->ieee_802_11.fcs_len = 4;
+ else
+ pinfo->pseudo_header->ieee_802_11.fcs_len = 0;
+
/* dissect the 802.11 header next */
call_dissector((rflags & IEEE80211_RADIOTAP_F_DATAPAD) ?
ieee80211_datapad_handle : ieee80211_handle,
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 61143660ed..7e46784e19 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -39,6 +39,8 @@ wireshark-tap-register.c: $(WIRESHARK_TAP_SRC) $(top_srcdir)/make-tapreg-dotc
noinst_HEADERS = \
about_dlg.h \
+ airpcap_dlg.h \
+ airpcap_gui_utils.h \
capture_dlg.h \
capture_file_dlg.h \
capture_if_details_dlg.h \
@@ -124,6 +126,8 @@ endif
libui_a_DEPENDENCIES =
EXTRA_DIST = \
+ airpcap_dlg.c \
+ airpcap_gui_utils.c \
capture_if_details_dlg.c \
doxygen.cfg.in \
ethclist.c \
diff --git a/gtk/Makefile.common b/gtk/Makefile.common
index b1e7fbe24a..89477b0d50 100644
--- a/gtk/Makefile.common
+++ b/gtk/Makefile.common
@@ -40,6 +40,8 @@ GENERATED_FILES = $(GENERATED_HEADER_FILES) $(GENERATED_C_FILES)
#
WIRESHARK_GTK_SRC = \
about_dlg.c \
+ airpcap_dlg.c \
+ airpcap_gui_utils.c \
capture_dlg.c \
capture_file_dlg.c \
capture_if_dlg.c \
diff --git a/gtk/airpcap_dlg.c b/gtk/airpcap_dlg.c
new file mode 100644
index 0000000000..e177956870
--- /dev/null
+++ b/gtk/airpcap_dlg.c
@@ -0,0 +1,1872 @@
+/* airpcap_dlg.c
+ *
+ * $Id$
+ *
+ * Ulf Lamping <ulf.lamping@web.de>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2000 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_AIRPCAP
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <string.h>
+
+#include <epan/filesystem.h>
+
+#include "gtk/main.h"
+#include "dlg_utils.h"
+#include "gui_utils.h"
+#include "simple_dialog.h"
+#include "dfilter_expr_dlg.h"
+#include "compat_macros.h"
+#include "gtkglobals.h"
+#include "help_dlg.h"
+
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+
+#include "keys.h"
+
+/* temporary block signals to widgets */
+BOOL block_advanced_signals;
+
+/*
+ * This struct will contain useful data for the selected (actual) airpcap device
+ */
+void
+airpcap_fill_if_combo(GtkWidget *combo, GList* if_list)
+{
+int ifn = 0;
+GList* popdown_if_list = NULL;
+GList* curr = NULL;
+airpcap_if_info_t* if_info = NULL;
+
+ curr = g_list_nth(if_list, ifn);
+ if_info = NULL;
+ if(curr != NULL) if_info = curr->data;
+
+ popdown_if_list = NULL;
+ ifn = g_list_length(if_list) - 1;
+ while(ifn >= 0) /* reverse order */
+ {
+ curr = g_list_nth(if_list, ifn);
+ if_info = NULL;
+ if(curr != NULL)
+ if_info = curr->data;
+ if(if_info != NULL)
+ popdown_if_list = g_list_append( popdown_if_list , if_info->description) ;
+ ifn--;
+ }
+ gtk_combo_set_popdown_strings( GTK_COMBO(combo), popdown_if_list) ;
+
+ if(airpcap_if_selected != NULL)
+ {
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), airpcap_if_selected->description);
+ }
+ else
+ {
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), "No Wireless Interfaces Found");
+ }
+}
+
+/*
+ * Callback for the crc chackbox
+ */
+static void
+crc_check_cb(GtkWidget *w, gpointer user_data)
+{
+if( !block_advanced_signals && (airpcap_if_selected != NULL))
+ {
+ if(airpcap_if_selected->IsFcsPresent)
+ {
+ airpcap_if_selected->IsFcsPresent = FALSE;
+ airpcap_if_selected->saved = FALSE;
+ }
+ else
+ {
+ airpcap_if_selected->IsFcsPresent = TRUE;
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+/*
+ * Callback for the wrong crc combo
+ */
+static void
+wrong_crc_combo_cb(GtkWidget *w, gpointer data)
+{
+const gchar *s;
+
+s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if( !block_advanced_signals && (data != NULL) && (w != NULL) )
+ {
+ if((g_strcasecmp("",s)))
+ {
+ airpcap_if_selected->CrcValidationOn = airpcap_get_validation_type(s);
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+/*
+ * Changed callback for the channel combobox
+ */
+static void
+channel_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+const gchar *s;
+
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if( !block_advanced_signals && (data != NULL) && (w != NULL) )
+ {
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+ if((g_strcasecmp("",s)))
+ {
+ if(airpcap_if_selected != NULL)
+ {
+ airpcap_if_selected->channel = airpcap_get_channel_number(s);
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+ }
+}
+
+/*
+ * Changed callback for the link layer combobox
+ */
+static void
+link_type_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+const gchar *s;
+
+s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if( !block_advanced_signals && (data != NULL) && (w != NULL) )
+ {
+ if((g_strcasecmp("",s)))
+ {
+ airpcap_if_selected->linkType = airpcap_get_link_type(s);
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+/*
+ * Activate callback for the adapter combobox
+ */
+static void
+combo_if_activate_cb(GtkWidget *entry _U_, gpointer data)
+{
+}
+
+/*
+ * Changed callback for the adapter combobox
+ */
+static void
+airpcap_advanced_combo_if_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+const gchar* s = NULL;
+
+s = gtk_entry_get_text(GTK_ENTRY(w));
+
+if((g_strcasecmp("",s)))
+ {
+ /* We are trying to change the interface to set up...*/
+ /* Check if the current interface settings need to be SAVED! */
+ if( (airpcap_if_selected != NULL) && !block_advanced_signals)
+ {
+ if( (airpcap_if_selected->saved) ) /* Just change interface */
+ {
+ /* No changes for this interface, no need to save anything */
+ airpcap_change_if(w,data);
+ }
+ else
+ {
+ /* Popup a dialog to ask if user wants to save settings for selected
+ * interface before changing it...
+ */
+ airpcap_ask_for_save(w,data);
+ }
+ }
+ }
+}
+
+/*
+ * Takes the keys from the GtkList widget, and add them to the interface list
+ */
+void
+airpcap_add_keys_from_list(GtkWidget *keylist, airpcap_if_info_t *if_info)
+{
+GtkWidget *key_ls;
+
+GString *new_key;
+
+gchar *text_entered = NULL;
+
+GtkWidget *nl_item,*nl_lb;
+
+GList *list,
+ *children;
+
+/* airpcap stuff */
+UINT i, j;
+gchar s[3];
+PAirpcapKeysCollection KeysCollection;
+ULONG KeysCollectionSize;
+UCHAR KeyByte;
+
+UINT keys_in_list = 0;
+
+key_ls = keylist;
+
+keys_in_list = (UINT)g_list_length(GTK_LIST(key_ls)->children);
+
+if(keys_in_list > 0)
+{
+ /*
+ * Save the encryption keys, if we have any of them
+ */
+ KeysCollectionSize = 0;
+
+ /*
+ * Calculate the size of the keys collection
+ */
+ KeysCollectionSize = sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey);
+
+ /*
+ * Allocate the collection
+ * We use malloc so it's easier to reuse the code in C programs
+ */
+ KeysCollection = (PAirpcapKeysCollection)malloc(KeysCollectionSize);
+ if(!KeysCollection)
+ {
+ /* Simple dialog ERROR */
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","Failed mamory allocation for KeysCollection!");
+ return;
+ }
+
+ /*
+ * Populate the key collection
+ */
+ list = GTK_LIST(key_ls)->children;
+ KeysCollection->nKeys = keys_in_list;
+
+ for(i = 0; i < keys_in_list; i++)
+ {
+ KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_WEP;
+
+ /* Retrieve the Item corresponding to the i-th key */
+ nl_item = g_list_nth_data(list, i);
+ children = gtk_container_children(GTK_CONTAINER(nl_item));
+ nl_lb = g_list_nth_data(children,0);
+ new_key = g_string_new(GTK_LABEL(nl_lb)->label);
+
+ KeysCollection->Keys[i].KeyLen = new_key->len / 2;
+ memset(&KeysCollection->Keys[i].KeyData, 0, sizeof(KeysCollection->Keys[i].KeyData));
+
+ for(j = 0 ; j < new_key->len; j += 2)
+ {
+ s[0] = new_key->str[j];
+ s[1] = new_key->str[j+1];
+ s[2] = '\0';
+ KeyByte = (UCHAR)strtol(s, NULL, 16);
+ KeysCollection->Keys[i].KeyData[j / 2] = KeyByte;
+ }
+ }
+
+ /*
+ * XXX - Free the old adapter key collection!
+ */
+ if(airpcap_if_selected->keysCollection != NULL)
+ g_free(airpcap_if_selected->keysCollection);
+
+ /*
+ * Set this collection ad the new one
+ */
+ airpcap_if_selected->keysCollection = KeysCollection;
+ airpcap_if_selected->keysCollectionSize = KeysCollectionSize;
+}
+}
+
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ * when closing the window.
+ */
+void
+airpcap_ask_for_save_before_closing(GtkWidget *w _U_, gpointer data)
+{
+ GtkWidget* dialog;
+
+ dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
+ PRIMARY_TEXT_START "Save settings before closing?" PRIMARY_TEXT_END "\n\n"
+ "If you close the window without saving, changes you made will\nbe discarded.");
+ simple_dialog_set_cb(dialog, airpcap_dialog_save_before_closing_cb, data);
+}
+
+/* user confirmed the "Save settings..." dialog */
+void
+airpcap_dialog_save_before_closing_cb(gpointer dialog _U_, gint btn, gpointer data)
+{
+GtkWidget* interface_combo;
+GtkWidget* key_ls;
+
+/* I need the combo box entry */
+interface_combo = GTK_WIDGET(OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_INTERFACE_KEY));
+key_ls = GTK_WIDGET(OBJECT_GET_DATA(data,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ switch(btn) {
+ case(ESD_BTN_SAVE):
+ /* save interface and exit */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ break;
+ case(ESD_BTN_DONT_SAVE):
+ /* exit without saving */
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ * when changing the interface in the advanced dialog box
+ */
+void
+airpcap_ask_for_save(GtkWidget *entry _U_, gpointer data)
+{
+ GtkWidget* dialog;
+
+ dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
+ PRIMARY_TEXT_START "Save settings before changing interface?" PRIMARY_TEXT_END "\n\n"
+ "If you change interface without saving, changes you made will\nbe discarded.");
+ simple_dialog_set_cb(dialog, airpcap_dialog_save_cb, data);
+
+}
+
+/* user confirmed the "Save settings..." dialog */
+void
+airpcap_dialog_save_cb(GtkWidget* dialog _U_, gint btn, gpointer data)
+{
+GtkWidget* interface_combo;
+GtkWidget* key_ls;
+
+/* I need the combo box entry */
+interface_combo = GTK_WIDGET(OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_INTERFACE_KEY));
+key_ls = GTK_WIDGET(OBJECT_GET_DATA(data,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ switch(btn) {
+ case(ESD_BTN_SAVE):
+ /* save interface and change */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_change_if(GTK_COMBO(interface_combo)->entry,data);
+ break;
+ case(ESD_BTN_DONT_SAVE):
+ /* change interface without saving */
+ airpcap_change_if(GTK_COMBO(interface_combo)->entry,data);
+ break;
+ case(ESD_BTN_CANCEL):
+ /* don't change interface and don't save */
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * Function used to change the selected interface and advanced dialog box
+ */
+void
+airpcap_change_if(GtkWidget *entry _U_, gpointer data)
+{
+ const gchar *s;
+ gchar *channel_s;
+ gchar *capture_s;
+ GtkWidget *main_w;
+
+ GtkWidget *interface_combo;
+ GtkWidget *channel_combo;
+ GtkWidget *capture_combo;
+ GtkWidget *crc_check;
+ GtkWidget *wrong_crc_combo;
+ GtkWidget *blink_bt;
+ GtkWidget *key_ls;
+
+ airpcap_if_info_t *new_if;
+
+ /* Retrieve the GUI object pointers */
+ main_w = GTK_WIDGET(data);
+ interface_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_INTERFACE_KEY));
+ channel_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CHANNEL_KEY));
+ capture_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_LINK_TYPE_KEY));
+ crc_check = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CRC_KEY));
+ wrong_crc_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_WRONG_CRC_KEY));
+ blink_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_BLINK_KEY));
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ s = gtk_entry_get_text(GTK_ENTRY(entry));
+
+ /* Select actual interface*/
+ new_if = get_airpcap_if_from_description(airpcap_if_list, s);
+
+ /* And change the GUI according to it... */
+ /* This should always happen, but it seems that the callback is
+ * called twice, the first time with an 'empty' text... so it
+ * will return NULL!
+ */
+ if(new_if != NULL)
+ {
+ airpcap_if_selected = new_if;
+
+ new_if = NULL;
+ /* I need to 'block' signals to widgets or they will receive a signal now
+ and will change twice */
+ block_advanced_signals = TRUE;
+
+ /* Blink button */
+ if(airpcap_if_selected->blinking)
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt),"Stop Blinking");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child),"Stop Blinking");
+ #endif
+ }
+ else
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt)," Blink Led ");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child)," Blink Led ");
+ #endif
+ }
+
+ /* Channel combo */
+ channel_s = g_strdup_printf("%d",airpcap_if_selected->channel);
+ if(channel_combo != NULL) /* this event seems to happen when combo is still NULL */
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_combo)->entry), channel_s);
+
+ /* Link Layer combo */
+ capture_s = NULL;
+ if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11)
+ {
+ capture_s = g_strdup_printf(AIRPCAP_LINK_TYPE_NAME_802_11_ONLY);
+ if(capture_combo != NULL) /* this event seems to happen when combo is still NULL */
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(capture_combo)->entry), capture_s);
+ }
+ else if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11_PLUS_RADIO)
+ {
+ capture_s = g_strdup_printf(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
+ if(capture_combo != NULL) /* this event seems to happen when combo is still NULL */
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(capture_combo)->entry), capture_s);
+ }
+
+ /* Fcs Presence check box */
+ if(airpcap_if_selected->IsFcsPresent)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),FALSE);
+
+ /* Wrong Crc combo box */
+ if(airpcap_if_selected->CrcValidationOn == AIRPCAP_VT_ACCEPT_EVERYTHING)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_combo)->entry),AIRPCAP_VALIDATION_TYPE_NAME_ALL);
+ else if(airpcap_if_selected->CrcValidationOn == AIRPCAP_VT_ACCEPT_CORRECT_FRAMES)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_combo)->entry),AIRPCAP_VALIDATION_TYPE_NAME_CORRECT);
+ else if(airpcap_if_selected->CrcValidationOn == AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_combo)->entry),AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT);
+
+ /* Remove old keys */
+ gtk_list_remove_items(GTK_LIST(key_ls),GTK_LIST(key_ls)->children);
+ /* Add new keys */
+ airpcap_fill_key_list(key_ls,airpcap_if_selected);
+
+ /* Enable the signals again */
+ block_advanced_signals = FALSE;
+ }
+}
+
+/*
+ * Thread function used to blink the led
+ */
+void update_blink(gpointer data _U_)
+{
+airpcap_if_info_t* sel;
+PAirpcapHandle ad;
+char* ebuf = NULL;
+
+sel = (airpcap_if_info_t*)data;
+
+ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, sel->description), ebuf);
+if(ad)
+ {
+ if(sel->led)
+ {
+ airpcap_if_turn_led_off(ad, 0);
+ sel->led = FALSE;
+ }
+ else
+ {
+ airpcap_if_turn_led_on(ad, 0);
+ sel->led = TRUE;
+ }
+ airpcap_if_close(ad);
+ }
+}
+
+/*
+ * Blink button callback
+ */
+void
+blink_cb( GtkWidget *blink_bt _U_, gpointer if_data )
+{
+PAirpcapHandle ad = NULL;
+char* ebuf = NULL;
+
+if(airpcap_if_selected != NULL)
+ if(!(airpcap_if_selected->blinking))
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt),"Stop Blinking");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child),"Stop Blinking");
+ #endif
+ airpcap_if_selected->tag = gtk_timeout_add(500, (GtkFunction)update_blink,airpcap_if_selected);
+ airpcap_if_selected->blinking = TRUE;
+ }
+ else
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt)," Blink Led ");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child)," Blink Led ");
+ #endif
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_if_selected->blinking = FALSE;
+ /* Switch on the led! */
+ ad = airpcap_if_open(airpcap_if_selected->name, ebuf);
+ if(ad)
+ {
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_if_turn_led_on(ad, 0);
+ airpcap_if_selected->blinking = FALSE;
+ airpcap_if_selected->led = TRUE;
+ airpcap_if_close(ad);
+ }
+ }
+}
+
+/* the window was closed, cleanup things */
+static void
+airpcap_if_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
+{
+ PAirpcapHandle ad = NULL;
+ char* ebuf = NULL;
+
+ /* Retrieve object data */
+ GtkWidget *main_w;
+ GtkWidget *channel_combo;
+ GtkWidget *capture_combo;
+ GtkWidget *crc_check;
+ GtkWidget *wrong_crc_combo;
+ GtkWidget *blink_bt;
+ GtkWidget *interface_combo;
+ GtkWidget *cancel_bt;
+ GtkWidget *ok_bt;
+ GtkWidget *key_ls;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm,
+ *toolbar_decryption_ck,
+ *advanced_bt;
+
+ gint *from_widget = NULL;
+
+ /* Retrieve the GUI object pointers */
+ main_w = GTK_WIDGET(user_data);
+ interface_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_INTERFACE_KEY));
+ channel_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CHANNEL_KEY));
+ capture_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_LINK_TYPE_KEY));
+ crc_check = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CRC_KEY));
+ wrong_crc_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_WRONG_CRC_KEY));
+ blink_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_BLINK_KEY));
+ cancel_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CANCEL_KEY));
+ ok_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_OK_KEY));
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+ advanced_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEY));
+
+ toolbar = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_TOOLBAR_KEY));
+
+ /* retrieve toolbar info */
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+ toolbar_decryption_ck = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_DECRYPTION_KEY));
+
+ from_widget = (gint*)OBJECT_GET_DATA(toolbar,AIRPCAP_ADVANCED_FROM_KEY);
+
+ /* ... */
+ /* gray out the toolbar (if we came here from the toolbar advanced button)*/
+ if( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
+ gtk_widget_set_sensitive(toolbar,TRUE);
+
+ /* Stop blinking ALL leds (go through the airpcap_if_list) */
+ if(airpcap_if_selected != NULL)
+ {
+ ad = airpcap_if_open(airpcap_if_selected->name, ebuf);
+ if(ad)
+ {
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_if_turn_led_on(ad, 0);
+ airpcap_if_selected->blinking = FALSE;
+ airpcap_if_selected->led = TRUE;
+ airpcap_if_close(ad);
+ }
+ }
+
+ /* See if the 'Cancel' button was pressed or not
+ * if button is pressed, don't save configuration!
+ */
+ if(GTK_BUTTON(cancel_bt)->in_button)
+ {
+ /* reload the configuration!!! Configuration has not been saved but
+ the corresponding structure has been modified probably...*/
+ if(!airpcap_if_selected->saved)
+ {
+ airpcap_load_selected_if_configuration(airpcap_if_selected);
+ }
+
+ /* NULL to everything */
+ main_w = NULL;
+ blink_bt = NULL;
+ channel_combo = NULL;
+ interface_combo = NULL;
+ capture_combo = NULL;
+ crc_check = NULL;
+ wrong_crc_combo = NULL;
+
+ /* ... */
+ /* gray out the toolbar (if we came here from the toolbar advanced button)*/
+ if( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
+ gtk_widget_set_sensitive(toolbar,TRUE);
+
+ g_free(from_widget);
+ return;
+ }
+ else if(GTK_BUTTON(ok_bt)->in_button)
+ {
+
+ /* ??? - Ask if want to save configuration */
+
+ /* Save the configuration */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+
+ /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
+ if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
+ {
+ gtk_label_set_text(GTK_LABEL(toolbar_if_lb), g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_selected)));
+ airpcap_channel_combo_set_by_number(toolbar_channel_cm,airpcap_if_selected->channel);
+ airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
+
+ gtk_signal_handler_block_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ }
+
+ /* If interface active is airpcap, set sensitive TRUE for airpcap toolbar */
+ if( get_airpcap_if_by_name(airpcap_if_list,airpcap_if_active->description) != NULL)
+ {
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+ }
+ else
+ {
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ }
+
+ /* NULL to everything */
+ main_w = NULL;
+ blink_bt = NULL;
+ channel_combo = NULL;
+ interface_combo = NULL;
+ capture_combo = NULL;
+ crc_check = NULL;
+ wrong_crc_combo = NULL;
+
+ /* ... */
+ /* gray out the toolbar (if we came here from the toolbar advanced button)*/
+ if( *from_widget == AIRPCAP_ADVANCED_FROM_OPTIONS)
+ gtk_widget_set_sensitive(toolbar,FALSE);
+
+ g_free(from_widget);
+ return;
+ }
+
+ /* reload the configuration!!! Configuration has not been saved but
+ the corresponding structure has been modified probably...*/
+ if(!airpcap_if_selected->saved)
+ {
+ airpcap_load_selected_if_configuration(airpcap_if_selected);
+ }
+}
+
+/*
+ * Callback for the 'Apply' button.
+ */
+static void
+airpcap_advanced_apply_cb(GtkWidget *button, gpointer data _U_)
+{
+ /* advenced window */
+ GtkWidget *main_w;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm,
+ *toolbar_decryption_ck;
+
+ GtkWidget *key_ls;
+
+ /* retrieve main window */
+ main_w = GTK_WIDGET(data);
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ toolbar = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_TOOLBAR_KEY));
+
+ /* retrieve toolbar info */
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+ toolbar_decryption_ck = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_DECRYPTION_KEY));
+
+ /* Save the configuration */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+
+ /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
+ if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
+ {
+ gtk_label_set_text(GTK_LABEL(toolbar_if_lb), g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_selected)));
+ airpcap_channel_combo_set_by_number(toolbar_channel_cm,airpcap_if_selected->channel);
+ airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
+
+ gtk_signal_handler_block_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ }
+}
+
+/*
+ * Callback for the 'Ok' button.
+ */
+static void
+airpcap_advanced_ok_cb(GtkWidget *w, gpointer data _U_)
+{
+ /* advenced window */
+ GtkWidget *main_w;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm,
+ *toolbar_decryption_ck;
+
+ GtkWidget *key_ls;
+
+ /* retrieve main window */
+ main_w = GTK_WIDGET(data);
+
+ toolbar = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_TOOLBAR_KEY));
+
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ /* retrieve toolbar info */
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+ toolbar_decryption_ck = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_DECRYPTION_KEY));
+
+ /* Save the configuration */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+
+ /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
+ if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
+ {
+ gtk_label_set_text(GTK_LABEL(toolbar_if_lb), g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_selected)));
+ airpcap_channel_combo_set_by_number(toolbar_channel_cm,airpcap_if_selected->channel);
+ airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
+
+ gtk_signal_handler_block_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ }
+}
+
+/*
+ * Callback for the 'Reset Configuration' button.
+ */
+static void
+airpcap_advanced_reset_configuration_cb(GtkWidget *button, gpointer data _U_)
+{
+
+}
+
+/*
+ * Callback for the 'About' button.
+ */
+static void
+airpcap_advanced_about_cb(GtkWidget *button, gpointer data _U_)
+{
+ /* retrieve toolbar info */
+}
+
+/*
+ * Callback used to add a WEP key in the add new key box;
+ */
+static void
+add_key(GtkWidget *widget, gpointer data _U_)
+{
+GtkWidget *text,
+ *key_ls,
+ *ok_bt;
+
+GString *new_key;
+
+gchar *text_entered = NULL;
+
+int keys_in_list = 0;
+unsigned int i;
+
+text = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_ADD_KEY_TEXT_KEY);
+ok_bt = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_ADD_KEY_OK_KEY);
+key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+
+keys_in_list = g_list_length(GTK_LIST(key_ls)->children);
+text_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(text)));
+
+/* Too many keys? */
+if(keys_in_list == MAX_ENCRYPTION_KEYS)
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","Reached the Wep Keys Limit for this Interface.");
+ return;
+ }
+
+/* Check if key is correct */
+new_key = g_string_new(text_entered);
+
+g_strchug(new_key->str);
+g_strchomp(new_key->str);
+
+if((new_key->len % 2) != 0)
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","1) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ return;
+ }
+
+for(i = 0; i < new_key->len; i++)
+ {
+ if(!g_ascii_isxdigit(new_key->str[i]))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","2) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ return;
+ }
+ }
+
+/* If so... Add key */
+airpcap_add_key_to_list(key_ls,new_key->str);
+
+airpcap_if_selected->saved = FALSE;
+
+g_string_free(new_key,TRUE);
+g_free(text_entered);
+
+window_destroy(GTK_WIDGET(data));
+return;
+}
+
+/*
+ * Callback used to add a WEP key in the edit key box;
+ */
+static void
+edit_key(GtkWidget *widget, gpointer data _U_)
+{
+GtkWidget *text,
+ *key_ls,
+ *ok_bt;
+
+GString *new_key;
+
+gchar *text_entered = NULL;
+
+GtkWidget *label;
+
+
+int keys_in_list = 0;
+unsigned int i;
+
+text = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_EDIT_KEY_TEXT_KEY);
+ok_bt = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_EDIT_KEY_OK_KEY);
+key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+label = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_EDIT_KEY_LABEL_KEY);
+
+keys_in_list = g_list_length(GTK_LIST(key_ls)->children);
+text_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(text)));
+
+/* Check if key is correct */
+new_key = g_string_new(text_entered);
+
+g_strchug(new_key->str);
+g_strchomp(new_key->str);
+
+if((new_key->len % 2) != 0)
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","1) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ return;
+ }
+
+for(i = 0; i < new_key->len; i++)
+ {
+ if(!g_ascii_isxdigit(new_key->str[i]))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","2) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ return;
+ }
+ }
+
+/* If so... modify key */
+gtk_label_set_text(GTK_LABEL(label),new_key->str);
+
+airpcap_if_selected->saved = FALSE;
+
+g_string_free(new_key,TRUE);
+g_free(text_entered);
+
+window_destroy(GTK_WIDGET(data));
+return;
+}
+
+/*
+ * Callback for the 'Add Key' button.
+ */
+static void
+airpcap_advanced_add_key_cb(GtkWidget *button, gpointer data _U_)
+{
+/* Window */
+GtkWidget *add_key_w;
+
+/* Frame */
+GtkWidget *add_key_frame;
+
+/* Boxes */
+GtkWidget *main_box, /* vertical */
+ *key_box, /* orizontal */
+ *text_box, /* orizontal */
+ *button_box;/* orizontal (packed to end)*/
+
+/* Text Entry */
+GtkWidget *key_text_entry;
+
+/* Buttons */
+GtkWidget *key_ok_bt,
+ *key_cancel_bt;
+
+/* Key List Widget */
+GtkWidget *key_ls;
+
+ /* Pop-up a new window */
+ add_key_w = window_new (GTK_WINDOW_TOPLEVEL,"Add a WEP Key");
+
+ /* Connect events */
+ SIGNAL_CONNECT(add_key_w, "delete_event",window_delete_event_cb, add_key_w);
+ SIGNAL_CONNECT(add_key_w, "destroy",add_key_w_destroy_cb, add_key_w);
+
+ /* Sets the border width of the window. */
+ gtk_container_set_border_width (GTK_CONTAINER (add_key_w), 5);
+
+ /* Retrieve the key list widget pointer, and add it to the add_key_w */
+ key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+ OBJECT_SET_DATA(GTK_WIDGET(add_key_w),AIRPCAP_ADVANCED_KEYLIST_KEY,key_ls);
+ OBJECT_SET_DATA(GTK_WIDGET(add_key_w),AIRPCAP_ADVANCED_KEY,data);
+
+ /* Create boxes */
+ main_box = gtk_vbox_new(FALSE,1);
+ key_box = gtk_hbox_new(FALSE,1);
+ button_box = gtk_hbox_new(FALSE,1);
+ text_box = gtk_hbox_new(TRUE,1);
+
+ /* Add the two sub boxes to the main box */
+ gtk_box_pack_start(GTK_BOX(main_box), key_box, FALSE, FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(main_box), button_box, FALSE, FALSE, 1);
+
+ /* Add the main box to the main window */
+ gtk_container_add(GTK_CONTAINER(add_key_w),main_box);
+
+ /* Crete key frame */
+ add_key_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(add_key_frame),"Key");
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(add_key_frame),
+ 200,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(add_key_frame),
+ 200,
+ -1 );
+ #endif
+
+ gtk_box_pack_start(GTK_BOX(key_box), add_key_frame, FALSE, FALSE, 1);
+
+ /* Create and Add text entry*/
+ key_text_entry = gtk_entry_new();
+ OBJECT_SET_DATA(add_key_w, AIRPCAP_ADVANCED_ADD_KEY_TEXT_KEY, key_text_entry);
+ SIGNAL_CONNECT(key_text_entry, "activate", add_key, add_key_w );
+ gtk_box_pack_start(GTK_BOX(text_box), key_text_entry, FALSE, FALSE, 1);
+ gtk_container_add(GTK_CONTAINER(add_key_frame),text_box);
+ gtk_container_set_border_width (GTK_CONTAINER (text_box), 5);
+
+ /* Create and add buttons */
+ key_ok_bt = gtk_button_new_with_label("OK");
+ SIGNAL_CONNECT(key_ok_bt, "clicked", add_key, add_key_w );
+ OBJECT_SET_DATA(add_key_w, AIRPCAP_ADVANCED_ADD_KEY_OK_KEY, key_ok_bt);
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #endif
+ key_cancel_bt = gtk_button_new_with_label("Cancel");
+ SIGNAL_CONNECT(key_cancel_bt, "clicked", window_cancel_button_cb, add_key_w );
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #endif
+
+ gtk_box_pack_end(GTK_BOX(button_box), key_cancel_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end(GTK_BOX(button_box), key_ok_bt, FALSE, FALSE, 1);
+
+ /* Show all */
+ gtk_widget_show(key_ok_bt);
+ gtk_widget_show(key_cancel_bt);
+ gtk_widget_show(key_text_entry);
+ gtk_widget_show(add_key_frame);
+ gtk_widget_show(text_box);
+ gtk_widget_show(button_box);
+ gtk_widget_show(key_box);
+ gtk_widget_show(main_box);
+ gtk_widget_show(add_key_w);
+}
+
+/*
+ * Add key window destroy callback
+ */
+static void
+add_key_w_destroy_cb(GtkWidget *button, gpointer data _U_)
+{
+return;
+}
+
+/*
+ * Edit key window destroy callback
+ */
+static void
+edit_key_w_destroy_cb(GtkWidget *button, gpointer data _U_)
+{
+return;
+}
+
+/*
+ * Callback for the 'Remove Key' button.
+ */
+static void
+airpcap_advanced_remove_key_cb(GtkWidget *button, gpointer data _U_)
+{
+GtkList *key_ls;
+GtkWidget *label;
+GList *item = NULL;
+gint n;
+
+/* retrieve key list */
+key_ls = GTK_LIST(data);
+
+/* Remove selected keys*/
+if(key_ls->selection != NULL)
+ {
+ item = g_list_nth(key_ls->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(key_ls,item->data);
+ label = GTK_BIN(item->data)->child;
+ gtk_list_clear_items(key_ls,n,n+1);
+ }
+ }
+
+/* Need to save config... */
+airpcap_if_selected->saved = FALSE;
+}
+
+/*
+ * Callback for the 'Edit Key' button.
+ */
+static void
+airpcap_advanced_edit_key_cb(GtkWidget *button, gpointer data _U_)
+{
+/* Window */
+GtkWidget *edit_key_w;
+
+/* Frame */
+GtkWidget *edit_key_frame;
+
+/* Boxes */
+GtkWidget *main_box, /* vertical */
+ *key_box, /* orizontal */
+ *text_box, /* orizontal */
+ *button_box;/* orizontal (packed to end)*/
+
+/* Text Entry */
+GtkWidget *key_text_entry;
+
+/* Buttons */
+GtkWidget *key_ok_bt,
+ *key_cancel_bt;
+
+/* Key List Widget */
+GtkWidget *key_ls;
+
+GtkWidget *label;
+GList *item = NULL;
+gint n;
+
+/* Retrieve the key list widget pointer, and add it to the edit_key_w */
+key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+
+/*
+ * Check if a key has been selected. If not, just do nothing.
+ */
+if(GTK_LIST(key_ls)->selection != NULL)
+ {
+ item = g_list_nth(GTK_LIST(key_ls)->selection,0);
+ if(item != NULL)
+ {
+ /* Pop-up a new window */
+ edit_key_w = window_new (GTK_WINDOW_TOPLEVEL,"Edit a WEP Key");
+
+ /* Connect events */
+ SIGNAL_CONNECT(edit_key_w, "delete_event",window_delete_event_cb, edit_key_w);
+ SIGNAL_CONNECT(edit_key_w, "destroy",edit_key_w_destroy_cb, edit_key_w);
+
+ /* Sets the border width of the window. */
+ gtk_container_set_border_width (GTK_CONTAINER (edit_key_w), 5);
+
+ OBJECT_SET_DATA(GTK_WIDGET(edit_key_w),AIRPCAP_ADVANCED_KEYLIST_KEY,key_ls);
+ OBJECT_SET_DATA(GTK_WIDGET(edit_key_w),AIRPCAP_ADVANCED_KEY,data);
+
+ /* Create boxes */
+ main_box = gtk_vbox_new(FALSE,1);
+ key_box = gtk_hbox_new(FALSE,1);
+ button_box = gtk_hbox_new(FALSE,1);
+ text_box = gtk_hbox_new(TRUE,1);
+
+ /* Add the two sub boxes to the main box */
+ gtk_box_pack_start(GTK_BOX(main_box), key_box, FALSE, FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(main_box), button_box, FALSE, FALSE, 1);
+
+ /* Add the main box to the main window */
+ gtk_container_add(GTK_CONTAINER(edit_key_w),main_box);
+
+ /* Crete key frame */
+ edit_key_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(edit_key_frame),"Key");
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(edit_key_frame),
+ 200,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(edit_key_frame),
+ 200,
+ -1 );
+ #endif
+
+ gtk_box_pack_start(GTK_BOX(key_box), edit_key_frame, FALSE, FALSE, 1);
+
+ /* Create and Add text entry*/
+ key_text_entry = gtk_entry_new();
+ /* Retrieve the currently selected entry */
+ if(GTK_LIST(key_ls)->selection != NULL)
+ {
+ item = g_list_nth(GTK_LIST(key_ls)->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(GTK_LIST(key_ls),item->data);
+ label = GTK_BIN(item->data)->child;
+ /* Pass the pointer as data */
+ OBJECT_SET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_LABEL_KEY,label);
+ }
+ }
+ gtk_entry_set_text(GTK_ENTRY(key_text_entry),GTK_LABEL(label)->label);
+ OBJECT_SET_DATA(edit_key_w, AIRPCAP_ADVANCED_EDIT_KEY_TEXT_KEY, key_text_entry);
+ SIGNAL_CONNECT(key_text_entry, "activate", edit_key, edit_key_w );
+ gtk_box_pack_start(GTK_BOX(text_box), key_text_entry, FALSE, FALSE, 1);
+ gtk_container_add(GTK_CONTAINER(edit_key_frame),text_box);
+ gtk_container_set_border_width (GTK_CONTAINER (text_box), 5);
+
+ /* Create and add buttons */
+ key_ok_bt = gtk_button_new_with_label("OK");
+ SIGNAL_CONNECT(key_ok_bt, "clicked", edit_key, edit_key_w );
+ OBJECT_SET_DATA(edit_key_w, AIRPCAP_ADVANCED_EDIT_KEY_OK_KEY, key_ok_bt);
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #endif
+ key_cancel_bt = gtk_button_new_with_label("Cancel");
+ SIGNAL_CONNECT(key_cancel_bt, "clicked", window_cancel_button_cb, edit_key_w );
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #endif
+
+ gtk_box_pack_end(GTK_BOX(button_box), key_cancel_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end(GTK_BOX(button_box), key_ok_bt, FALSE, FALSE, 1);
+
+ /* Show all */
+ gtk_widget_show(key_ok_bt);
+ gtk_widget_show(key_cancel_bt);
+ gtk_widget_show(key_text_entry);
+ gtk_widget_show(edit_key_frame);
+ gtk_widget_show(text_box);
+ gtk_widget_show(button_box);
+ gtk_widget_show(key_box);
+ gtk_widget_show(main_box);
+ gtk_widget_show(edit_key_w);
+ }
+ }
+}
+
+/*
+ * Callback for the 'Move Key Up' button.
+ */
+static void
+airpcap_advanced_move_key_up_cb(GtkWidget *button, gpointer data _U_)
+{
+GtkList *key_ls;
+GtkWidget *label,*nl_lb,*nl_item;
+GList *new_list = NULL;
+GList *item = NULL;
+gint n;
+
+/* retrieve key list */
+key_ls = GTK_LIST(data);
+
+/* Remove selected keys*/
+if(key_ls->selection != NULL)
+ {
+ item = g_list_nth(key_ls->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(key_ls,item->data);
+ if(n>0)
+ {
+ label = GTK_BIN(item->data)->child;
+ nl_lb = gtk_label_new(GTK_LABEL(label)->label);
+ gtk_list_clear_items(key_ls,n,n+1);
+ nl_item = gtk_list_item_new();
+ gtk_misc_set_alignment (GTK_MISC (nl_lb), 0.0, 0.5);
+ gtk_container_add(GTK_CONTAINER(nl_item), nl_lb);
+ gtk_widget_show(nl_lb);
+ gtk_widget_show(nl_item);
+ new_list = g_list_append(new_list,nl_item);
+ gtk_list_insert_items(key_ls,new_list,n-1);
+ gtk_list_select_item(key_ls,n-1);
+ }
+ }
+ }
+
+/* Need to save config... */
+airpcap_if_selected->saved = FALSE;
+}
+
+/*
+ * Callback for the 'Move Key Down' button.
+ */
+static void
+airpcap_advanced_move_key_down_cb(GtkWidget *button, gpointer data _U_)
+{
+GtkList *key_ls;
+GtkWidget *label,*nl_lb,*nl_item;
+GList *new_list = NULL;
+GList *item = NULL;
+unsigned int n;
+
+/* retrieve key list */
+key_ls = GTK_LIST(data);
+
+/* Remove selected keys*/
+if(key_ls->selection != NULL)
+ {
+ item = g_list_nth(key_ls->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(key_ls,item->data);
+ if(n< (g_list_length(key_ls->children)-1))
+ {
+ label = GTK_BIN(item->data)->child;
+ nl_lb = gtk_label_new(GTK_LABEL(label)->label);
+ gtk_list_clear_items(key_ls,n,n+1);
+
+ nl_item = gtk_list_item_new();
+ gtk_misc_set_alignment (GTK_MISC (nl_lb), 0.0, 0.5);
+ gtk_container_add(GTK_CONTAINER(nl_item), nl_lb);
+ gtk_widget_show(nl_lb);
+ gtk_widget_show(nl_item);
+
+ new_list = g_list_append(new_list,nl_item);
+ gtk_list_insert_items(key_ls,new_list,n+1);
+ gtk_list_select_item(key_ls,n+1);
+ }
+ }
+ }
+
+/* Need to save config... */
+airpcap_if_selected->saved = FALSE;
+}
+
+/* Turns the decryption on or off */
+static void
+encryption_check_cb(GtkWidget *w, gpointer data)
+{
+if( !block_advanced_signals && (airpcap_if_selected != NULL))
+ {
+ if(airpcap_if_selected->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ {
+ airpcap_if_selected->DecryptionOn = AIRPCAP_DECRYPTION_OFF;
+ airpcap_if_selected->saved = FALSE;
+ }
+ else
+ {
+ airpcap_if_selected->DecryptionOn = AIRPCAP_DECRYPTION_ON;
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+
+/* Called to create the airpcap settings' window */
+void
+display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
+{
+ /* Main window */
+ GtkWidget *airpcap_advanced_w;
+
+ /* Blink button */
+ GtkWidget *blink_bt,
+ *channel_combo;
+ /* Combos */
+ GtkWidget *interface_combo,
+ *capture_combo;
+
+ /* check */
+ GtkWidget *wrong_crc_combo;
+
+ /* key list*/
+ GtkWidget *key_ls;
+
+ /* frames */
+ GtkWidget *interface_frame,
+ *basic_frame,
+ *wep_frame;
+ /* boxes */
+ GtkWidget *main_box,
+ *buttons_box_1,
+ *buttons_box_2,
+ *interface_box,
+ *basic_box,
+ *basic_combo_box,
+ *basic_check_box,
+ *basic_label_box,
+ *basic_wrong_box,
+ *wep_box,
+ *wep_sub_box,
+ *encryption_box,
+ *wep_buttons_box;
+ /* buttons */
+ /* blink button is global */
+ GtkWidget *add_new_key_bt,
+ *remove_key_bt,
+ *edit_key_bt,
+ *move_key_up_bt,
+ *move_key_down_bt,
+ *reset_configuration_bt,
+ *about_bt,
+ *apply_bt,
+ *ok_bt,
+ *cancel_bt;
+ /* combo */
+
+ /* shortcut to combo entry */
+ GtkWidget *link_type_te,
+ *wrong_crc_te,
+ *channel_te;
+ /* check */
+ /* global check buttons */
+ GtkWidget *crc_check,
+ *encryption_check;
+ /* label */
+ GtkWidget *channel_lb,
+ *wrong_lb,
+ *capture_lb;
+ /* text field */
+ GtkWidget *key_text;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm;
+
+ /* other stuff */
+ GList *channel_list,*capture_list;
+ GList *linktype_list = NULL;
+ gchar *channel_s,*capture_s;
+
+
+ /* user data - RETRIEVE pointers of toolbar widgets */
+ toolbar = GTK_WIDGET(data);
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm= GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+
+ /* gray out the toolbar */
+ gtk_widget_set_sensitive(toolbar,FALSE);
+
+ /* main window */
+ /* global */
+
+ /* NULL to global widgets */
+ blink_bt = NULL;
+ channel_combo = NULL;
+ block_advanced_signals = FALSE;
+
+ /* the selected is the active, for now */
+ airpcap_if_selected = airpcap_if_active;
+
+ /* Create the new window */
+ airpcap_advanced_w = window_new(GTK_WINDOW_TOPLEVEL, "Advanced Wireless Settings");
+
+ /*
+ * I will need the toolbar and the main widget in some callback,
+ * so I will add the toolbar pointer to the airpcap_advanced_w
+ */
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_TOOLBAR_KEY,toolbar);
+
+ /* Connect the callbacks */
+ SIGNAL_CONNECT(airpcap_advanced_w, "delete_event", window_delete_event_cb, airpcap_advanced_w);
+ SIGNAL_CONNECT(airpcap_advanced_w, "destroy", airpcap_if_destroy_cb, airpcap_advanced_w);
+
+ /* Set the size */
+ /* Sets the border width of the window. */
+ gtk_container_set_border_width (GTK_CONTAINER (airpcap_advanced_w), 10);
+
+ /* Create the main box */
+ main_box = gtk_vbox_new(FALSE,0);
+
+ /* Create the button boxes */
+ buttons_box_1 = gtk_hbox_new(FALSE,0);
+ buttons_box_2 = gtk_hbox_new(FALSE,0);
+
+ /* Create the buttons for box 1 */
+ reset_configuration_bt = gtk_button_new_with_label("Reset Configuration");
+ SIGNAL_CONNECT(reset_configuration_bt, "clicked", airpcap_advanced_reset_configuration_cb, toolbar);
+ gtk_widget_show(reset_configuration_bt);
+
+ about_bt = gtk_button_new_with_label("About");
+ SIGNAL_CONNECT(about_bt, "clicked", airpcap_advanced_about_cb, toolbar);
+ gtk_widget_show(about_bt);
+
+ /* Add them to box 1 */
+ gtk_box_pack_start (GTK_BOX (buttons_box_1), reset_configuration_bt, FALSE, FALSE, 1);
+ gtk_box_pack_start (GTK_BOX (buttons_box_1), about_bt, FALSE, FALSE, 1);
+
+ /* Create the buttons for box 2 */
+ apply_bt = gtk_button_new_with_label("Apply");
+ SIGNAL_CONNECT(apply_bt, "clicked", airpcap_advanced_apply_cb, airpcap_advanced_w);
+ gtk_widget_show(apply_bt);
+
+ ok_bt = gtk_button_new_with_label("Ok");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_OK_KEY,ok_bt);
+ window_set_cancel_button(airpcap_advanced_w, ok_bt, window_cancel_button_cb);
+ gtk_widget_show(ok_bt);
+
+ cancel_bt = gtk_button_new_with_label("Cancel");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_CANCEL_KEY,cancel_bt);
+ window_set_cancel_button(airpcap_advanced_w, cancel_bt, window_cancel_button_cb);
+ gtk_widget_show(cancel_bt);
+
+ /* Add them to box 2 */
+ gtk_box_pack_end (GTK_BOX (buttons_box_2), cancel_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end (GTK_BOX (buttons_box_2), apply_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end (GTK_BOX (buttons_box_2), ok_bt, FALSE, FALSE, 1);
+
+ /* Create the three main frames */
+ interface_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(interface_frame),"Interface");
+
+ basic_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(basic_frame),"Basic Parameters");
+
+ wep_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(wep_frame),"WEP Keys");
+
+ /* Create the three sub boxes */
+ interface_box = gtk_hbox_new(FALSE,0);
+ basic_box = gtk_hbox_new(FALSE,0);
+ wep_box = gtk_vbox_new(FALSE,0);
+
+ /* Fill the interface_box */
+ if(airpcap_if_active != NULL)
+ {
+ interface_combo = gtk_label_new(airpcap_if_active->description);
+ }
+ else
+ {
+ interface_combo = gtk_label_new("No airpcap interface found!");
+ gtk_widget_set_sensitive(main_box,FALSE);
+ }
+
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_INTERFACE_KEY,interface_combo);
+ gtk_box_pack_start (GTK_BOX (interface_box), interface_combo, TRUE, TRUE, 0);
+ gtk_widget_show(interface_combo);
+
+ /* blink led button (BEFORE interface_combo, 'cause its callback will need blink_bt)*/
+ blink_bt = gtk_button_new_with_label(" Blink Led ");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_BLINK_KEY,blink_bt);
+ gtk_box_pack_end (GTK_BOX (interface_box), blink_bt, FALSE, FALSE, 0);
+ SIGNAL_CONNECT(blink_bt, "clicked", blink_cb, NULL);
+ gtk_widget_show(blink_bt);
+
+ gtk_container_set_border_width (GTK_CONTAINER (interface_box), 10);
+
+ /* Fill the basic_box */
+ /* Create the two vertical boxes for combo and check */
+ basic_combo_box = gtk_vbox_new(TRUE,0);
+ basic_check_box = gtk_vbox_new(TRUE,0);
+ basic_label_box = gtk_vbox_new(TRUE,0);
+
+ /* Create the Wrong CRC horiziontal box */
+ basic_wrong_box = gtk_hbox_new(FALSE,0);
+
+ /* Fill the label vbox */
+ channel_lb = gtk_label_new("Channel: ");
+ gtk_label_set_justify(GTK_LABEL(channel_lb),GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (basic_label_box), channel_lb, TRUE, TRUE, 0);
+ gtk_widget_show(channel_lb);
+ capture_lb = gtk_label_new("Capture Type:");
+ gtk_label_set_justify(GTK_LABEL(capture_lb),GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (basic_label_box), capture_lb, TRUE, TRUE, 0);
+ gtk_widget_show(capture_lb);
+
+ /* Create the two combo boxes */
+ channel_combo = gtk_combo_new();
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_CHANNEL_KEY,channel_combo);
+
+ channel_list = NULL;
+ channel_list = g_list_append(channel_list, "1");
+ channel_list = g_list_append(channel_list, "2");
+ channel_list = g_list_append(channel_list, "3");
+ channel_list = g_list_append(channel_list, "4");
+ channel_list = g_list_append(channel_list, "5");
+ channel_list = g_list_append(channel_list, "6");
+ channel_list = g_list_append(channel_list, "7");
+ channel_list = g_list_append(channel_list, "8");
+ channel_list = g_list_append(channel_list, "9");
+ channel_list = g_list_append(channel_list, "10");
+ channel_list = g_list_append(channel_list, "11");
+ channel_list = g_list_append(channel_list, "12");
+ channel_list = g_list_append(channel_list, "13");
+ channel_list = g_list_append(channel_list, "14");
+ gtk_combo_set_popdown_strings( GTK_COMBO(channel_combo), channel_list) ;
+
+ /* Select the first entry */
+ if(airpcap_if_selected != NULL)
+ {
+ channel_s = g_strdup_printf("%d",airpcap_if_selected->channel);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_combo)->entry), channel_s);
+ }
+
+ channel_te = GTK_COMBO(channel_combo)->entry;
+ gtk_editable_set_editable(GTK_EDITABLE(channel_te),FALSE);
+ SIGNAL_CONNECT(channel_te, "changed", channel_changed_cb, channel_te);
+ gtk_box_pack_start (GTK_BOX (basic_combo_box), channel_combo, FALSE, FALSE, 0);
+ gtk_widget_show(channel_combo);
+
+ capture_combo = gtk_combo_new();
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_LINK_TYPE_KEY,capture_combo);
+ capture_list = NULL;
+ capture_list = g_list_append(capture_list, AIRPCAP_LINK_TYPE_NAME_802_11_ONLY);
+ capture_list = g_list_append(capture_list, AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
+ gtk_combo_set_popdown_strings( GTK_COMBO(capture_combo), capture_list) ;
+
+ capture_s = NULL;
+ if(airpcap_if_selected != NULL)
+ {
+ if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11)
+ capture_s = g_strdup_printf("%s",AIRPCAP_LINK_TYPE_NAME_802_11_ONLY);
+ else if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11_PLUS_RADIO)
+ capture_s = g_strdup_printf("%s",AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
+ if(capture_s != NULL) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(capture_combo)->entry), capture_s);
+ }
+ g_free(capture_s);
+
+ link_type_te = GTK_COMBO(capture_combo)->entry;
+ gtk_editable_set_editable(GTK_EDITABLE(link_type_te),FALSE);
+ SIGNAL_CONNECT(link_type_te, "changed", link_type_changed_cb, link_type_te);
+ gtk_box_pack_start (GTK_BOX (basic_combo_box), capture_combo, FALSE, FALSE, 1);
+ gtk_widget_show(capture_combo);
+
+ /* Create the two check boxes */
+ crc_check = gtk_check_button_new_with_label("Include 802.11 FCS in Frames");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_CRC_KEY,crc_check);
+
+ /* Fcs Presence check box */
+ if(airpcap_if_selected != NULL)
+ {
+ if(airpcap_if_selected->IsFcsPresent)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),FALSE);
+ }
+
+ SIGNAL_CONNECT(crc_check,"toggled",crc_check_cb,NULL);
+ gtk_box_pack_start (GTK_BOX (basic_check_box), crc_check, FALSE, FALSE, 0);
+ gtk_widget_show(crc_check);
+
+ /* CRC Filter label */
+ wrong_lb = gtk_label_new("FCS Filter:");
+ gtk_box_pack_start (GTK_BOX (basic_wrong_box), wrong_lb, FALSE, FALSE, 0);
+ gtk_widget_show(wrong_lb);
+
+ /* CRC Filter combo */
+ wrong_crc_combo = gtk_combo_new();
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_WRONG_CRC_KEY,wrong_crc_combo);
+
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_ALL);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRECT);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT);
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(wrong_crc_combo), linktype_list) ;
+
+ wrong_crc_te = GTK_COMBO(wrong_crc_combo)->entry;
+
+ if(airpcap_if_selected != NULL)
+ {
+ airpcap_validation_type_combo_set_by_type(wrong_crc_combo,airpcap_if_selected->CrcValidationOn);
+ }
+
+ gtk_editable_set_editable(GTK_EDITABLE(wrong_crc_te),FALSE);
+ SIGNAL_CONNECT(wrong_crc_te,"changed",wrong_crc_combo_cb,wrong_crc_te);
+ gtk_box_pack_start (GTK_BOX (basic_wrong_box), wrong_crc_combo, FALSE, FALSE, 0);
+ gtk_widget_show(wrong_crc_combo);
+
+ gtk_box_pack_start(GTK_BOX(basic_check_box), basic_wrong_box, FALSE, FALSE, 0);
+ gtk_widget_show(basic_wrong_box);
+
+ /* Add the vertical inner boxes to the basic_box */
+ gtk_box_pack_start (GTK_BOX (basic_box), basic_label_box, FALSE, FALSE, 10);
+ gtk_box_pack_start (GTK_BOX (basic_box), basic_combo_box, FALSE, FALSE, 10);
+ gtk_box_pack_start (GTK_BOX (basic_box), basic_check_box, FALSE, FALSE, 10);
+
+ gtk_container_set_border_width (GTK_CONTAINER (basic_box), 10);
+
+ /* Fill the wep_box */
+ wep_sub_box = gtk_hbox_new(FALSE,1);
+ gtk_widget_show(wep_sub_box);
+ encryption_box = gtk_hbox_new(FALSE,1);
+ gtk_widget_show(encryption_box);
+
+ /* encryption enabled box */
+ encryption_check = gtk_check_button_new_with_label("Enable WEP Decryption");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_DECRYPTION_KEY,encryption_check);
+
+ /* Fcs Presence check box */
+ if(airpcap_if_selected != NULL)
+ {
+ if(airpcap_if_selected->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_check),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_check),FALSE);
+ }
+
+ SIGNAL_CONNECT(encryption_check,"toggled",encryption_check_cb,NULL);
+ gtk_box_pack_start (GTK_BOX (encryption_box), encryption_check, FALSE, FALSE, 0);
+ gtk_widget_show(encryption_check);
+
+ /* WEP text box */
+ key_text = scrolled_window_new(NULL, NULL);
+ /* never use a scrollbar in x direction, show the complete relation string */
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(key_text),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(key_text),
+ GTK_SHADOW_IN);
+ #endif
+
+ /* add WEP keys if present... */
+ key_ls = gtk_list_new();
+ gtk_list_set_selection_mode(GTK_LIST(key_ls), GTK_SELECTION_SINGLE);
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_KEYLIST_KEY,key_ls);
+
+ airpcap_fill_key_list(key_ls,airpcap_if_selected);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(key_text),key_ls);
+ gtk_widget_show(key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_sub_box), key_text, TRUE, TRUE, 0);
+ gtk_widget_show(key_text);
+
+ /* WEP buttons */
+ wep_buttons_box = gtk_vbox_new(FALSE,0);
+
+ /* Create and add buttons */
+ add_new_key_bt = gtk_button_new_with_label("Add New Key");
+ SIGNAL_CONNECT(add_new_key_bt, "clicked", airpcap_advanced_add_key_cb, airpcap_advanced_w);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), add_new_key_bt, FALSE, FALSE, 0);
+ gtk_widget_show(add_new_key_bt);
+ remove_key_bt = gtk_button_new_with_label("Remove Key");
+ SIGNAL_CONNECT(remove_key_bt, "clicked", airpcap_advanced_remove_key_cb, key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), remove_key_bt, FALSE, FALSE, 0);
+ gtk_widget_show(remove_key_bt);
+ edit_key_bt = gtk_button_new_with_label("Edit Key");
+ SIGNAL_CONNECT(edit_key_bt, "clicked", airpcap_advanced_edit_key_cb, airpcap_advanced_w);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), edit_key_bt, FALSE, FALSE, 0);
+ gtk_widget_show(edit_key_bt);
+ move_key_up_bt = gtk_button_new_with_label("Move Key Up");
+ SIGNAL_CONNECT(move_key_up_bt, "clicked", airpcap_advanced_move_key_up_cb, key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), move_key_up_bt, FALSE, FALSE, 0);
+ gtk_widget_show(move_key_up_bt);
+ move_key_down_bt = gtk_button_new_with_label("Move Key Down");
+ SIGNAL_CONNECT(move_key_down_bt, "clicked", airpcap_advanced_move_key_down_cb, key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), move_key_down_bt, FALSE, FALSE, 0);
+ gtk_widget_show(move_key_down_bt);
+
+ gtk_box_pack_end (GTK_BOX (wep_sub_box), wep_buttons_box, FALSE, FALSE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (wep_sub_box), 10);
+
+ gtk_box_pack_start (GTK_BOX (wep_box), encryption_box, FALSE, FALSE,0);
+ gtk_box_pack_start (GTK_BOX (wep_box), wep_sub_box, FALSE, FALSE,0);
+ gtk_widget_show(wep_sub_box);
+
+ /* Add them to the frames */
+ gtk_container_add(GTK_CONTAINER(interface_frame),interface_box);
+ gtk_container_add(GTK_CONTAINER(basic_frame),basic_box);
+ gtk_container_add(GTK_CONTAINER(wep_frame),wep_box);
+
+ /* Add frames to the main box */
+ gtk_box_pack_start (GTK_BOX (main_box), interface_frame, FALSE, FALSE, 1);
+ gtk_box_pack_start (GTK_BOX (main_box), basic_frame, FALSE, FALSE, 1);
+ gtk_box_pack_start (GTK_BOX (main_box), wep_frame, FALSE, FALSE, 1);
+
+ /* Add buttons' boxes to the main box */
+ gtk_box_pack_start (GTK_BOX (main_box), buttons_box_2, FALSE, FALSE, 1);
+
+ /* Add the main box to the main window */
+ gtk_container_add(GTK_CONTAINER(airpcap_advanced_w),main_box);
+
+ /* SHOW EVERYTHING */
+ /* Show the WEP key buttons */
+ gtk_widget_show (wep_buttons_box);
+
+ /* Show the combo and check boxes */
+ gtk_widget_show (basic_label_box);
+ gtk_widget_show (basic_combo_box);
+ gtk_widget_show (basic_check_box);
+
+ /* Show the button boxes */
+ gtk_widget_show (buttons_box_1);
+ gtk_widget_show (buttons_box_2);
+
+ /* Show the frames */
+ gtk_widget_show (interface_frame);
+ gtk_widget_show (basic_frame);
+ gtk_widget_show (wep_frame);
+
+ /* Show the sub main boxes */
+ gtk_widget_show (interface_box);
+ gtk_widget_show (basic_box);
+ gtk_widget_show (wep_box);
+
+ /* Show the main box */
+ gtk_widget_show (main_box);
+
+ /* Show the window */
+ gtk_widget_show (airpcap_advanced_w);
+}
+
+#endif /* HAVE_AIRPCAP */
diff --git a/gtk/airpcap_dlg.h b/gtk/airpcap_dlg.h
new file mode 100644
index 0000000000..ea4a904481
--- /dev/null
+++ b/gtk/airpcap_dlg.h
@@ -0,0 +1,148 @@
+/* airpcap_dlg.h
+ * Declarations of routines for the "Airpcap" dialog
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __AIRPCAP_DLG_H__
+#define __AIRPCAP_DLG_H__
+
+#define AIRPCAP_ADVANCED_FROM_TOOLBAR 0
+#define AIRPCAP_ADVANCED_FROM_OPTIONS 1
+
+/*
+ * Takes the keys from the GtkList widget, and add them to the interface list
+ */
+void airpcap_add_keys_from_list(GtkWidget *w, airpcap_if_info_t *if_info);
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ * when closing the window.
+ */
+void
+airpcap_ask_for_save_before_closing(GtkWidget *w _U_, gpointer data);
+
+/* user confirmed the "Save settings..." dialog */
+void
+airpcap_dialog_save_before_closing_cb(gpointer dialog _U_, gint btn, gpointer data);
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ */
+void
+airpcap_ask_for_save(GtkWidget *entry _U_, gpointer data);
+
+/*
+ * Function used to change the selected interface and advanced dialog box
+ */
+void
+airpcap_change_if(GtkWidget *entry _U_, gpointer data);
+
+/*
+ * Fill the interface combo box specified
+ */
+void
+airpcap_fill_if_combo(GtkWidget *combo, GList* if_list);
+
+/*
+ * Add key window destroy callback
+ */
+static void
+add_key_w_destroy_cb(GtkWidget *button, gpointer data _U_);
+
+/*
+ * Changed callback for the channel combobox
+ */
+static void
+channel_changed_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Activate callback for the link layer combobox
+ */
+static void
+link_layer_activate_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Changed callback for the link layer combobox
+ */
+static void
+link_layer_changed_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Callback for the crc chackbox
+ */
+static void
+crc_check_cb(GtkWidget *w, gpointer user_data);
+
+/*
+ * Callback for the wrong crc chackbox
+ */
+static void
+wrong_crc_check_cb(GtkWidget *w, gpointer user_data);
+
+/*
+ * Callbackfunction for WEP key list
+ */
+static void
+key_sel_list_cb(GtkWidget *l, gpointer data _U_);
+
+/*
+ * Callback function for WEP key list
+ */
+static gint
+key_sel_list_button_cb(GtkWidget *widget, GdkEventButton *event,gpointer func_data);
+
+/*
+ * Activate callback for the adapter combobox
+ */
+static void
+combo_if_activate_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Changed callback for the adapter combobox
+ */
+static void
+airpcap_advanced_combo_if_changed_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Pop-up window that appears when user confirms the "Save settings..." dialog
+ */
+static void
+airpcap_dialog_save_cb(GtkWidget* dialog _U_, gint btn, gpointer data);
+
+/*
+ * Thread function used to blink the led
+ */
+void update_blink(gpointer data _U_);
+
+/*
+ * Blink button callback
+ */
+void blink_cb(GtkWidget *blink_bt _U_, gpointer if_data);
+
+/** Create a "Airpcap" dialog box caused by a button click.
+ *
+ * @param widget parent widget
+ * @param construct_args_ptr parameters to construct the dialog (construct_args_t)
+ */
+void display_airpcap_advanced_cb(GtkWidget *widget, gpointer construct_args_ptr);
+
+#endif
diff --git a/gtk/airpcap_gui_utils.c b/gtk/airpcap_gui_utils.c
new file mode 100755
index 0000000000..69a61bef44
--- /dev/null
+++ b/gtk/airpcap_gui_utils.c
@@ -0,0 +1,400 @@
+/* airpcap_gui_utils.c
+ *
+ * $Id$
+ *
+ * Ulf Lamping <ulf.lamping@web.de>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2000 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_AIRPCAP
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <string.h>
+
+#include <epan/filesystem.h>
+
+#include "gtk/main.h"
+#include "dlg_utils.h"
+#include "gui_utils.h"
+#include "simple_dialog.h"
+#include "dfilter_expr_dlg.h"
+#include "compat_macros.h"
+#include "gtkglobals.h"
+#include "help_dlg.h"
+
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+
+#include "keys.h"
+
+/*
+ * Set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
+{
+GtkWidget *airpcap_toolbar_crc_filter_combo;
+GtkWidget *airpcap_toolbar_label;
+GtkWidget *airpcap_toolbar_channel;
+GtkWidget *airpcap_toolbar_button;
+GtkWidget *airpcap_toolbar_decryption;
+
+gchar *if_label_text;
+
+airpcap_toolbar_crc_filter_combo = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_WRONG_CRC_KEY);
+airpcap_toolbar_label = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY);
+airpcap_toolbar_channel = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY);
+airpcap_toolbar_button = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY);
+airpcap_toolbar_decryption = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
+
+/* The current interface is an airpcap interface */
+if(if_info != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption,FALSE);
+ airpcap_validation_type_combo_set_by_type(GTK_WIDGET(airpcap_toolbar_crc_filter_combo),if_info->CrcValidationOn);
+ airpcap_channel_combo_set_by_number(GTK_WIDGET(airpcap_toolbar_channel),if_info->channel);
+
+ /*decription check box*/
+ gtk_signal_handler_block_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+ if(if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+
+ if_label_text = g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(if_info));
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
+ g_free(if_label_text);
+ }
+else
+ {
+ if(airpcap_if_list != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"Not a valid Wireless Interface");
+ }
+ else
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"No Wireless Interface Found");
+ }
+ }
+}
+
+/*
+ * Set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
+{
+GtkWidget *airpcap_toolbar_crc_filter_combo;
+GtkWidget *airpcap_toolbar_label;
+GtkWidget *airpcap_toolbar_channel;
+GtkWidget *airpcap_toolbar_button;
+GtkWidget *airpcap_toolbar_decryption;
+
+gchar *if_label_text;
+
+airpcap_toolbar_crc_filter_combo = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_WRONG_CRC_KEY);
+airpcap_toolbar_label = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY);
+airpcap_toolbar_channel = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY);
+airpcap_toolbar_button = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY);
+airpcap_toolbar_decryption = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
+
+/* The current interface is an airpcap interface */
+if(if_info != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption,TRUE);
+ airpcap_validation_type_combo_set_by_type(GTK_WIDGET(airpcap_toolbar_crc_filter_combo),if_info->CrcValidationOn);
+ airpcap_channel_combo_set_by_number(GTK_WIDGET(airpcap_toolbar_channel),if_info->channel);
+
+ /*decription check box*/
+ gtk_signal_handler_block_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+ if(if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+
+
+ if_label_text = g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(if_info));
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
+ g_free(if_label_text);
+ }
+else
+ {
+ if(airpcap_if_list != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"Not a valid Wireless Interface");
+ }
+ else
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"No Wireless Interface Found");
+ }
+ }
+}
+
+/*
+ * Add a key (string) to the given list
+ */
+void
+airpcap_add_key_to_list(GtkWidget *keylist, gchar* s)
+{
+GtkWidget *nl_item,*nl_lb;
+
+nl_lb = gtk_label_new(s);
+nl_item = gtk_list_item_new();
+
+gtk_misc_set_alignment (GTK_MISC (nl_lb), 0.0, 0.5);
+gtk_container_add(GTK_CONTAINER(nl_item), nl_lb);
+gtk_widget_show(nl_lb);
+gtk_container_add(GTK_CONTAINER(keylist), nl_item);
+gtk_widget_show(nl_item);
+}
+
+/*
+ * Fill the list with the keys
+ */
+void
+airpcap_fill_key_list(GtkWidget *keylist,airpcap_if_info_t* if_info)
+{
+GtkWidget *nl_item,*nl_lb;
+gchar* s;
+unsigned int i;
+
+ if( (if_info != NULL) && (if_info->keysCollection != NULL))
+ {
+ for(i = 0; i < if_info->keysCollection->nKeys; i++)
+ {
+ s = airpcap_get_key_string(if_info->keysCollection->Keys[i]);
+ nl_lb = gtk_label_new(s);
+ nl_item = gtk_list_item_new();
+ gtk_misc_set_alignment (GTK_MISC (nl_lb), 0.0, 0.5);
+ gtk_container_add(GTK_CONTAINER(nl_item), nl_lb);
+ gtk_widget_show(nl_lb);
+ gtk_container_add(GTK_CONTAINER(keylist), nl_item);
+ gtk_widget_show(nl_item);
+ }
+ }
+}
+
+/*
+ * Function used to retrieve the AirpcapValidationType given the string name.
+ */
+AirpcapValidationType
+airpcap_get_validation_type(const gchar* name)
+{
+ if(!(g_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_ALL,name)))
+ {
+ return AIRPCAP_VT_ACCEPT_EVERYTHING;
+ }
+ else if(!(g_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRECT,name)))
+ {
+ return AIRPCAP_VT_ACCEPT_CORRECT_FRAMES;
+ }
+ else if(!(g_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT,name)))
+ {
+ return AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES;
+ }
+ else
+ {
+ return AIRPCAP_VT_UNKNOWN;
+ }
+}
+
+/*
+ * Function used to retrieve the string name given an AirpcapValidationType,
+ * or NULL in case of error
+ */
+gchar*
+airpcap_get_validation_name(AirpcapValidationType vt)
+{
+ if(vt == AIRPCAP_VT_ACCEPT_EVERYTHING)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_ALL;
+ }
+ else if(vt == AIRPCAP_VT_ACCEPT_CORRECT_FRAMES)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_CORRECT;
+ }
+ else if(vt == AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT;
+ }
+ else if(vt == AIRPCAP_VT_UNKNOWN)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN;
+ }
+ return NULL;
+}
+
+/*
+ * Returns the AirpcapLinkType corresponding to the given string name.
+ */
+AirpcapLinkType
+airpcap_get_link_type(const gchar* name)
+{
+ if(!(g_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_ONLY,name)))
+ {
+ return AIRPCAP_LT_802_11;
+ }
+ else if(!(g_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO,name)))
+ {
+ return AIRPCAP_LT_802_11_PLUS_RADIO;
+ }
+ else
+ {
+ return AIRPCAP_LT_UNKNOWN;
+ }
+}
+
+/*
+ * Returns the string name corresponding to the given AirpcapLinkType, or
+ * NULL in case of error.
+ */
+gchar*
+airpcap_get_link_name(AirpcapLinkType lt)
+{
+ if(lt == AIRPCAP_LT_802_11)
+ {
+ return AIRPCAP_LINK_TYPE_NAME_802_11_ONLY;
+ }
+ else if(lt == AIRPCAP_LT_802_11_PLUS_RADIO)
+ {
+ return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO;
+ }
+ else if(lt == AIRPCAP_LT_UNKNOWN)
+ {
+ return AIRPCAP_LINK_TYPE_NAME_UNKNOWN;
+ }
+ return NULL;
+}
+
+/*
+ * Sets the entry of the link type combo using the AirpcapLinkType.
+ */
+void
+airpcap_link_type_combo_set_by_type(GtkWidget* c, AirpcapLinkType type)
+{
+gchar* s;
+
+s = airpcap_get_link_name(type);
+gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(c)->entry),s);
+}
+
+/*
+ * Retrieves the name in link type the combo entry.
+ */
+AirpcapLinkType
+airpcap_link_type_combo_get_type(GtkWidget* c)
+{
+const gchar* s;
+
+s = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(c)->entry));
+
+return airpcap_get_link_type(s);
+}
+
+/*
+ * Sets the entry of the validation combo using the AirpcapValidationType.
+ */
+void
+airpcap_validation_type_combo_set_by_type(GtkWidget* c, AirpcapValidationType type)
+{
+const gchar* s;
+
+s = airpcap_get_validation_name(type);
+gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(c)->entry),s);
+}
+
+/*
+ * Retrieves the name in the validation combo entry.
+ */
+AirpcapValidationType
+airpcap_validation_type_combo_get_type(GtkWidget* c)
+{
+const gchar* s;
+
+s = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(c)->entry));
+
+return airpcap_get_validation_type(s);
+}
+
+/*
+ * Retrieve the UINT corresponding to the given string (channel only, handle with care!)
+ */
+UINT
+airpcap_get_channel_number(const gchar* s)
+{
+int ch_num;
+
+sscanf(s,"%d",&ch_num);
+
+/* XXX - check for ch_num btween 1-14, and return -1 otherwise??? */
+
+return ch_num;
+}
+
+/*
+ * Returns the string corresponding to the given UINT (1-14, for channel only)
+ */
+gchar*
+airpcap_get_channel_name(UINT n)
+{
+return g_strdup_printf("%d",n);
+}
+
+/*
+ * Set the combo box entry string given an UINT channel number
+ */
+void
+airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel)
+{
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),airpcap_get_channel_name(channel));
+}
+
+#endif /* HAVE_AIRPCAP */
diff --git a/gtk/airpcap_gui_utils.h b/gtk/airpcap_gui_utils.h
new file mode 100755
index 0000000000..b69fa48f31
--- /dev/null
+++ b/gtk/airpcap_gui_utils.h
@@ -0,0 +1,127 @@
+/* airpcap_utils.h
+ * Declarations of utility routines for the "Airpcap" dialog widgets
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __AIRPCAP_GUI_UTILS_H__
+#define __AIRPCAP_GUI_UTILS_H__
+
+#define AIRPCAP_VALIDATION_TYPE_NAME_ALL "All Frames"
+#define AIRPCAP_VALIDATION_TYPE_NAME_CORRECT "Valid Frames"
+#define AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT "Invalid Frames"
+#define AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN "Unknown"
+
+#define AIRPCAP_LINK_TYPE_NAME_802_11_ONLY "802.11 Only"
+#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO "802.11 + Radio"
+#define AIRPCAP_LINK_TYPE_NAME_UNKNOWN "Unknown"
+
+/*
+ * set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info);
+
+/*
+ * Set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info);
+
+/*
+ * Add a key (string) to the given list
+ */
+void
+airpcap_add_key_to_list(GtkWidget *keylist, gchar* s);
+
+/*
+ * Fill the list with the keys
+ */
+void
+airpcap_fill_key_list(GtkWidget *keylist,airpcap_if_info_t* if_info);
+
+/*
+ * Function used to retrieve the AirpcapValidationType given the string name.
+ */
+AirpcapValidationType
+airpcap_get_validation_type(const gchar* name);
+
+/*
+ * Function used to retrieve the string name given an AirpcapValidationType.
+ */
+gchar*
+airpcap_get_validation_name(AirpcapValidationType vt);
+
+/*
+ * Returns the AirpcapLinkType corresponding to the given string name.
+ */
+AirpcapLinkType
+airpcap_get_link_type(const gchar* name);
+
+/*
+ * Returns the string name corresponding to the given AirpcapLinkType.
+ */
+gchar*
+airpcap_get_link_name(AirpcapLinkType lt);
+
+/*
+ * Sets the entry of the link type combo using the AirpcapLinkType.
+ */
+void
+airpcap_link_type_combo_set_by_type(GtkWidget* c, AirpcapLinkType type);
+
+/*
+ * Retrieves the name in link type the combo entry.
+ */
+AirpcapLinkType
+airpcap_link_type_combo_get_type(GtkWidget* c);
+
+/*
+ * Sets the entry of the validation combo using the AirpcapValidationType.
+ */
+void
+airpcap_validation_type_combo_set_by_type(GtkWidget* c,AirpcapValidationType type);
+
+/*
+ * Retrieves the name in the validation combo entry.
+ */
+AirpcapValidationType
+airpcap_validation_type_combo_get_type(GtkWidget* c);
+
+/*
+ * Returns the string corresponding to the given UINT (1-14, for channel only)
+ */
+UINT
+airpcap_get_channel_number(const gchar* s);
+
+/*
+ * Retrieve the UINT corresponding to the given string (channel only, handle with care!)
+ */
+gchar*
+airpcap_get_channel_name(UINT n);
+
+/*
+ * Set the combo box entry string given an UINT channel number
+ */
+void
+airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel);
+
+#endif
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 1d4c35ce04..d940d2a854 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -61,6 +61,15 @@
#include "capture-wpcap.h"
#endif
+#include "keys.h"
+
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+#endif
+
/* Capture callback data keys */
#define E_CAP_IFACE_KEY "cap_iface"
#define E_CAP_IFACE_IP_KEY "cap_iface_ip"
@@ -114,7 +123,6 @@
*/
static GtkWidget *cap_open_w;
-
static void
capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
@@ -138,6 +146,10 @@ capture_dlg_prep(gpointer parent_w);
void
capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
{
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
+
capture_stop(capture_opts);
}
@@ -145,6 +157,10 @@ capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
void
capture_restart_cb(GtkWidget *w _U_, gpointer d _U_)
{
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+#endif
+
capture_restart(capture_opts);
}
@@ -173,12 +189,31 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
int ips = 0;
GSList *curr_ip;
if_addr_t *ip_addr;
+#ifdef HAVE_AIRPCAP
+ GtkWidget *advanced_bt;
+#endif
lt_menu = gtk_menu_new();
entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
if_text = g_strstrip(entry_text);
if_name = get_if_name(if_text);
+#ifdef HAVE_AIRPCAP
+ /* is it an airpcap interface??? */
+ /* retrieve the advanced button pointer */
+ advanced_bt = OBJECT_GET_DATA(entry,AIRPCAP_OPTIONS_ADVANCED_KEY);
+ airpcap_if_selected = get_airpcap_if_by_name(airpcap_if_list,if_name);
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ if( airpcap_if_selected != NULL)
+ {
+ gtk_widget_set_sensitive(advanced_bt,TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(advanced_bt,FALSE);
+ }
+#endif
+
/*
* If the interface name is in the list of known interfaces, get
* its list of link-layer types and set the option menu to display it.
@@ -482,6 +517,24 @@ guint32 value)
}
}
+#ifdef HAVE_AIRPCAP
+/*
+ * Sets the toolbar before calling the advanced dialog with for the right interface
+ */
+void
+options_airpcap_advanced_cb(GtkWidget *w _U_, gpointer d _U_)
+{
+int *from_widget;
+
+from_widget = (gint*)g_malloc(sizeof(gint));
+*from_widget = AIRPCAP_ADVANCED_FROM_OPTIONS;
+OBJECT_SET_DATA(airpcap_tb,AIRPCAP_ADVANCED_FROM_KEY,from_widget);
+
+airpcap_if_active = airpcap_if_selected;
+gtk_widget_set_sensitive(airpcap_tb,FALSE);
+display_airpcap_advanced_cb(w,d);
+}
+#endif
/* show capture prepare (options) dialog */
void
@@ -497,6 +550,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
*snap_hb, *snap_cb, *snap_sb, *snap_lb,
*promisc_cb,
*filter_hb, *filter_bt, *filter_te, *filter_cm,
+ *advanced_hb,
*file_fr, *file_vb,
*file_hb, *file_bt, *file_lb, *file_te,
@@ -517,7 +571,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
*resolv_fr, *resolv_vb,
*m_resolv_cb, *n_resolv_cb, *t_resolv_cb,
*bbox, *ok_bt, *cancel_bt,
- *help_bt;
+ *help_bt,
+ *advanced_bt;
#if GTK_MAJOR_VERSION < 2
GtkAccelGroup *accel_group;
#endif
@@ -537,6 +592,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gchar *cap_title;
gchar *if_device;
+ gint *from_widget = NULL;
+
if (cap_open_w != NULL) {
/* There's already a "Capture Options" dialog box; reactivate it. */
@@ -564,6 +621,22 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
g_free(cant_get_if_list_errstr);
}
+#ifdef HAVE_AIRPCAP
+ /* update airpcap interface list */
+ /* load the airpcap interfaces */
+ airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+
+ if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
+ cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
+ cant_get_if_list_errstr);
+ g_free(cant_get_if_list_errstr);
+ }
+
+ /* select the first ad default (THIS SHOULD BE CHANGED) */
+ airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+#endif
+
/* use user-defined title if preference is set */
cap_title = create_user_window_title("Wireshark: Capture Options");
@@ -611,6 +684,13 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
capture_opts->iface = g_strdup(get_if_name(if_device));
g_free(if_device);
}
+
+#ifdef HAVE_AIRPCAP
+ /* get the airpcap interface (if it IS an airpcap interface, and update the
+ toolbar... and of course enable the advanced button...)*/
+ airpcap_if_selected = get_airpcap_if_by_name(airpcap_if_list,capture_opts->iface);
+#endif
+
if (capture_opts->iface != NULL) {
if_device = build_capture_combo_name(if_list, capture_opts->iface);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_device);
@@ -681,7 +761,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0);
buffer_size_lb = gtk_label_new("megabyte(s)");
- gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 6);
#endif
/* Promiscuous mode row */
@@ -767,6 +847,40 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
/* let an eventually capture filters dialog know the text entry to fill in */
OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
+ /* advanced row */
+ advanced_hb = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(capture_vb), advanced_hb, FALSE, FALSE, 0);
+ advanced_bt = gtk_button_new();
+
+ /* set the text */
+ #if GTK_MAJOR_VERSION >= 2
+ /* XXX - find a way to set the GtkButton label in GTK 1.x */
+ gtk_button_set_label(GTK_BUTTON(advanced_bt), "Wireless Settings");
+ #else
+ /* Set the GtkButton label in GTK 1.x */
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(advanced_bt)->child), "Wireless Settings");
+ #endif
+
+#ifdef HAVE_AIRPCAP
+ /* Both the callback and the data are global */
+ SIGNAL_CONNECT(advanced_bt,"clicked",options_airpcap_advanced_cb,airpcap_tb);
+ OBJECT_SET_DATA(GTK_ENTRY(GTK_COMBO(if_cb)->entry),AIRPCAP_OPTIONS_ADVANCED_KEY,advanced_bt);
+
+ if(airpcap_if_selected != NULL)
+ {
+ /* It is an airpcap interface */
+ gtk_widget_set_sensitive(advanced_bt,TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(advanced_bt,FALSE);
+ }
+#endif
+
+ gtk_box_pack_start(GTK_BOX(linktype_hb),advanced_bt,FALSE,FALSE,0);
+ gtk_widget_show(advanced_bt);
+ gtk_widget_show(advanced_hb);
+
/* Capture file-related options frame */
file_fr = gtk_frame_new("Capture File(s)");
gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
@@ -1236,6 +1350,11 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
{
gpointer dialog;
+#ifdef HAVE_AIRPCAP
+ airpcap_if_active = airpcap_if_selected;
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+#endif
+
#ifdef _WIN32
/* Is WPcap loaded? */
if (!has_wpcap) {
@@ -1548,6 +1667,11 @@ capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
/* Note that we no longer have a "Capture Options" dialog box. */
cap_open_w = NULL;
+
+#ifdef HAVE_AIRPCAP
+ /* update airpcap toolbar */
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
}
/* user changed the interface entry */
@@ -1555,7 +1679,6 @@ static void
capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
{
GtkWidget *linktype_om = argp;
-
set_link_type_list(linktype_om, entry);
}
diff --git a/gtk/capture_dlg.h b/gtk/capture_dlg.h
index 3d20ff2993..caf536cea4 100644
--- a/gtk/capture_dlg.h
+++ b/gtk/capture_dlg.h
@@ -26,6 +26,8 @@
#ifndef __CAPTURE_DLG_H__
#define __CAPTURE_DLG_H__
+extern GtkWidget* airpcap_tb;
+
/** @file
* "Capture Options" dialog box.
* @ingroup dialog_group
@@ -70,6 +72,14 @@ void capture_start_confirmed(void);
void
capture_if_cb(GtkWidget *widget, gpointer data);
+/** User requested the "Capture Airpcap" dialog box by menu or toolbar.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
+void
+capture_air_cb(GtkWidget *widget, gpointer data);
+
/** User requested the "Capture Interfaces" dialog box by menu or toolbar.
*
* @param capture_in_progress capture is in progress
diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c
index 279b3bb8e5..e4ce712bb2 100644
--- a/gtk/capture_if_dlg.c
+++ b/gtk/capture_if_dlg.c
@@ -48,14 +48,37 @@
#include "capture_dlg.h"
#include "capture_if_details_dlg.h"
#include "capture_errs.h"
+#include "recent.h"
+#include <epan/prefs.h>
#include "gui_utils.h"
#include "dlg_utils.h"
-#include "wtap.h"
#include "main.h"
+#include "wtap.h"
#include "help_dlg.h"
#include "toolbar.h"
+#include "keys.h"
+
+#include "webbrowser.h"
+
+#ifdef HAVE_AIRPCAP
+#include "../image/toolbar/capture_airpcap_16.xpm"
+#endif
+#include "../image/toolbar/capture_ethernet_16.xpm"
+
+/* new buttons to be used instead of labels for 'Capture','Prepare',' */
+#include "../image/toolbar/capture_capture_16.xpm"
+#include "../image/toolbar/capture_prepare_16.xpm"
+#include "../image/toolbar/capture_details_16.xpm"
+
+
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+#endif
/*
* Keep a static pointer to the current "Capture Interfaces" window, if
@@ -63,7 +86,7 @@
* already a "Capture Interfaces" window up, we just pop up the existing
* one, rather than creating a new one.
*/
-static GtkWidget *cap_if_w;
+static GtkWidget *cap_if_w, *cap_air_w;
GList *if_data = NULL;
@@ -103,7 +126,12 @@ void update_if(if_dlg_data_t *if_dlg_data);
static void
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
{
- if_dlg_data_t *if_dlg_data = if_data;
+if_dlg_data_t *if_dlg_data = if_data;
+
+#ifdef HAVE_AIRPCAP
+airpcap_if_active = get_airpcap_if_from_description(airpcap_if_list, GTK_LABEL(if_dlg_data->descr_lb)->label);
+airpcap_if_selected = airpcap_if_active;
+#endif
if (capture_opts->iface)
g_free(capture_opts->iface);
@@ -219,7 +247,7 @@ update_if(if_dlg_data_t *if_dlg_data)
#else
diff = stats.ps_recv;
if_dlg_data->last_packets = stats.ps_recv + if_dlg_data->last_packets;
-#endif
+#endif
str = g_strdup_printf("%u", if_dlg_data->last_packets);
gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str);
@@ -277,13 +305,13 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
if(cap_if_w) {
gtk_widget_set_sensitive(stop_bt, capture_in_progress);
-
+
for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
if_dlg_data_t *if_dlg_data = curr->data;
gtk_widget_set_sensitive(if_dlg_data->capture_bt, !capture_in_progress);
gtk_widget_set_sensitive(if_dlg_data->prepare_bt, !capture_in_progress);
- }
+ }
}
}
@@ -310,14 +338,65 @@ capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
/* Note that we no longer have a "Capture Options" dialog box. */
cap_if_w = NULL;
+
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
}
+GtkWidget*
+combo_channel_new(void)
+{
+ GtkWidget* channel_cb;
+ GList* popdown;
+
+
+ channel_cb = gtk_combo_new();
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cb)->entry), "1");
+
+ popdown = NULL;
+
+ popdown = g_list_append(popdown, "1");
+ popdown = g_list_append(popdown, "2");
+ popdown = g_list_append(popdown, "3");
+ popdown = g_list_append(popdown, "4");
+ popdown = g_list_append(popdown, "5");
+ popdown = g_list_append(popdown, "6");
+ popdown = g_list_append(popdown, "7");
+ popdown = g_list_append(popdown, "8");
+ popdown = g_list_append(popdown, "9");
+ popdown = g_list_append(popdown, "10");
+ popdown = g_list_append(popdown, "11");
+ popdown = g_list_append(popdown, "12");
+ popdown = g_list_append(popdown, "13");
+ popdown = g_list_append(popdown, "14");
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(channel_cb), popdown) ;
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(channel_cb),
+ 45,
+ 10 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(channel_cb),
+ 45,
+ 10 );
+ #endif
+
+
+ return channel_cb;
+}
/* start getting capture stats from all interfaces */
void
capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
{
- GtkWidget *main_vb, *main_sw, *bbox, *close_bt, *help_bt;
+ GtkWidget *main_vb,
+ *main_sw,
+ *bbox,
+ *close_bt,
+ *help_bt,
+ *icon;
GtkWidget *if_tb;
GtkWidget *if_lb;
@@ -357,6 +436,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
}
#endif
+ /* LOAD THE INTERFACES */
if_list = get_interface_list(&err, err_str);
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
@@ -366,6 +446,37 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
return;
}
+#ifdef HAVE_AIRPCAP
+ /* LOAD AIRPCAP INTERFACES */
+ /* load the airpcap interfaces */
+ airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+
+ if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
+ cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
+ cant_get_if_list_errstr);
+ g_free(cant_get_if_list_errstr);
+ }
+
+ /* If no airpcap interface is present, gray everything */
+ if(airpcap_if_active == NULL)
+ {
+ if(airpcap_if_list == NULL)
+ {
+ /*No airpcap device found */
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ }
+ else
+ {
+ /* default adapter is not airpcap... or is airpcap but is not found*/
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ }
+ }
+
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+#endif
+
cap_if_w = window_new(GTK_WINDOW_TOPLEVEL, "Wireshark: Capture Interfaces");
tooltips = gtk_tooltips_new();
@@ -387,7 +498,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(main_sw), main_vb);
- if_tb = gtk_table_new(6,1, FALSE);
+ if_tb = gtk_table_new(1,9, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3);
gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3);
gtk_box_pack_start(GTK_BOX(main_vb), if_tb, FALSE, FALSE, 0);
@@ -395,6 +506,10 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
row = 0;
height = 0;
+ /* This is the icon column, used to display which kind of interface we have */
+ if_lb = gtk_label_new("");
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
+
#ifndef _WIN32
/*
* On Windows, device names are generally not meaningful - NT 5
@@ -402,28 +517,28 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
* bother showing them.
*/
if_lb = gtk_label_new("Device");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1);
#endif
if_lb = gtk_label_new("Description");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1);
if_lb = gtk_label_new(" IP ");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1);
if_lb = gtk_label_new("Packets");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
if_lb = gtk_label_new(" Packets/s ");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 5, 6, row, row+1);
stop_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_STOP);
- gtk_tooltips_set_tip(tooltips, stop_bt,
+ gtk_tooltips_set_tip(tooltips, stop_bt,
"Stop a running capture.", NULL);
#ifdef _WIN32
- gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 5, 8, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 9, row, row+1);
#else
- gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 5, 7, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 8, row, row+1);
#endif
SIGNAL_CONNECT(stop_bt, "clicked", capture_stop_cb, NULL);
@@ -436,12 +551,25 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
if_info = curr->data;
if_dlg_data = g_malloc0(sizeof(if_dlg_data_t));
+
+ /* Kind of adaptor (icon) */
+#ifdef HAVE_AIRPCAP
+ if(get_airpcap_if_from_description(airpcap_if_list,if_info->description) != NULL)
+ icon = xpm_to_widget(capture_airpcap_16_xpm);
+ else
+ icon = xpm_to_widget(capture_ethernet_16_xpm);
+#else
+ icon = xpm_to_widget(capture_ethernet_16_xpm);
+#endif
+
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 0, 1, row, row+1);
+
/* device name */
if_dlg_data->device_lb = gtk_label_new(if_info->name);
if_dlg_data->device = if_info->name;
#ifndef _WIN32
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 0, 1, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 1, 2, row, row+1);
#endif
g_string_append(if_tool_str, "Device: ");
g_string_append(if_tool_str, if_info->name);
@@ -453,7 +581,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
else
if_dlg_data->descr_lb = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 1, 2, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 2, 3, row, row+1);
if (if_info->description) {
g_string_append(if_tool_str, "Description: ");
@@ -489,40 +617,41 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
g_string_append(if_tool_str, "unknown");
}
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->ip_lb, 2, 3, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->ip_lb, 3, 4, row, row+1);
g_string_append(if_tool_str, "\n");
/* packets */
if_dlg_data->curr_lb = gtk_label_new("-");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 3, 4, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 4, 5, row, row+1);
/* packets/s */
if_dlg_data->last_lb = gtk_label_new("-");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 4, 5, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 5, 6, row, row+1);
/* capture button */
if_dlg_data->capture_bt = gtk_button_new_with_label("Capture");
- SIGNAL_CONNECT(if_dlg_data->capture_bt, "clicked", capture_do_cb, if_dlg_data);
+ SIGNAL_CONNECT(if_dlg_data->capture_bt, "clicked", capture_do_cb, if_dlg_data);
tmp_str = g_strdup_printf("Immediately start a capture from this interface:\n\n%s", if_tool_str->str);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt,
+ gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt,
tmp_str, NULL);
g_free(tmp_str);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 5, 6, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 6, 7, row, row+1);
/* prepare button */
if_dlg_data->prepare_bt = gtk_button_new_with_label("Prepare");
SIGNAL_CONNECT(if_dlg_data->prepare_bt, "clicked", capture_prepare_cb, if_dlg_data);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt,
+ gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt,
"Open the capture options dialog with this interface selected.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 6, 7, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 7, 8, row, row+1);
/* details button */
#ifdef _WIN32
if_dlg_data->details_bt = gtk_button_new_with_label("Details");
- SIGNAL_CONNECT(if_dlg_data->details_bt, "clicked", capture_details_cb, if_dlg_data);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->details_bt,
+ gtk_container_add (GTK_CONTAINER (if_dlg_data->details_bt), xpm_box(capture_details_16_xpm));
+ SIGNAL_CONNECT(if_dlg_data->details_bt, "clicked", capture_details_cb, if_dlg_data);
+ gtk_tooltips_set_tip(tooltips, if_dlg_data->details_bt,
"Open the capture details dialog of this interface.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 7, 8, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 8, 9, row, row+1);
#endif
open_if(if_info->name, if_dlg_data);
@@ -558,7 +687,8 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_widget_size_request(GTK_WIDGET(close_bt), &requisition);
/* height + static offset + what GTK-Wimp needs in addition per interface */
- height += requisition.height + 26 + ifs;
+ /* XXX - Modify or the window will become huge with many interfaces! */
+ height += requisition.height + 26 + 16;
gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
gtk_widget_grab_default(close_bt);
diff --git a/gtk/capture_info_dlg.c b/gtk/capture_info_dlg.c
index 65628aaf3d..090fc0782a 100644
--- a/gtk/capture_info_dlg.c
+++ b/gtk/capture_info_dlg.c
@@ -45,6 +45,13 @@
#include "main.h"
#include "capture-pcap-util.h"
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+#endif
+
/* a single capture counter value (with title, pointer to value and GtkWidgets) */
/* as the packet_counts is a struct, not an array, keep a pointer to the */
@@ -78,6 +85,10 @@ pct(gint num, gint denom) {
static gboolean
capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data _U_) {
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
+
capture_stop(capture_opts);
return TRUE;
}
diff --git a/gtk/compat_macros.h b/gtk/compat_macros.h
index 29be9359a8..a7fe7ef6b5 100644
--- a/gtk/compat_macros.h
+++ b/gtk/compat_macros.h
@@ -187,6 +187,7 @@ gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), name)
#ifdef HAVE_LIBPCAP
#define WIRESHARK_STOCK_CAPTURE_INTERFACES "Interfaces"
+#define WIRESHARK_STOCK_CAPTURE_AIRPCAP "Airpcap"
#define WIRESHARK_STOCK_CAPTURE_OPTIONS "Options"
#define WIRESHARK_STOCK_CAPTURE_START "Start"
#define WIRESHARK_STOCK_CAPTURE_STOP "Stop"
@@ -320,6 +321,7 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
#ifdef HAVE_LIBPCAP
#define WIRESHARK_STOCK_LABEL_CAPTURE_INTERFACES "_Interfaces"
+#define WIRESHARK_STOCK_LABEL_CAPTURE_AIRPCAP "_Wireless"
#define WIRESHARK_STOCK_LABEL_CAPTURE_OPTIONS "_Options"
#define WIRESHARK_STOCK_LABEL_CAPTURE_START "_Start"
#define WIRESHARK_STOCK_LABEL_CAPTURE_STOP "S_top"
@@ -358,6 +360,7 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
#ifdef HAVE_LIBPCAP
#define WIRESHARK_STOCK_CAPTURE_INTERFACES "Wireshark_Stock_CaptureInterfaces"
+#define WIRESHARK_STOCK_CAPTURE_AIRPCAP "Wireshark_Stock_CaptureAirpcap"
#define WIRESHARK_STOCK_CAPTURE_OPTIONS "Wireshark_Stock_CaptureOptionss"
#define WIRESHARK_STOCK_CAPTURE_START "Wireshark_Stock_CaptureStart"
#define WIRESHARK_STOCK_CAPTURE_STOP "Wireshark_Stock_CaptureStop"
diff --git a/gtk/gui_utils.c b/gtk/gui_utils.c
index e5e3b4a280..891e77f4e3 100644
--- a/gtk/gui_utils.c
+++ b/gtk/gui_utils.c
@@ -573,6 +573,26 @@ GtkWidget *xpm_to_widget(const char ** xpm) {
return xpm_to_widget_from_parent(top_level, xpm);
}
+/* Create a new hbox with an image packed into it
+ * and return the box. */
+GtkWidget *xpm_box( gchar **xpm )
+{
+ GtkWidget *box;
+ GtkWidget *image;
+
+ /* Create box for image */
+ box = gtk_hbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 3);
+
+ /* Now on to the image stuff */
+ image = xpm_to_widget (xpm);
+
+ /* Pack the image into the box */
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
+
+ return box;
+}
+
/* Set the name of the top-level window and its icon to the specified
string. */
diff --git a/gtk/gui_utils.h b/gtk/gui_utils.h
index 017c31a2f1..5e413b4433 100644
--- a/gtk/gui_utils.h
+++ b/gtk/gui_utils.h
@@ -291,6 +291,14 @@ extern GtkWidget *xpm_to_widget(const char ** xpm);
*/
extern GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm);
+/** Create a new hbox with an image packed into it
+ * and return the box.
+ *
+ * @param xpm the character array containing the picture
+ * @return a newly created GtkHBox containing the picture
+ */
+GtkWidget *xpm_box( gchar **xpm );
+
/** Copy a GString to the clipboard.
*
* @param str GString that is to be copied to the clipboard.
diff --git a/gtk/keys.h b/gtk/keys.h
index 9c150757bf..9df70b4214 100644
--- a/gtk/keys.h
+++ b/gtk/keys.h
@@ -29,22 +29,54 @@
* Various keys for OBJECT_SET_DATA().
*/
-#define E_DFILTER_TE_KEY "display_filter_entry"
-#define E_RFILTER_TE_KEY "read_filter_te"
-#define E_MPACKET_LIST_KEY "menu_packet_list"
-#define E_MPACKET_LIST_ROW_KEY "menu_packet_list_row"
-#define E_MPACKET_LIST_COL_KEY "menu_packet_list_col"
-
-#define PRINT_CMD_LB_KEY "printer_command_label"
-#define PRINT_CMD_TE_KEY "printer_command_entry"
-#define PRINT_FILE_BT_KEY "printer_file_button"
-#define PRINT_FILE_TE_KEY "printer_file_entry"
-
-#define PLUGINS_DFILTER_TE "plugins_dfilter_te"
-
-#define PM_MENU_LIST_KEY "popup_menu_menu_list"
-#define PM_PACKET_LIST_KEY "popup_menu_packet_list"
-#define PM_TREE_VIEW_KEY "popup_menu_tree_view"
-#define PM_HEXDUMP_KEY "popup_menu_hexdump"
+#define E_DFILTER_TE_KEY "display_filter_entry"
+#define E_RFILTER_TE_KEY "read_filter_te"
+#define E_MPACKET_LIST_KEY "menu_packet_list"
+#define E_MPACKET_LIST_ROW_KEY "menu_packet_list_row"
+#define E_MPACKET_LIST_COL_KEY "menu_packet_list_col"
+
+#define PRINT_CMD_LB_KEY "printer_command_label"
+#define PRINT_CMD_TE_KEY "printer_command_entry"
+#define PRINT_FILE_BT_KEY "printer_file_button"
+#define PRINT_FILE_TE_KEY "printer_file_entry"
+
+#define PLUGINS_DFILTER_TE "plugins_dfilter_te"
+
+#define PM_MENU_LIST_KEY "popup_menu_menu_list"
+#define PM_PACKET_LIST_KEY "popup_menu_packet_list"
+#define PM_TREE_VIEW_KEY "popup_menu_tree_view"
+#define PM_HEXDUMP_KEY "popup_menu_hexdump"
+
+#ifdef HAVE_AIRPCAP
+#define AIRPCAP_TOOLBAR_KEY "airpcap_toolbar_key"
+#define AIRPCAP_TOOLBAR_INTERFACE_KEY "airpcap_toolbar_if_key"
+#define AIRPCAP_TOOLBAR_LINK_TYPE_KEY "airpcap_toolbar_lt_key"
+#define AIRPCAP_TOOLBAR_CHANNEL_KEY "airpcap_toolbar_ch_key"
+#define AIRPCAP_TOOLBAR_CRC_KEY "airpcap_toolbar_crc_key"
+#define AIRPCAP_TOOLBAR_WRONG_CRC_KEY "airpcap_toolbar_wcrc_key"
+#define AIRPCAP_TOOLBAR_ADVANCED_KEY "airpcap_toolbar_advanced_key"
+#define AIRPCAP_TOOLBAR_DECRYPTION_KEY "airpcap_toolbar_decryption_key"
+
+#define AIRPCAP_ADVANCED_KEY "airpcap_advanced_key"
+#define AIRPCAP_ADVANCED_INTERFACE_KEY "airpcap_advanced_if_key"
+#define AIRPCAP_ADVANCED_LINK_TYPE_KEY "airpcap_advanced_lt_key"
+#define AIRPCAP_ADVANCED_CHANNEL_KEY "airpcap_advanced_ch_key"
+#define AIRPCAP_ADVANCED_CRC_KEY "airpcap_advanced_crc_key"
+#define AIRPCAP_ADVANCED_WRONG_CRC_KEY "airpcap_advanced_wcrc_key"
+#define AIRPCAP_ADVANCED_BLINK_KEY "airpcap_advanced_blink_key"
+#define AIRPCAP_ADVANCED_CANCEL_KEY "airpcap_advanced_cancel_key"
+#define AIRPCAP_ADVANCED_OK_KEY "airpcap_advanced_ok_key"
+#define AIRPCAP_ADVANCED_KEYLIST_KEY "airpcap_advanced_keylist_key"
+#define AIRPCAP_ADVANCED_ADD_KEY_TEXT_KEY "airpcap_advanced_add_key_text_key"
+#define AIRPCAP_ADVANCED_ADD_KEY_OK_KEY "airpcap_advanced_add_key_ok_key"
+#define AIRPCAP_ADVANCED_EDIT_KEY_TEXT_KEY "airpcap_advanced_edit_key_text_key"
+#define AIRPCAP_ADVANCED_EDIT_KEY_OK_KEY "airpcap_advanced_edit_key_ok_key"
+#define AIRPCAP_ADVANCED_EDIT_KEY_LABEL_KEY "airpcap_advanced_edit_key_label_key"
+#define AIRPCAP_ADVANCED_DECRYPTION_KEY "airpcap_advanced_decryption_key"
+
+#define AIRPCAP_OPTIONS_ADVANCED_KEY "airpcap_options_advanced_key"
+
+#define AIRPCAP_ADVANCED_FROM_KEY "airpcap_advanced_name_key"
+#endif
#endif
diff --git a/gtk/main.c b/gtk/main.c
index 40d6d2bee3..4f63e8b5db 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -153,6 +153,16 @@
#include "../image/wsiconcap32.xpm"
#include "../image/wsiconcap48.xpm"
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_dlg.h"
+#include "airpcap_gui_utils.h"
+
+#include "./gtk/toolbar.h"
+
+#include "./image/toolbar/wep_closed_24.xpm"
+#endif
/*
* Files under personal and global preferences directories in which
@@ -173,6 +183,11 @@ static GtkWidget *main_pane_v1, *main_pane_v2, *main_pane_h1, *main_pane_h2;
static GtkWidget *main_first_pane, *main_second_pane;
static GtkWidget *status_pane;
static GtkWidget *menubar, *main_vbox, *main_tb, *pkt_scrollw, *stat_hbox, *filter_tb;
+
+#ifdef HAVE_AIRPCAP
+GtkWidget *airpcap_tb;
+#endif
+
static GtkWidget *info_bar;
static GtkWidget *packets_bar = NULL;
static GtkWidget *welcome_pane;
@@ -195,6 +210,7 @@ capture_options global_capture_opts;
capture_options *capture_opts = &global_capture_opts;
#endif
+gboolean block_toolbar_signals = FALSE;
static void create_main_window(gint, gint, gint, e_prefs*);
static void show_main_window(gboolean);
@@ -204,8 +220,6 @@ static void main_save_window_geometry(GtkWidget *widget);
#define E_DFILTER_CM_KEY "display_filter_combo"
#define E_DFILTER_FL_KEY "display_filter_list"
-
-
/* Match selected byte pattern */
static void
match_selected_cb_do(gpointer data, int action, gchar *text)
@@ -431,7 +445,7 @@ match_selected_plist_cb(GtkWidget *w _U_, gpointer data, MATCH_SELECTED_E action
}
/* This function allows users to right click in the details window and copy the text
- * information to the operating systems clipboard.
+ * information to the operating systems clipboard.
*
* We first check to see if a string representation is setup in the tree and then
* read the string. If not available then we try to grab the value. If all else
@@ -1993,6 +2007,11 @@ main(int argc, char *argv[])
int optind_initial;
int status;
+#ifdef HAVE_AIRPCAP
+ char err_str[AIRPCAP_ERRBUF_SIZE];
+ gchar *cant_get_if_list_errstr;
+#endif
+
#define OPTSTRING_INIT "a:b:c:Df:g:Hhi:klLm:nN:o:pQr:R:Ss:t:vw:X:y:z:"
#if defined HAVE_LIBPCAP && defined _WIN32
@@ -2244,6 +2263,31 @@ main(int argc, char *argv[])
/* Read the preference files. */
prefs = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
&pf_open_errno, &pf_read_errno, &pf_path);
+
+#ifdef HAVE_AIRPCAP
+ /* Load the airpcap.dll */
+ if(!load_airpcap())
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","Failed to load airpcap.dll\nMake sure you have the right airpcap.dll installed!");
+ airpcap_if_active = NULL;
+ }
+ else
+ {
+ /* load the airpcap interfaces */
+ airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+
+ if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
+ cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
+ cant_get_if_list_errstr);
+ g_free(cant_get_if_list_errstr);
+ }
+
+ /* select the first ad default (THIS SHOULD BE CHANGED) */
+ airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+ }
+#endif
+
if (gpf_path != NULL) {
if (gpf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
@@ -3105,6 +3149,11 @@ void main_widgets_rearrange(void) {
gtk_widget_ref(menubar);
gtk_widget_ref(main_tb);
gtk_widget_ref(filter_tb);
+
+#ifdef HAVE_AIRPCAP
+ gtk_widget_ref(airpcap_tb);
+#endif
+
gtk_widget_ref(pkt_scrollw);
gtk_widget_ref(tv_scrollw);
gtk_widget_ref(byte_nb_ptr);
@@ -3138,6 +3187,11 @@ void main_widgets_rearrange(void) {
gtk_box_pack_start(GTK_BOX(main_vbox), filter_tb, FALSE, TRUE, 1);
}
+#ifdef HAVE_AIRPCAP
+ /* airpcap toolbar */
+ gtk_box_pack_start(GTK_BOX(main_vbox), airpcap_tb, FALSE, TRUE, 1);
+#endif
+
/* fill the main layout panes */
switch(prefs.gui_layout_type) {
case(layout_type_5):
@@ -3209,6 +3263,11 @@ void main_widgets_rearrange(void) {
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_tb, FALSE, TRUE, 1);
}
+#ifdef HAVE_AIRPCAP
+ /* airpcap toolbar */
+ gtk_box_pack_start(GTK_BOX(main_vbox), airpcap_tb, FALSE, TRUE, 1);
+#endif
+
/* statusbar */
gtk_box_pack_start(GTK_BOX(stat_hbox), status_pane, TRUE, TRUE, 0);
gtk_paned_pack1(GTK_PANED(status_pane), info_bar, FALSE, FALSE);
@@ -3412,6 +3471,14 @@ main_widgets_show_or_hide(void)
gtk_widget_hide(filter_tb);
}
+#ifdef HAVE_AIRPCAP
+ if (recent.airpcap_toolbar_show) {
+ gtk_widget_show(airpcap_tb);
+ } else {
+ gtk_widget_hide(airpcap_tb);
+ }
+#endif
+
if (recent.packet_list_show && have_capture_file) {
gtk_widget_show(pkt_scrollw);
} else {
@@ -3479,6 +3546,128 @@ window_state_event_cb (GtkWidget *widget _U_,
}
#endif
+#ifdef HAVE_AIRPCAP
+/*
+ * Changed callback for the channel combobox
+ */
+static void
+airpcap_toolbar_channel_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+const gchar *s;
+int ch_num;
+
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if((data != NULL) && (w != NULL) )
+ {
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+ if((g_strcasecmp("",s)))
+ {
+ sscanf(s,"%d",&ch_num);
+ if(airpcap_if_active != NULL)
+ {
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, airpcap_if_active->description), ebuf);
+
+ if(ad)
+ {
+ airpcap_if_set_device_channel(ad,ch_num);
+ airpcap_if_active->channel = ch_num;
+ airpcap_if_close(ad);
+ }
+ }
+ }
+ }
+}
+#endif
+
+
+#ifdef HAVE_AIRPCAP
+/*
+ * Callback for the wrong crc combo
+ */
+static void
+airpcap_toolbar_wrong_crc_combo_cb(GtkWidget *entry, gpointer user_data)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+
+if( !block_toolbar_signals && (airpcap_if_active != NULL))
+ {
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list,airpcap_if_active->description), ebuf);
+
+ if(ad)
+ {
+ airpcap_if_active->CrcValidationOn = airpcap_get_validation_type(gtk_entry_get_text(GTK_ENTRY(entry)));
+ airpcap_if_set_fcs_validation(ad,airpcap_if_active->CrcValidationOn);
+ /* Save configuration */
+ if(!airpcap_if_store_cur_config_as_adapter_default(ad))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
+ }
+ airpcap_if_close(ad);
+ }
+ }
+}
+#endif
+
+#ifdef HAVE_AIRPCAP
+void
+airpcap_toolbar_encryption_cb(GtkWidget *entry, gpointer user_data)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+
+if( !block_toolbar_signals && (airpcap_if_active != NULL))
+{
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list,airpcap_if_active->description), ebuf);
+
+ if(ad)
+ {
+ if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ {
+ airpcap_if_active->DecryptionOn = AIRPCAP_DECRYPTION_OFF;
+ airpcap_if_set_decryption_state(ad,airpcap_if_active->DecryptionOn);
+ /* Save configuration */
+ if(!airpcap_if_store_cur_config_as_adapter_default(ad))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
+ }
+ airpcap_if_close(ad);
+ }
+ else
+ {
+ airpcap_if_active->DecryptionOn = AIRPCAP_DECRYPTION_ON;
+ airpcap_if_set_decryption_state(ad,airpcap_if_active->DecryptionOn);
+ /* Save configuration */
+ if(!airpcap_if_store_cur_config_as_adapter_default(ad))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
+ }
+ airpcap_if_close(ad);
+ }
+ }
+ }
+}
+#endif
+
+#ifdef HAVE_AIRPCAP
+/*
+ * Callback for the Advanced Wireless Settings button
+ */
+static void
+toolbar_display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
+{
+int *from_widget;
+
+ from_widget = (gint*)g_malloc(sizeof(gint));
+ *from_widget = AIRPCAP_ADVANCED_FROM_TOOLBAR;
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_ADVANCED_FROM_KEY,from_widget);
+
+ display_airpcap_advanced_cb(w,data);
+}
+#endif
static void
create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
@@ -3490,8 +3679,28 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
*filter_reset;
GList *dfilter_list = NULL;
GtkTooltips *tooltips;
+
GtkAccelGroup *accel;
gchar *title;
+
+#ifdef HAVE_AIRPCAP
+ GtkWidget
+ *advanced_bt,
+ *interface_lb,
+ *channel_lb,
+ *channel_cm,
+ *wrong_crc_lb,
+ *encryption_ck,
+ *wrong_crc_cm,
+ *iconw;
+ GList *channel_list = NULL;
+ GList *linktype_list = NULL;
+ GList *link_list = NULL;
+ GtkTooltips *airpcap_tooltips;
+ gchar *if_label_text;
+ gint *from_widget = NULL;
+#endif
+
/* Display filter construct dialog has an Apply button, and "OK" not
only sets our text widget, it activates it (i.e., it causes us to
filter the capture). */
@@ -3511,6 +3720,10 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
tooltips = gtk_tooltips_new();
+#ifdef HAVE_AIRPCAP
+ airpcap_tooltips = gtk_tooltips_new();
+#endif
+
#ifdef _WIN32
#if GTK_MAJOR_VERSION < 2
/* has to be done, after top_level window is created */
@@ -3584,6 +3797,206 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
main_pane_h2 = gtk_hpaned_new();
gtk_widget_show(main_pane_h2);
+#ifdef HAVE_AIRPCAP
+ /* airpcap toolbar */
+#if GTK_MAJOR_VERSION < 2
+ airpcap_tb = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
+ GTK_TOOLBAR_BOTH);
+#else
+ airpcap_tb = gtk_toolbar_new();
+ gtk_toolbar_set_orientation(GTK_TOOLBAR(airpcap_tb),
+ GTK_ORIENTATION_HORIZONTAL);
+#endif /* GTK_MAJOR_VERSION */
+ gtk_widget_show(airpcap_tb);
+
+ /* Interface Label */
+ if(airpcap_if_active != NULL)
+ {
+ if_label_text = g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_active));
+ interface_lb = gtk_label_new(if_label_text);
+ g_free(if_label_text);
+ }
+ else
+ {
+ interface_lb = gtk_label_new("No Wireless Interface Found ");
+ }
+
+ /* Add the label to the toolbar */
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), interface_lb,
+ "Current Wireless Interface", "Private");
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY,interface_lb);
+ gtk_widget_show(interface_lb);
+ gtk_toolbar_insert_space(GTK_TOOLBAR(airpcap_tb),1);
+
+
+ /* Create the "802.11 Channel:" label */
+ channel_lb = gtk_label_new(" 802.11 Channel: ");
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_lb,
+ "Current 802.11 Channel", "Private");
+ gtk_widget_show(channel_lb);
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(channel_lb),
+ 100,
+ 28 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(channel_lb),
+ 100,
+ 28 );
+ #endif
+
+ /* Create the channel combo box */
+ channel_cm = gtk_combo_new();
+ gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(channel_cm)->entry),FALSE);
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY,channel_cm);
+
+ channel_list = g_list_append(channel_list, "1");
+ channel_list = g_list_append(channel_list, "2");
+ channel_list = g_list_append(channel_list, "3");
+ channel_list = g_list_append(channel_list, "4");
+ channel_list = g_list_append(channel_list, "5");
+ channel_list = g_list_append(channel_list, "6");
+ channel_list = g_list_append(channel_list, "7");
+ channel_list = g_list_append(channel_list, "8");
+ channel_list = g_list_append(channel_list, "9");
+ channel_list = g_list_append(channel_list, "10");
+ channel_list = g_list_append(channel_list, "11");
+ channel_list = g_list_append(channel_list, "12");
+ channel_list = g_list_append(channel_list, "13");
+ channel_list = g_list_append(channel_list, "14");
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(channel_cm), channel_list) ;
+
+ gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(channel_cm)->entry),
+ "Change the 802.11 RF channel",
+ NULL);
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(channel_cm),
+ 45,
+ 28 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(channel_cm),
+ 45,
+ 28 );
+ #endif
+
+ if(airpcap_if_active != NULL)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry), airpcap_get_channel_name(airpcap_if_active->channel));
+ else
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry),"");
+
+ /* callback for channel combo box */
+ SIGNAL_CONNECT(GTK_COMBO(channel_cm)->entry,"changed",airpcap_toolbar_channel_changed_cb,GTK_COMBO(channel_cm)->entry);
+ gtk_widget_show(channel_cm);
+
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_cm,
+ "802.11 Channel", "Private");
+
+ gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
+
+ /* Wrong CRC Label */
+ wrong_crc_lb = gtk_label_new(" FCS Filter: ");
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), wrong_crc_lb,
+ "", "Private");
+ gtk_widget_show(wrong_crc_lb);
+
+ /* Wrong CRC combo */
+ wrong_crc_cm = gtk_combo_new();
+ gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(wrong_crc_cm)->entry),FALSE);
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_WRONG_CRC_KEY,wrong_crc_cm);
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), wrong_crc_cm,
+ "", "Private");
+
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_ALL);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRECT);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT);
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(wrong_crc_cm), linktype_list) ;
+ gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(wrong_crc_cm)->entry),
+ "Select the 802.11 FCS filter that the wireless adapter will apply.",
+ NULL);
+
+ if(airpcap_if_active != NULL)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_cm)->entry), airpcap_get_validation_name(airpcap_if_active->CrcValidationOn));
+ else
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_cm)->entry),"");
+
+ SIGNAL_CONNECT(GTK_COMBO(wrong_crc_cm)->entry,"changed",airpcap_toolbar_wrong_crc_combo_cb,airpcap_tb);
+ gtk_widget_show(wrong_crc_cm);
+
+ gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
+
+ /* encryption enabled box */
+
+ encryption_ck = gtk_toggle_button_new();
+ iconw = xpm_to_widget (wep_closed_24_xpm);
+ gtk_widget_show(iconw);
+ gtk_container_add(GTK_CONTAINER(encryption_ck),iconw);
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(encryption_ck),
+ 28,
+ 28 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(encryption_ck),
+ 28,
+ 28 );
+ #endif
+
+ OBJECT_SET_DATA(GTK_TOOLBAR(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY,encryption_ck);
+
+ if(airpcap_if_active != NULL)
+ {
+ if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_ck),FALSE);
+ }
+
+ SIGNAL_CONNECT(encryption_ck,"toggled",airpcap_toolbar_encryption_cb,airpcap_tb);
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), encryption_ck,
+ "Enable the WEP decryption in the wireless driver", "Private");
+ gtk_widget_show(encryption_ck);
+
+ gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
+
+ /* Advanced button */
+ advanced_bt = gtk_button_new_with_label("Advanced Wireless Settings...");
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY,advanced_bt);
+
+ SIGNAL_CONNECT(advanced_bt, "clicked", toolbar_display_airpcap_advanced_cb, airpcap_tb);
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), advanced_bt,
+ "Set Advanced Wireless Settings...", "Private");
+ gtk_widget_show(advanced_bt);
+
+ /* select the default interface */
+ airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+
+ /* If no airpcap interface is present, gray everything */
+ if(airpcap_if_active == NULL)
+ {
+ if(airpcap_if_list == NULL)
+ {
+ /*No airpcap device found */
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ recent.airpcap_toolbar_show = FALSE;
+ }
+ else
+ {
+ /* default adapter is not airpcap... or is airpcap but is not found*/
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ recent.airpcap_toolbar_show = TRUE;
+ }
+ }
+ else
+ {
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ recent.airpcap_toolbar_show = TRUE;
+ }
+#endif
+
/* filter toolbar */
#if GTK_MAJOR_VERSION < 2
filter_tb = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
diff --git a/gtk/main.h b/gtk/main.h
index cde0803ffc..a02a537925 100644
--- a/gtk/main.h
+++ b/gtk/main.h
@@ -62,6 +62,8 @@ extern GString *comp_info_str;
/** Global runtime version string */
extern GString *runtime_info_str;
+extern GtkWidget* airpcap_tb;
+
/** Global capture options type. */
typedef struct capture_options_tag * p_capture_options_t;
/** Pointer to global capture options. */
@@ -70,6 +72,9 @@ extern p_capture_options_t capture_opts;
extern void protect_thread_critical_region(void);
extern void unprotect_thread_critical_region(void);
+void
+airpcap_toolbar_encryption_cb(GtkWidget *entry, gpointer user_data);
+
/** User requested "Zoom In" by menu or toolbar.
*
* @param widget parent widget (unused)
diff --git a/gtk/menu.c b/gtk/menu.c
index 35d1f52cb0..da2e049451 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -109,6 +109,9 @@ static void menus_init(void);
static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint);
static void main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
+#ifdef HAVE_AIRPCAP
+static void airpcap_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
+#endif
static void packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
@@ -445,6 +448,9 @@ static GtkItemFactoryEntry menu_items[] =
ITEM_FACTORY_ENTRY("/_View", NULL, NULL, 0, "<Branch>", NULL),
ITEM_FACTORY_ENTRY("/View/_Main Toolbar", NULL, main_toolbar_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Filter Toolbar", NULL, filter_toolbar_show_cb, 0, "<CheckItem>", NULL),
+#ifdef HAVE_AIRPCAP
+ ITEM_FACTORY_ENTRY("/View/_Wireless Toolbar", NULL, airpcap_toolbar_show_cb, 0, "<CheckItem>", NULL),
+#endif
ITEM_FACTORY_ENTRY("/View/_Statusbar", NULL, statusbar_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
ITEM_FACTORY_ENTRY("/View/Packet _List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL),
@@ -1504,6 +1510,17 @@ filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
main_widgets_show_or_hide();
}
+#ifdef HAVE_AIRPCAP
+static void
+airpcap_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
+{
+
+ /* save current setting in recent */
+ recent.airpcap_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
+
+ main_widgets_show_or_hide();
+}
+#endif
static void
packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_)
@@ -1775,6 +1792,9 @@ menu_recent_read_finished(void) {
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
+ menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Wireless Toolbar");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.airpcap_toolbar_show);
+
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
diff --git a/gtk/recent.c b/gtk/recent.c
index f4c3c226d9..8e8c19e849 100644
--- a/gtk/recent.c
+++ b/gtk/recent.c
@@ -50,6 +50,7 @@
#define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show"
#define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show"
+#define RECENT_KEY_AIRPCAP_TOOLBAR_SHOW "gui.airpcap_toolbar_show"
#define RECENT_KEY_PACKET_LIST_SHOW "gui.packet_list_show"
#define RECENT_KEY_TREE_VIEW_SHOW "gui.tree_view_show"
#define RECENT_KEY_BYTE_VIEW_SHOW "gui.byte_view_show"
@@ -165,6 +166,13 @@ write_recent(void)
fprintf(rf, RECENT_KEY_FILTER_TOOLBAR_SHOW ": %s\n",
recent.filter_toolbar_show == TRUE ? "TRUE" : "FALSE");
+#ifdef HAVE_AIRPCAP
+ fprintf(rf, "\n# Wireless Settings Toolbar show (hide).\n");
+ fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
+ fprintf(rf, RECENT_KEY_AIRPCAP_TOOLBAR_SHOW ": %s\n",
+ recent.airpcap_toolbar_show == TRUE ? "TRUE" : "FALSE");
+#endif
+
fprintf(rf, "\n# Packet list show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_PACKET_LIST_SHOW ": %s\n",
@@ -213,7 +221,7 @@ write_recent(void)
recent.gui_geometry_main_width);
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
recent.gui_geometry_main_height);
-
+
fprintf(rf, "\n# Main window maximized (GTK2 only!).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED ": %s\n",
@@ -259,7 +267,7 @@ write_recent(void)
/* write the geometry values of a window to recent file */
-void
+void
write_recent_geom(gpointer key _U_, gpointer value, gpointer rf)
{
window_geometry_t *geom = value;
@@ -301,6 +309,13 @@ read_set_recent_pair_static(gchar *key, gchar *value)
else {
recent.filter_toolbar_show = FALSE;
}
+ } else if (strcmp(key, RECENT_KEY_AIRPCAP_TOOLBAR_SHOW) == 0) {
+ if (strcasecmp(value, "true") == 0) {
+ recent.airpcap_toolbar_show = TRUE;
+ }
+ else {
+ recent.airpcap_toolbar_show = FALSE;
+ }
} else if (strcmp(key, RECENT_KEY_PACKET_LIST_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.packet_list_show = TRUE;
@@ -489,6 +504,7 @@ recent_read_static(char **rf_path_return, int *rf_errno_return)
/* set defaults */
recent.main_toolbar_show = TRUE;
recent.filter_toolbar_show = TRUE;
+ recent.airpcap_toolbar_show = FALSE;
recent.packet_list_show = TRUE;
recent.tree_view_show = TRUE;
recent.byte_view_show = TRUE;
diff --git a/gtk/recent.h b/gtk/recent.h
index 2450aadff1..e1ecb3de95 100644
--- a/gtk/recent.h
+++ b/gtk/recent.h
@@ -43,6 +43,7 @@
typedef struct recent_settings_tag {
gboolean main_toolbar_show;
gboolean filter_toolbar_show;
+ gboolean airpcap_toolbar_show;
gboolean packet_list_show;
gboolean tree_view_show;
gboolean byte_view_show;
diff --git a/image/toolbar/capture_airpcap_16.xpm b/image/toolbar/capture_airpcap_16.xpm
new file mode 100644
index 0000000000..f55396cad4
--- /dev/null
+++ b/image/toolbar/capture_airpcap_16.xpm
@@ -0,0 +1,275 @@
+/* XPM */
+static char * capture_airpcap_16_xpm[] = {
+"16 16 256 2",
+" c None",
+". c #800000",
+"+ c #008000",
+"@ c #808000",
+"# c #000080",
+"$ c #800080",
+"% c #008080",
+"& c #C0C0C0",
+"* c #C0DCC0",
+"= c #A6CAF0",
+"- c #040404",
+"; c #080808",
+"> c #0C0C0C",
+", c #111111",
+"' c #161616",
+") c #1C1C1C",
+"! c #222222",
+"~ c #292929",
+"{ c #555555",
+"] c #4D4D4D",
+"^ c #424242",
+"/ c #393939",
+"( c #FF7C80",
+"_ c #FF5050",
+": c #D60093",
+"< c #CCECFF",
+"[ c #EFD6C6",
+"} c #E7E7D6",
+"| c #ADA990",
+"1 c #330000",
+"2 c #660000",
+"3 c #990000",
+"4 c #CC0000",
+"5 c #003300",
+"6 c #333300",
+"7 c #663300",
+"8 c #993300",
+"9 c #CC3300",
+"0 c #FF3300",
+"a c #006600",
+"b c #336600",
+"c c #666600",
+"d c #996600",
+"e c #CC6600",
+"f c #FF6600",
+"g c #009900",
+"h c #339900",
+"i c #669900",
+"j c #999900",
+"k c #CC9900",
+"l c #FF9900",
+"m c #00CC00",
+"n c #33CC00",
+"o c #66CC00",
+"p c #99CC00",
+"q c #CCCC00",
+"r c #FFCC00",
+"s c #66FF00",
+"t c #99FF00",
+"u c #CCFF00",
+"v c #000033",
+"w c #330033",
+"x c #660033",
+"y c #990033",
+"z c #CC0033",
+"A c #FF0033",
+"B c #003333",
+"C c #333333",
+"D c #663333",
+"E c #993333",
+"F c #CC3333",
+"G c #FF3333",
+"H c #006633",
+"I c #336633",
+"J c #666633",
+"K c #996633",
+"L c #CC6633",
+"M c #FF6633",
+"N c #009933",
+"O c #339933",
+"P c #669933",
+"Q c #999933",
+"R c #CC9933",
+"S c #FF9933",
+"T c #00CC33",
+"U c #33CC33",
+"V c #66CC33",
+"W c #99CC33",
+"X c #CCCC33",
+"Y c #FFCC33",
+"Z c #33FF33",
+"` c #66FF33",
+" . c #99FF33",
+".. c #CCFF33",
+"+. c #FFFF33",
+"@. c #000066",
+"#. c #330066",
+"$. c #660066",
+"%. c #990066",
+"&. c #CC0066",
+"*. c #FF0066",
+"=. c #003366",
+"-. c #333366",
+";. c #663366",
+">. c #993366",
+",. c #CC3366",
+"'. c #FF3366",
+"). c #006666",
+"!. c #336666",
+"~. c #666666",
+"{. c #996666",
+"]. c #CC6666",
+"^. c #009966",
+"/. c #339966",
+"(. c #669966",
+"_. c #999966",
+":. c #CC9966",
+"<. c #FF9966",
+"[. c #00CC66",
+"}. c #33CC66",
+"|. c #99CC66",
+"1. c #CCCC66",
+"2. c #FFCC66",
+"3. c #00FF66",
+"4. c #33FF66",
+"5. c #99FF66",
+"6. c #CCFF66",
+"7. c #FF00CC",
+"8. c #CC00FF",
+"9. c #009999",
+"0. c #993399",
+"a. c #990099",
+"b. c #CC0099",
+"c. c #000099",
+"d. c #333399",
+"e. c #660099",
+"f. c #CC3399",
+"g. c #FF0099",
+"h. c #006699",
+"i. c #336699",
+"j. c #663399",
+"k. c #996699",
+"l. c #CC6699",
+"m. c #FF3399",
+"n. c #339999",
+"o. c #669999",
+"p. c #999999",
+"q. c #CC9999",
+"r. c #FF9999",
+"s. c #00CC99",
+"t. c #33CC99",
+"u. c #66CC66",
+"v. c #99CC99",
+"w. c #CCCC99",
+"x. c #FFCC99",
+"y. c #00FF99",
+"z. c #33FF99",
+"A. c #66CC99",
+"B. c #99FF99",
+"C. c #CCFF99",
+"D. c #FFFF99",
+"E. c #0000CC",
+"F. c #330099",
+"G. c #6600CC",
+"H. c #9900CC",
+"I. c #CC00CC",
+"J. c #003399",
+"K. c #3333CC",
+"L. c #6633CC",
+"M. c #9933CC",
+"N. c #CC33CC",
+"O. c #FF33CC",
+"P. c #0066CC",
+"Q. c #3366CC",
+"R. c #666699",
+"S. c #9966CC",
+"T. c #CC66CC",
+"U. c #FF6699",
+"V. c #0099CC",
+"W. c #3399CC",
+"X. c #6699CC",
+"Y. c #9999CC",
+"Z. c #CC99CC",
+"`. c #FF99CC",
+" + c #00CCCC",
+".+ c #33CCCC",
+"++ c #66CCCC",
+"@+ c #99CCCC",
+"#+ c #CCCCCC",
+"$+ c #FFCCCC",
+"%+ c #00FFCC",
+"&+ c #33FFCC",
+"*+ c #66FF99",
+"=+ c #99FFCC",
+"-+ c #CCFFCC",
+";+ c #FFFFCC",
+">+ c #3300CC",
+",+ c #6600FF",
+"'+ c #9900FF",
+")+ c #0033CC",
+"!+ c #3333FF",
+"~+ c #6633FF",
+"{+ c #9933FF",
+"]+ c #CC33FF",
+"^+ c #FF33FF",
+"/+ c #0066FF",
+"(+ c #3366FF",
+"_+ c #6666CC",
+":+ c #9966FF",
+"<+ c #CC66FF",
+"[+ c #FF66CC",
+"}+ c #0099FF",
+"|+ c #3399FF",
+"1+ c #6699FF",
+"2+ c #9999FF",
+"3+ c #CC99FF",
+"4+ c #FF99FF",
+"5+ c #00CCFF",
+"6+ c #33CCFF",
+"7+ c #66CCFF",
+"8+ c #99CCFF",
+"9+ c #CCCCFF",
+"0+ c #FFCCFF",
+"a+ c #33FFFF",
+"b+ c #66FFCC",
+"c+ c #99FFFF",
+"d+ c #CCFFFF",
+"e+ c #FF6666",
+"f+ c #66FF66",
+"g+ c #FFFF66",
+"h+ c #6666FF",
+"i+ c #FF66FF",
+"j+ c #66FFFF",
+"k+ c #A50021",
+"l+ c #5F5F5F",
+"m+ c #777777",
+"n+ c #868686",
+"o+ c #969696",
+"p+ c #CBCBCB",
+"q+ c #B2B2B2",
+"r+ c #D7D7D7",
+"s+ c #DDDDDD",
+"t+ c #E3E3E3",
+"u+ c #EAEAEA",
+"v+ c #F1F1F1",
+"w+ c #F8F8F8",
+"x+ c #FFFBF0",
+"y+ c #A0A0A4",
+"z+ c #808080",
+"A+ c #FF0000",
+"B+ c #00FF00",
+"C+ c #FFFF00",
+"D+ c #0000FF",
+"E+ c #FF00FF",
+"F+ c #00FFFF",
+"G+ c #FFFFFF",
+" ",
+" 5. 5. ",
+"5. + 5. 5.+ 5.",
+"+ 5. a 5. n+n+ 5.a 5.+ ",
+"+ 5. a 5. n+& & n+ 5.a 5.+ ",
+"+ 5. a 5. n+#+& n+ 5.a 5.+ ",
+"+ 5. a 5. n+n+ 5.a 5.+ ",
+"5. + 5. o+n+ 5.+ 5.",
+" 5. & n+ 5. ",
+" & n+ ",
+" & n+ ",
+" & n+ ",
+" & n+ ",
+" & n+ ",
+" & n+ ",
+" "};
diff --git a/image/toolbar/capture_capture_16.xpm b/image/toolbar/capture_capture_16.xpm
new file mode 100644
index 0000000000..ef2a0f573f
--- /dev/null
+++ b/image/toolbar/capture_capture_16.xpm
@@ -0,0 +1,170 @@
+/* XPM */
+static char * capture_capture_16_xpm[] = {
+"16 16 151 2",
+" c None",
+". c #7F7F7F",
+"+ c #A9A9A9",
+"@ c #8E8E8E",
+"# c #373737",
+"$ c #545454",
+"% c #3D3D3D",
+"& c #F1F1F1",
+"* c #C2C2C2",
+"= c #A4A4A4",
+"- c #121212",
+"; c #212121",
+"> c #E9E9E9",
+", c #C7C7C7",
+"' c #505050",
+") c #979797",
+"! c #595958",
+"~ c #181818",
+"{ c #1F1F1F",
+"] c #A0A0A0",
+"^ c #323232",
+"/ c #5F5E5B",
+"( c #5D5C59",
+"_ c #1D1C1B",
+": c #7A7A7A",
+"< c #838383",
+"[ c #1E2018",
+"} c #7F847C",
+"| c #3B3C3B",
+"1 c #000000",
+"2 c #353535",
+"3 c #696865",
+"4 c #6D6B65",
+"5 c #6B6964",
+"6 c #54534D",
+"7 c #282828",
+"8 c #828282",
+"9 c #3D4536",
+"0 c #566147",
+"a c #535D44",
+"b c #5E6B57",
+"c c #30322F",
+"d c #313131",
+"e c #91908C",
+"f c #595854",
+"g c #737270",
+"h c #73726C",
+"i c #131211",
+"j c #808080",
+"k c #5E5F55",
+"l c #57624E",
+"m c #636958",
+"n c #5A6852",
+"o c #5A5D59",
+"p c #686868",
+"q c #5B5A56",
+"r c #7A7772",
+"s c #7F7D77",
+"t c #41403C",
+"u c #464646",
+"v c #7E7A6B",
+"w c #575E4B",
+"x c #7A7862",
+"y c #525D4A",
+"z c #686A66",
+"A c #B4B4B4",
+"B c #4D4D4D",
+"C c #0F0F0E",
+"D c #454545",
+"E c #7E7E7E",
+"F c #7B564E",
+"G c #534C3D",
+"H c #785042",
+"I c #4E5947",
+"J c #5B5D59",
+"K c #E6E6E6",
+"L c #E5E5E5",
+"M c #989898",
+"N c #DCDCDC",
+"O c #E3E3E3",
+"P c #7D7D7D",
+"Q c #3C4338",
+"R c #3D4836",
+"S c #424A3C",
+"T c #3B3D39",
+"U c #080A07",
+"V c #5E605E",
+"W c #51524F",
+"X c #455137",
+"Y c #687355",
+"Z c #656B55",
+"` c #5F6759",
+" . c #393B38",
+".. c #242B21",
+"+. c #6B725C",
+"@. c #53503F",
+"#. c #565546",
+"$. c #555445",
+"%. c #474533",
+"&. c #313B28",
+"*. c #445036",
+"=. c #5D6B49",
+"-. c #6F7C64",
+";. c #6A6C68",
+">. c #6D6D6D",
+",. c #615F5D",
+"'. c #273024",
+"). c #73805E",
+"!. c #4A4C36",
+"~. c #434632",
+"{. c #56583E",
+"]. c #4B4D36",
+"^. c #484A35",
+"/. c #5C6647",
+"(. c #6A7652",
+"_. c #60704C",
+":. c #667359",
+"<. c #4E514A",
+"[. c #585957",
+"}. c #525352",
+"|. c #3F3F3F",
+"1. c #313C2D",
+"2. c #5A7051",
+"3. c #6E7655",
+"4. c #5C684A",
+"5. c #6B7352",
+"6. c #5A6547",
+"7. c #68704F",
+"8. c #616E4B",
+"9. c #6E7954",
+"0. c #66734E",
+"a. c #37412C",
+"b. c #1D2317",
+"c. c #2C302A",
+"d. c #242423",
+"e. c #364430",
+"f. c #B3AB7D",
+"g. c #8B8E66",
+"h. c #B3AA7C",
+"i. c #898D64",
+"j. c #B2A97B",
+"k. c #898B63",
+"l. c #B2A87B",
+"m. c #868760",
+"n. c #171D12",
+"o. c #3B3829",
+"p. c #2D2E21",
+"q. c #2D2D20",
+"r. c #3B3828",
+"s. c #2C2C1F",
+"t. c #2A2A2A",
+" ",
+" . + + + + @ # $ % ",
+" + & & & & * = - ; ",
+" + > , ' ' ) ! ~ { ",
+" + ] ^ / ( _ : < [ } | ",
+"1 + 2 3 4 5 6 7 8 9 0 a b c ",
+"1 + d e f g h i j k l m n o ",
+"1 + p q r s t u j v w x y z ",
+"1 + A B C C D = E F G H I J ",
+"1 + K L M M N O P Q R S I T ",
+"U V E E P P P P W X Y Z ` . ",
+"..+.@.@.#.$.%.&.*.=.-.;.>.,.@ . ",
+"'.).!.~.{.].^./.(._.:.<.[.}.p |.",
+"1.2.3.4.5.6.7.8.9.0.a.b.c.d. ",
+" e.f.g.h.i.j.k.l.m.n. { ",
+" o.p.o.p.o.q.r.s. t. "};
diff --git a/image/toolbar/capture_details_16.xpm b/image/toolbar/capture_details_16.xpm
new file mode 100644
index 0000000000..41d025fb29
--- /dev/null
+++ b/image/toolbar/capture_details_16.xpm
@@ -0,0 +1,150 @@
+/* XPM */
+static char * capture_details_16_xpm[] = {
+"16 16 131 2",
+" c None",
+". c #000000",
+"+ c #AAAAAA",
+"@ c #8E8E8E",
+"# c #373737",
+"$ c #FEFEFE",
+"% c #F4F4F4",
+"& c #F8F8F8",
+"* c #F5F5F5",
+"= c #FFFFFF",
+"- c #FBFBFB",
+"; c #F9F9F9",
+"> c #C2C2C2",
+", c #A4A4A4",
+"' c #121212",
+") c #FDFDFC",
+"! c #FBFBFA",
+"~ c #F8F8F7",
+"{ c #F6F6F5",
+"] c #B6B6B6",
+"^ c #616160",
+"/ c #181818",
+"( c #F0F0F0",
+"_ c #ECECEC",
+": c #F1F1F1",
+"< c #E4E4E4",
+"[ c #DCDCDC",
+"} c #EEEEED",
+"| c #E8E8E7",
+"1 c #ECECEB",
+"2 c #6A6A6A",
+"3 c #DEDEDE",
+"4 c #555555",
+"5 c #BFBFBF",
+"6 c #B9B9B8",
+"7 c #535353",
+"8 c #C3C3C2",
+"9 c #E0E0DF",
+"0 c #DEDEDD",
+"a c #DEDEDC",
+"b c #D9D9D8",
+"c c #E4E4E3",
+"d c #6D6D6D",
+"e c #545454",
+"f c #575757",
+"g c #9F9F9F",
+"h c #393938",
+"i c #D0D0CE",
+"j c #E3E3E2",
+"k c #DFDFDD",
+"l c #E2E2E0",
+"m c #E4E4E2",
+"n c #6C6C6C",
+"o c #FDFDFD",
+"p c #DFDFDF",
+"q c #C1C1C1",
+"r c #303030",
+"s c #C5C5C3",
+"t c #DFDFDE",
+"u c #DBDBD9",
+"v c #E1E1DE",
+"w c #D3D3D2",
+"x c #595959",
+"y c #454545",
+"z c #8B8B8A",
+"A c #C8C8C7",
+"B c #D1D1CF",
+"C c #D0D0CD",
+"D c #D6D6D4",
+"E c #6C6C6B",
+"F c #FAFAFA",
+"G c #EBEBEA",
+"H c #717170",
+"I c #969696",
+"J c #4E4E4E",
+"K c #BABAB8",
+"L c #DCDCDA",
+"M c #C9C9C7",
+"N c #C8C8C6",
+"O c #CBCBC9",
+"P c #D6D6D3",
+"Q c #F9F9F8",
+"R c #E7E7E5",
+"S c #8C8C8C",
+"T c #545453",
+"U c #C0C0BE",
+"V c #D1D1CE",
+"W c #CECECB",
+"X c #D2D2CE",
+"Y c #D4D4D0",
+"Z c #5D5D5D",
+"` c #B7B7B7",
+" . c #414141",
+".. c #868684",
+"+. c #C4C4C1",
+"@. c #CDCDCA",
+"#. c #CACAC7",
+"$. c #6B6B6A",
+"%. c #4C4C4B",
+"&. c #282827",
+"*. c #9A9A97",
+"=. c #C0C0BD",
+"-. c #CECECA",
+";. c #CCCCC8",
+">. c #F5F5F4",
+",. c #4B4B4A",
+"'. c #2F2F2E",
+"). c #333332",
+"!. c #252525",
+"~. c #92928F",
+"{. c #CFCFCB",
+"]. c #CDCDC9",
+"^. c #CCCCC7",
+"/. c #B1B1AF",
+"(. c #2E2E2E",
+"_. c #595958",
+":. c #787876",
+"<. c #6B6B69",
+"[. c #9D9D9A",
+"}. c #B6B6B2",
+"|. c #B5B5B1",
+"1. c #B4B4B0",
+"2. c #5C5C5B",
+"3. c #424242",
+"4. c #3C3C3B",
+"5. c #323231",
+"6. c #222221",
+"7. c #2C2C2C",
+"8. c #2D2D2D",
+"9. c #2C2C2B",
+"0. c #1B1B1A",
+" ",
+" . + + + + + + + + + + @ # ",
+" . $ % & * = = = $ - ; > , ' ",
+" . $ % & * = = ) ! ~ { ] ^ / ",
+" . = ( _ _ ( : < [ } | } 1 2 ",
+" . = 3 4 5 6 7 8 9 0 a b c d ",
+" . $ e + f d g h i j k l m n ",
+" . o 7 p g g q r s t u a v n ",
+" . - w x [ q y z A a B C D E ",
+" . F G H + I J K L M N O P E ",
+" . Q R S + S T U P V W X Y E ",
+" . ~ N Z [ ` ...+.@.#.W C $. ",
+" . { %.p g g q &.*.=.#.-.;.E ",
+" . >.,.+ '.).g !.~.{.].^.^.$. ",
+" . c /.(._.:.'.<.[.}.}.|.1.2. ",
+" . 3.4.(.&.5.'.6.7.(.(.8.9.0. "};
diff --git a/image/toolbar/capture_ethernet_16.xpm b/image/toolbar/capture_ethernet_16.xpm
new file mode 100644
index 0000000000..260b9ea03f
--- /dev/null
+++ b/image/toolbar/capture_ethernet_16.xpm
@@ -0,0 +1,163 @@
+/* XPM */
+static char * capture_ethernet_16_xpm[] = {
+"16 16 144 2",
+" c None",
+". c #6A6A6A",
+"+ c #3F3F3F",
+"@ c #565656",
+"# c #535353",
+"$ c #4B5A45",
+"% c #7C9773",
+"& c #7B906D",
+"* c #80916D",
+"= c #748766",
+"- c #7D8E6A",
+"; c #708362",
+"> c #6D7B5B",
+", c #75815E",
+"' c #718060",
+") c #697756",
+"! c #6F7B5C",
+"~ c #5C6E52",
+"{ c #4B523F",
+"] c #576B50",
+"^ c #959D92",
+"/ c #AAAEA9",
+"( c #8F968B",
+"_ c #A3A7A1",
+": c #8B9388",
+"< c #676E64",
+"[ c #525D42",
+"} c #727B6D",
+"| c #47543F",
+"1 c #6F746D",
+"2 c #4C5C42",
+"3 c #6C6C6C",
+"4 c #444D3B",
+"5 c #909A8D",
+"6 c #A5A5A5",
+"7 c #BDBDBD",
+"8 c #ABABAB",
+"9 c #9A9A9A",
+"0 c #666765",
+"a c #575E4C",
+"b c #98987A",
+"c c #3F4831",
+"d c #979076",
+"e c #425039",
+"f c #777777",
+"g c #444E3C",
+"h c #6D7B68",
+"i c #888888",
+"j c #868686",
+"k c #737373",
+"l c #6D6D6D",
+"m c #636363",
+"n c #464845",
+"o c #3F4836",
+"p c #957665",
+"q c #3B3A28",
+"r c #94655A",
+"s c #3F4C36",
+"t c #6F6F6F",
+"u c #44523F",
+"v c #506349",
+"w c #454D41",
+"x c #555A53",
+"y c #3A4138",
+"z c #515550",
+"A c #363C34",
+"B c #343932",
+"C c #464E37",
+"D c #4B5844",
+"E c #384430",
+"F c #434B3E",
+"G c #4F4F4F",
+"H c #475642",
+"I c #6B7F5E",
+"J c #566246",
+"K c #585F44",
+"L c #454E37",
+"M c #4B533B",
+"N c #495039",
+"O c #53593F",
+"P c #61694A",
+"Q c #5F6D4B",
+"R c #616C4A",
+"S c #6F755F",
+"T c #586151",
+"U c #4A4A4A",
+"V c #455440",
+"W c #848F71",
+"X c #606549",
+"Y c #79785F",
+"Z c #7E8065",
+"` c #5D614D",
+" . c #616247",
+".. c #4F5E40",
+"+. c #566847",
+"@. c #5E6E4B",
+"#. c #76856C",
+"$. c #616161",
+"%. c #585858",
+"&. c #787775",
+"*. c #B3B3B3",
+"=. c #666666",
+"-. c #3F4C3A",
+";. c #6F7B59",
+">. c #3D402E",
+",. c #484833",
+"'. c #4F513A",
+"). c #494A34",
+"!. c #41422F",
+"~. c #5B6647",
+"{. c #6B7752",
+"]. c #60704C",
+"^. c #707C5D",
+"/. c #4B4B4B",
+"(. c #474747",
+"_. c #646464",
+":. c #6E6E6E",
+"<. c #1F1F1F",
+"[. c #5B7151",
+"}. c #6B7654",
+"|. c #687251",
+"1. c #687250",
+"2. c #66714F",
+"3. c #66704F",
+"4. c #6A7551",
+"5. c #6C7853",
+"6. c #65724D",
+"7. c #2F3B26",
+"8. c #1E2618",
+"9. c #11150D",
+"0. c #525252",
+"a. c #33402D",
+"b. c #A5A175",
+"c. c #A4A074",
+"d. c #A39F73",
+"e. c #A39E72",
+"f. c #A29E72",
+"g. c #A09B6F",
+"h. c #131910",
+"i. c #3F402E",
+"j. c #3E3F2D",
+"k. c #3E3E2C",
+"l. c #3D3C2B",
+"m. c #3C3C3C",
+" ",
+" . + ",
+" @ ",
+" # ",
+" # ",
+"$ % & * = - ; > , ' ) ! ~ # ",
+"{ ] ^ / ( _ : < [ } | 1 2 3 ",
+"4 5 6 7 8 6 9 0 a b c d e f ",
+"g h i j k l m n o p q r s t ",
+"u v w x y z A B C D E F s G ",
+"H I J K L M N O P Q R S T U ",
+"V W X Y Z ` ...+.@.#.$.%.&.*.=.",
+"-.;.>.,.'.).!.~.{.].^./.(._.:.<.",
+" [.}.|.1.2.3.4.5.6.7.8.9.0. ",
+" a.b.c.c.d.e.e.f.g.h. # ",
+" i.j.j.j.k.k.k.l. m. "};
diff --git a/image/toolbar/capture_prepare_16.xpm b/image/toolbar/capture_prepare_16.xpm
new file mode 100644
index 0000000000..084d4bb6d0
--- /dev/null
+++ b/image/toolbar/capture_prepare_16.xpm
@@ -0,0 +1,178 @@
+/* XPM */
+static char * capture_prepare_16_xpm[] = {
+"16 16 159 2",
+" c None",
+". c #808080",
+"+ c #000000",
+"@ c #353535",
+"# c #444444",
+"$ c #545454",
+"% c #3D3D3D",
+"& c #AAAAAA",
+"* c #505050",
+"= c #4B4B4B",
+"- c #212121",
+"; c #494949",
+"> c #F6F6F6",
+", c #EFEFEF",
+"' c #A1A1A1",
+") c #272727",
+"! c #1F1F1F",
+"~ c #555555",
+"{ c #E1E1E1",
+"] c #0F100E",
+"^ c #7F847C",
+"/ c #3B3C3B",
+"( c #343E30",
+"_ c #697D61",
+": c #252821",
+"< c #626F56",
+"[ c #59674C",
+"} c #4F5C44",
+"| c #556147",
+"1 c #5E6950",
+"2 c #566147",
+"3 c #535D44",
+"4 c #5E6B57",
+"5 c #30322F",
+"6 c #292F24",
+"7 c #576750",
+"8 c #8C8C8C",
+"9 c #E9E9E9",
+"0 c #4B4D4B",
+"a c #828880",
+"b c #90968E",
+"c c #5E675B",
+"d c #7E836E",
+"e c #57624E",
+"f c #636958",
+"g c #5A6852",
+"h c #5A5D59",
+"i c #0E100D",
+"j c #7F817D",
+"k c #F3F3F3",
+"l c #E5E5E5",
+"m c #C1C1C1",
+"n c #4F4F4F",
+"o c #9E9E9E",
+"p c #656764",
+"q c #4B5542",
+"r c #9A9A81",
+"s c #575E4B",
+"t c #7A7862",
+"u c #525D4A",
+"v c #686A66",
+"w c #010101",
+"x c #0C0C0C",
+"y c #242423",
+"z c #6A6B6A",
+"A c #494D48",
+"B c #3D4836",
+"C c #927261",
+"D c #534C3D",
+"E c #785042",
+"F c #4E5947",
+"G c #5B5D59",
+"H c #1D221B",
+"I c #555A53",
+"J c #1D1E1C",
+"K c #4D514A",
+"L c #1B1B1B",
+"M c #323331",
+"N c #3B3E39",
+"O c #252A22",
+"P c #434C35",
+"Q c #535F4B",
+"R c #424A3C",
+"S c #3B3D39",
+"T c #2A3327",
+"U c #6D8261",
+"V c #596548",
+"W c #515A40",
+"X c #49513A",
+"Y c #484F38",
+"Z c #51563D",
+"` c #424C34",
+" . c #5B6547",
+".. c #596847",
+"+. c #687355",
+"@. c #656B55",
+"#. c #5F6759",
+"$. c #393B38",
+"%. c #2A3226",
+"&. c #8C9777",
+"*. c #6B6D54",
+"=. c #6D6E54",
+"-. c #6A6E57",
+";. c #6C7058",
+">. c #68694C",
+",. c #505D40",
+"'. c #5F6E4B",
+"). c #61704C",
+"!. c #6F7C64",
+"~. c #6A6C68",
+"{. c #6C6C6C",
+"]. c #615F5D",
+"^. c #8E8E8E",
+"/. c #7F7F7F",
+"(. c #273024",
+"_. c #73805E",
+":. c #4A4C36",
+"<. c #434632",
+"[. c #56583E",
+"}. c #4B4D36",
+"|. c #484A35",
+"1. c #5C6647",
+"2. c #6A7652",
+"3. c #60704C",
+"4. c #667359",
+"5. c #4E514A",
+"6. c #585957",
+"7. c #525352",
+"8. c #686868",
+"9. c #3F3F3F",
+"0. c #313C2D",
+"a. c #5A7051",
+"b. c #6E7655",
+"c. c #5C684A",
+"d. c #6B7352",
+"e. c #5A6547",
+"f. c #68704F",
+"g. c #616E4B",
+"h. c #6E7954",
+"i. c #66734E",
+"j. c #37412C",
+"k. c #1D2317",
+"l. c #2C302A",
+"m. c #364430",
+"n. c #B3AB7D",
+"o. c #8B8E66",
+"p. c #B3AA7C",
+"q. c #898D64",
+"r. c #B2A97B",
+"s. c #898B63",
+"t. c #B2A87B",
+"u. c #868760",
+"v. c #171D12",
+"w. c #3B3829",
+"x. c #2D2E21",
+"y. c #2D2D20",
+"z. c #3B3828",
+"A. c #2C2C1F",
+"B. c #2A2A2A",
+" ",
+" . + @ # $ % ",
+" & * * . = - ",
+" ; > , ' ) ! ",
+" ~ { ] ^ / ",
+"( _ ~ { : < [ } | 1 2 3 4 5 ",
+"6 7 8 9 0 a b c } d e f g h ",
+"i j k l m n o p q r s t u v ",
+"w & x y * * z A B C D E F G ",
+"H I J K L M N O P Q B R F S ",
+"T U V W X Y Z ` ...+.@.#.$. ",
+"%.&.*.=.-.;.>.,.'.).!.~.{.].^./.",
+"(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.",
+"0.a.b.c.d.e.f.g.h.i.j.k.l.y ",
+" m.n.o.p.q.r.s.t.u.v. ! ",
+" w.x.w.x.w.y.z.A. B. "};
diff --git a/image/toolbar/wep_closed_24.xpm b/image/toolbar/wep_closed_24.xpm
new file mode 100644
index 0000000000..cfd74eb52d
--- /dev/null
+++ b/image/toolbar/wep_closed_24.xpm
@@ -0,0 +1,240 @@
+/* XPM */
+static char * wep_closed_24_xpm[] = {
+"24 24 212 2",
+" c None",
+". c #333333",
+"+ c #727272",
+"@ c #737373",
+"# c #616161",
+"$ c #000000",
+"% c #202020",
+"& c #A5A5A5",
+"* c #EEEEEE",
+"= c #ECECEC",
+"- c #E7E7E7",
+"; c #E3E3E3",
+"> c #CBCBCB",
+", c #424242",
+"' c #1F1F1F",
+") c #D4D4D4",
+"! c #E8E8E8",
+"~ c #B5B5B5",
+"{ c #707070",
+"] c #6C6C6C",
+"^ c #BCBCBC",
+"/ c #DFDFDF",
+"( c #C8C8C8",
+"_ c #5B5B5B",
+": c #A4A4A4",
+"< c #818181",
+"[ c #919191",
+"} c #DDDDDD",
+"| c #2D2D2D",
+"1 c #3B3B3B",
+"2 c #EDEDED",
+"3 c #BABABA",
+"4 c #010101",
+"5 c #A0A0A0",
+"6 c #D6D6D6",
+"7 c #777777",
+"8 c #7F7F7F",
+"9 c #E2E2E2",
+"0 c #757575",
+"a c #3D3D3D",
+"b c #E6E6E6",
+"c c #AFAFAF",
+"d c #767676",
+"e c #DCDCDC",
+"f c #8B6C4F",
+"g c #AE8A6A",
+"h c #D2A06E",
+"i c #AD8562",
+"j c #90735A",
+"k c #8F7156",
+"l c #8E7054",
+"m c #8F7054",
+"n c #8E6F54",
+"o c #C99560",
+"p c #C48F5A",
+"q c #8A6849",
+"r c #79502A",
+"s c #331707",
+"t c #EFDBBF",
+"u c #E5C7A0",
+"v c #D8B385",
+"w c #D4AC7C",
+"x c #D0A873",
+"y c #CAA06A",
+"z c #C79C64",
+"A c #C89C64",
+"B c #C3985F",
+"C c #C09054",
+"D c #BC8545",
+"E c #B67A38",
+"F c #9A5E1B",
+"G c #2A1306",
+"H c #F0DABF",
+"I c #E4C6A0",
+"J c #D6AF80",
+"K c #D3AC7B",
+"L c #D0A570",
+"M c #C99F68",
+"N c #C69B64",
+"O c #C69C64",
+"P c #C89D66",
+"Q c #C79C65",
+"R c #C39860",
+"S c #C09256",
+"T c #BC8645",
+"U c #B67C36",
+"V c #985E1A",
+"W c #291306",
+"X c #EED8BC",
+"Y c #786752",
+"Z c #D2AC7D",
+"` c #D3AA7B",
+" . c #AA885C",
+".. c #896C46",
+"+. c #755C3B",
+"@. c #644F33",
+"#. c #634F33",
+"$. c #765D3C",
+"%. c #B58D59",
+"&. c #60492C",
+"*. c #604523",
+"=. c #7E5627",
+"-. c #995D1A",
+";. c #EED8BB",
+">. c #191611",
+",. c #C8A377",
+"'. c #D2A97A",
+"). c #7B6242",
+"!. c #57452C",
+"~. c #241C12",
+"{. c #99774C",
+"]. c #C59B64",
+"^. c #A57D4C",
+"/. c #140F08",
+"(. c #B27E3F",
+"_. c #36240F",
+":. c #623C11",
+"<. c #EFDABE",
+"[. c #332C23",
+"}. c #7F684B",
+"|. c #271F16",
+"1. c #5C4A32",
+"2. c #6D5638",
+"3. c #241C11",
+"4. c #98764C",
+"5. c #C49B62",
+"6. c #C49960",
+"7. c #A47D4A",
+"8. c #B8803E",
+"9. c #4B3216",
+"0. c #52330E",
+"a. c #EFD8BB",
+"b. c #4D4234",
+"c. c #443727",
+"d. c #1E1810",
+"e. c #3B2F1F",
+"f. c #816440",
+"g. c #231B11",
+"h. c #4B3B25",
+"i. c #614C30",
+"j. c #A58152",
+"k. c #A37C4A",
+"l. c #0A0704",
+"m. c #583E1E",
+"n. c #33220E",
+"o. c #86531A",
+"p. c #685947",
+"q. c #19140E",
+"r. c #7D6547",
+"s. c #0D0A07",
+"t. c #98774D",
+"u. c #97764A",
+"v. c #C49961",
+"w. c #A47C4A",
+"x. c #BA813E",
+"y. c #B27733",
+"z. c #A36B2F",
+"A. c #EDD6B8",
+"B. c #7F6B54",
+"C. c #3D3122",
+"D. c #B79161",
+"E. c #15110A",
+"F. c #A47D4C",
+"G. c #231A0F",
+"H. c #4A3822",
+"I. c #5F492C",
+"J. c #715634",
+"K. c #A17844",
+"L. c #140E07",
+"M. c #B67D3A",
+"N. c #B07530",
+"O. c #A67137",
+"P. c #EED8BA",
+"Q. c #E0C099",
+"R. c #D1A973",
+"S. c #CBA26B",
+"T. c #C49962",
+"U. c #C49A62",
+"V. c #C09257",
+"W. c #BD8C4E",
+"X. c #B9803D",
+"Y. c #B67D38",
+"Z. c #AB783F",
+"`. c #EED5B7",
+" + c #DFC096",
+".+ c #D2A776",
+"++ c #CEA46E",
+"@+ c #C89D65",
+"#+ c #C1955C",
+"$+ c #C2955C",
+"%+ c #C2965C",
+"&+ c #C09155",
+"*+ c #BC8A4B",
+"=+ c #BA8442",
+"-+ c #BE8A4C",
+";+ c #A9773C",
+">+ c #D5AE7E",
+",+ c #CFA772",
+"'+ c #C49256",
+")+ c #C08D51",
+"!+ c #BA8849",
+"~+ c #B78342",
+"{+ c #B48240",
+"]+ c #B68241",
+"^+ c #B88544",
+"/+ c #BB8949",
+"(+ c #BC8748",
+"_+ c #BA874A",
+":+ c #B98548",
+"<+ c #B27B3B",
+"[+ c #88521A",
+"}+ c #231005",
+" ",
+" ",
+" . + @ # $ ",
+" % & * = - ; > , ",
+" ' ) ! ~ { ] ^ / ( _ ",
+" : ! < $ [ } ^ | ",
+" 1 2 3 4 5 6 7 ",
+" 8 9 0 a b c $ ",
+" d e # a 3 $ ",
+" f g h i j k l l m m n o p q r ",
+" s t u v w x y z z A z B C D E F G ",
+" s H I J K L M N O P Q R S T U V W ",
+" s X Y Z ` ...+.@.#.$.%.&.*.=.-.W ",
+" s ;.>.,.'.).!.~.{.O ].^./.(._.:.W ",
+" s <.[.}.|.1.2.3.4.5.6.7./.8.9.0.W ",
+" s a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.W ",
+" s X p.q.r.s.t.3.u.v.R w./.x.y.z.W ",
+" s A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.W ",
+" s P.Q.` R.S.N 6.T.U.v.V.W.X.Y.Z.W ",
+" s `. +.+++@+6.#+$+%+%+&+*+=+-+;+W ",
+" s >+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+ ",
+" G G W W W W W W W W W W W W }+ ",
+" ",
+" "};
+