Advertisement
Guest User

wash-max-pcap-next-failures.patch

a guest
Jun 22nd, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.39 KB | None | 0 0
  1. --- a/trunk/src/80211.c 2014-06-22 16:19:30.329975344 +0400
  2. +++ b/trunk/src/80211.c 2014-06-22 17:04:28.357220443 +0400
  3. @@ -37,10 +37,23 @@
  4.  const u_char *next_packet(struct pcap_pkthdr *header)
  5.  {
  6.     const u_char *packet = NULL;
  7. +   int pcap_next_failures = 0;
  8. +   const int max_pcap_next_failures = get_max_pcap_next_failures();
  9.  
  10. -   /* Loop until we get a valid packet, or until we run out of packets */
  11. -   while((packet = pcap_next(get_handle(), header)) != NULL)
  12. +   /* Loop until we get a valid packet, or until we run out of packets, or until pcap_next_failures >= max_pcap_next_failures */
  13. +   while( ( max_pcap_next_failures < 0 ) || ( (pcap_next_failures <= max_pcap_next_failures) && ( pcap_next_failures != INT_MAX ) ) )
  14.     {
  15. +       packet = pcap_next(get_handle(), header);
  16. +      
  17. +       if (packet == NULL)
  18. +       {
  19. +           if ( (pcap_next_failures < INT_MAX) && (max_pcap_next_failures >= 0) )
  20. +           {
  21. +               pcap_next_failures++;
  22. +           }
  23. +           continue;
  24. +       }
  25. +      
  26.         if(get_validate_fcs())
  27.         {
  28.             if(check_fcs(packet, header->len))
  29. --- a/trunk/src/80211.h 2014-06-22 16:19:30.352975324 +0400
  30. +++ b/trunk/src/80211.h 2014-06-22 17:00:28.885292972 +0400
  31. @@ -34,6 +34,7 @@
  32.  #ifndef DOT11_H
  33.  #define DOT11_H
  34.  
  35. +#include <limits.h>
  36.  #include "defs.h"
  37.  #include "globule.h"
  38.  #include "argsparser.h"
  39. --- a/trunk/src/defs.h  2014-06-22 16:19:30.352975324 +0400
  40. +++ b/trunk/src/defs.h  2014-06-22 16:39:26.930865469 +0400
  41. @@ -46,6 +46,7 @@
  42.  
  43.  #define NULL_MAC       "\x00\x00\x00\x00\x00\x00"
  44.  #define DEFAULT_MAX_NUM_PROBES 15
  45. +#define DEFAULT_MAX_NUM_PCAP_NEXT_FAILURES 10
  46.  #define MAX_ASSOC_FAILURES 10
  47.  
  48.  #define TIMESTAMP_LEN      8
  49. --- a/trunk/src/globule.c   2014-06-22 16:19:30.353975323 +0400
  50. +++ b/trunk/src/globule.c   2014-06-22 16:49:54.379776855 +0400
  51. @@ -258,6 +258,15 @@
  52.     return globule->max_num_probes;
  53.  }
  54.  
  55. +void set_max_pcap_next_failures(int value)
  56. +{
  57. +   globule->max_pcap_next_failures = value;
  58. +}
  59. +int get_max_pcap_next_failures()
  60. +{
  61. +   return globule->max_pcap_next_failures;
  62. +}
  63. +
  64.  void set_rx_timeout(int value)
  65.  {
  66.     globule->rx_timeout = value;
  67. --- a/trunk/src/globule.h   2014-06-22 16:19:29.199976328 +0400
  68. +++ b/trunk/src/globule.h   2014-06-22 17:08:55.101148732 +0400
  69. @@ -102,6 +102,8 @@
  70.  
  71.     int max_num_probes;     /* Maximum number of probe requests to send to an AP during survey mode */
  72.    
  73. +   int max_pcap_next_failures;     /* Maximum number of pcap_next() failures (returning NULL) before giving up on it */
  74. +  
  75.     int validate_fcs;       /* If 1, validate each packet's FCS. If 0, process packets even with invalid FCS. */
  76.  
  77.          enum wsc_op_code opcode;        /* WFA opcode, received by exchange.c and used by builder.c */
  78. @@ -178,6 +180,8 @@
  79.  int get_max_pin_attempts();
  80.  int get_max_num_probes();
  81.  void set_max_num_probes(int value);
  82. +void set_max_pcap_next_failures(int value);
  83. +int get_max_pcap_next_failures();
  84.  void set_rx_timeout(int value);
  85.  int get_rx_timeout();
  86.  void set_timeout_is_nack(int value);
  87. --- a/trunk/src/wpsmon.c    2014-06-22 16:19:29.524976045 +0400
  88. +++ b/trunk/src/wpsmon.c    2014-06-22 17:02:21.205257967 +0400
  89. @@ -41,13 +41,14 @@
  90.     int source = INTERFACE, ret_val = EXIT_FAILURE;
  91.     struct bpf_program bpf = { 0 };
  92.     char *out_file = NULL, *last_optarg = NULL, *target = NULL, *bssid = NULL;
  93. -   char *short_options = "i:c:n:o:b:5sfuCDh";
  94. +   char *short_options = "i:c:n:p:o:b:5sfuCDh";
  95.          struct option long_options[] = {
  96.         { "bssid", required_argument, NULL, 'b' },
  97.                  { "interface", required_argument, NULL, 'i' },
  98.                  { "channel", required_argument, NULL, 'c' },
  99.         { "out-file", required_argument, NULL, 'o' },
  100.         { "probes", required_argument, NULL, 'n' },
  101. +       { "max-pcap-next-failures", required_argument, NULL, 'p' },
  102.         { "daemonize", no_argument, NULL, 'D' },
  103.         { "file", no_argument, NULL, 'f' },
  104.         { "ignore-fcs", no_argument, NULL, 'C' },
  105. @@ -70,6 +71,7 @@
  106.     set_validate_fcs(1);
  107.     set_log_file(stdout);
  108.     set_max_num_probes(DEFAULT_MAX_NUM_PROBES);
  109. +   set_max_pcap_next_failures(DEFAULT_MAX_NUM_PCAP_NEXT_FAILURES);
  110.  
  111.     while((c = getopt_long(argc, argv, short_options, long_options, &long_opt_index)) != -1)
  112.          {
  113. @@ -94,6 +96,9 @@
  114.             case 'n':
  115.                 set_max_num_probes(atoi(optarg));
  116.                 break;
  117. +           case 'p':
  118. +               set_max_pcap_next_failures(atoi(optarg));
  119. +               break;
  120.             case 'o':
  121.                 out_file = strdup(optarg);
  122.                 break;
  123. @@ -426,6 +431,7 @@
  124.     fprintf(stderr, "\t-c, --channel=<num>                  Channel to listen on [auto]\n");
  125.     fprintf(stderr, "\t-o, --out-file=<file>                Write data to file\n");
  126.     fprintf(stderr, "\t-n, --probes=<num>                   Maximum number of probes to send to each AP in scan mode [%d]\n", DEFAULT_MAX_NUM_PROBES);
  127. +   fprintf(stderr, "\t-p, --max-pcap-next-failures=<num>   Maximum number of pcap_next failures before giving up (set it to -1 to wait forever, maximum is %d) [%d]\n", INT_MAX, DEFAULT_MAX_NUM_PCAP_NEXT_FAILURES);
  128.     fprintf(stderr, "\t-D, --daemonize                      Daemonize wash\n");
  129.     fprintf(stderr, "\t-C, --ignore-fcs                     Ignore frame checksum errors\n");
  130.     fprintf(stderr, "\t-5, --5ghz                           Use 5GHz 802.11 channels\n");
  131. --- a/trunk/src/wpsmon.h    2014-06-22 16:19:29.524976045 +0400
  132. +++ b/trunk/src/wpsmon.h    2014-06-22 17:00:08.605299492 +0400
  133. @@ -39,6 +39,7 @@
  134.  #include <sys/time.h>
  135.  #include <arpa/inet.h>
  136.  #include <libwps.h>
  137. +#include <limits.h>
  138.  #include "defs.h"
  139.  #include "globule.h"
  140.  #include "misc.h"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement