PCHAR Description; /* Device description */
} AirpcapDeviceDescription, *PAirpcapDeviceDescription;
+#define MAX_ENCRYPTION_KEYS 64
+
#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 */
#define CANT_GET_AIRPCAP_INTERFACE_LIST 0 /* error getting list */
#define NO_AIRPCAP_INTERFACES_FOUND 1 /* list is empty */
-#define MAX_ENCRYPTION_KEYS 64
-
#define AIRPCAP_CHANNEL_ANY_NAME "ANY"
/*
#include <ctype.h>
#include "isprint.h"
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#else
+/* XXX - This is probably a bit much */
+#define MAX_ENCRYPTION_KEYS 64
+#endif
+
#ifndef roundup2
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
#endif
*/
#ifndef USE_ENV
-static const char *wep_keystr[] = {NULL, NULL, NULL, NULL};
+static char *wep_keystr[MAX_ENCRYPTION_KEYS];
#endif
/* ************************************************************************* */
void
proto_register_ieee80211 (void)
{
+ int i;
+ GString *key_name, *key_title, *key_desc;
+
static const value_string frame_type[] = {
{MGT_FRAME, "Management frame"},
{CONTROL_FRAME, "Control frame"},
"How many WEP keys do we have to choose from? (0 to disable, up to 4)",
&num_wepkeys, wep_keys_options, FALSE);
- prefs_register_string_preference(wlan_module, "wep_key1",
- "WEP key #1",
- "First WEP key (A:B:C:D:E) [40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
- &wep_keystr[0]);
- prefs_register_string_preference(wlan_module, "wep_key2",
- "WEP key #2",
- "Second WEP key (A:B:C:D:E) [40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
- &wep_keystr[1]);
- prefs_register_string_preference(wlan_module, "wep_key3",
- "WEP key #3",
- "Third WEP key (A:B:C:D:E) [40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
- &wep_keystr[2]);
- prefs_register_string_preference(wlan_module, "wep_key4",
- "WEP key #4",
- "Fourth WEP key (A:B:C:D:E) [40bit] (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
- &wep_keystr[3]);
+ for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
+ key_name = g_string_new("");
+ key_title = g_string_new("");
+ key_desc = g_string_new("");
+ wep_keystr[i] = NULL;
+ /* prefs_register_*_preference() expects unique strings, so
+ * we build them using g_string_sprintf and just leave them
+ * allocated. */
+ g_string_sprintf(key_name, "wep_key%d", i + 1);
+fprintf(stderr, "%s\n", key_name->str);
+ g_string_sprintf(key_title, "WEP key #%d", i + 1);
+ g_string_sprintf(key_desc, "WEP key #%d bytes in hexadecimal (A:B:C:D:E) "
+ "[40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key "
+ "length you're using", i + 1);
+
+ prefs_register_string_preference(wlan_module, key_name->str,
+ key_title->str, key_desc->str, &wep_keystr[i]);
+
+ g_string_free(key_name, FALSE);
+ g_string_free(key_title, FALSE);
+ g_string_free(key_desc, FALSE);
+ }
#endif
}
#include <epan/prefs-int.h>
/* Internal functions */
-static module_t *find_module(const char *name);
static module_t *prefs_register_module_or_subtree(module_t *parent,
const char *name, const char *title, const char *description, gboolean is_subtree,
void (*apply_cb)(void));
* protocol preferences to have a bogus "protocol.", or
* something such as that, to be added to all their names).
*/
- g_assert(find_module(name) == NULL);
+ g_assert(prefs_find_module(name) == NULL);
/*
* Insert this module in the list of all modules.
return strcmp(name, module->name);
}
-static module_t *
-find_module(const char *name)
+module_t *
+prefs_find_module(const char *name)
{
GList *list_entry;
gboolean
prefs_is_registered_protocol(const char *name)
{
- module_t *m = find_module(name);
+ module_t *m = prefs_find_module(name);
return (m != NULL && !m->obsolete);
}
const char *
prefs_get_title_by_name(const char *name)
{
- module_t *m = find_module(name);
+ module_t *m = prefs_find_module(name);
return (m != NULL && !m->obsolete) ? m->title : NULL;
}
had_a_dot = TRUE;
}
*dotp = '\0'; /* separate module and preference name */
- module = find_module(pref_name);
+ module = prefs_find_module(pref_name);
/*
* XXX - "Diameter" rather than "diameter" was used in earlier
*/
if (module == NULL) {
if (strcmp(pref_name, "Diameter") == 0)
- module = find_module("diameter");
+ module = prefs_find_module("diameter");
else if (strcmp(pref_name, "bxxp") == 0)
- module = find_module("beep");
+ module = prefs_find_module("beep");
else if (strcmp(pref_name, "gtpv0") == 0 ||
strcmp(pref_name, "gtpv1") == 0)
- module = find_module("gtp");
+ module = prefs_find_module("gtp");
else if (strcmp(pref_name, "smpp-gsm-sms") == 0)
- module = find_module("gsm-sms-ud");
+ module = prefs_find_module("gsm-sms-ud");
}
*dotp = '.'; /* put the preference string back */
dotp++; /* skip past separator to preference name */
pref = find_preference(module, "desegment_body");
} else if (strcmp(module->name, "smpp") == 0) {
/* Handle preferences that moved from SMPP. */
- module_t *new_module = find_module("gsm-sms-ud");
+ module_t *new_module = prefs_find_module("gsm-sms-ud");
if(new_module){
if (strcmp(dotp, "port_number_udh_means_wsp") == 0)
pref = find_preference(new_module, "port_number_udh_means_wsp");
#define PREFS_SET_NO_SUCH_PREF 2 /* no such preference */
#define PREFS_SET_OBSOLETE 3 /* preference used to exist but no longer does */
+/** Given a module name, return a pointer to its pref_module struct,
+ * or NULL if it's not found.
+ *
+ * @param name The preference module name. Usually the same as the protocol
+ * name, e.g. "tcp".
+ * @return A pointer to the corresponding preference module, or NULL if it
+ * wasn't found.
+ */
+module_t *prefs_find_module(const char *name);
+
extern int prefs_set_pref(char *prefarg);
#endif /* prefs.h */