~jelmer/wireshark/daily-ppa

« back to all changes in this revision

Viewing changes to epan/tap.c

  • Committer: Bazaar Package Importer
  • Author(s): Balint Reczey
  • Date: 2010-11-20 18:41:41 UTC
  • mfrom: (1.1.28 upstream) (42.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20101120184141-19e4sxq2kfsdnc9i
Tags: 1.4.2-1
* New upstream release 1.4.2
  - release notes:
    http://www.wireshark.org/docs/relnotes/wireshark-1.4.2.html
  - security fixes
     - Nephi Johnson of BreakingPoint discovered that the LDSS dissector
       could overflow a buffer. (No assigned CVE number.)
     - The ZigBee ZCL dissector could go into an infinite loop.
       (No assigned CVE number.)
* drop 05_fix-display-filter-update-when-changing-profile.patch
  patch since it has been integrated upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* tap.c
2
2
 * packet tap interface   2002 Ronnie Sahlberg
3
3
 *
4
 
 * $Id: tap.c 30720 2009-10-26 19:22:56Z gerald $
 
4
 * $Id: tap.c 30252 2009-10-02 19:55:43Z stig $
5
5
 *
6
6
 * Wireshark - Network traffic analyzer
7
7
 * By Gerald Combs <gerald@wireshark.org>
37
37
#endif
38
38
 
39
39
#include <string.h>
40
 
#include "epan/packet_info.h"
41
 
#include "epan/dfilter/dfilter.h"
 
40
#include <epan/packet_info.h>
 
41
#include <epan/dfilter/dfilter.h>
42
42
#include <epan/tap.h>
43
43
 
44
44
static gboolean tapping_is_active=FALSE;
45
 
int num_tap_filters=0;
46
45
 
47
46
typedef struct _tap_dissector_t {
48
47
        struct _tap_dissector_t *next;
70
69
typedef struct _tap_listener_t {
71
70
        struct _tap_listener_t *next;
72
71
        int tap_id;
73
 
        int needs_redraw;
 
72
        gboolean needs_redraw;
 
73
        guint flags;
74
74
        dfilter_t *code;
75
75
        void *tapdata;
76
76
        tap_reset_cb reset;
258
258
                for(tl=(tap_listener_t *)tap_listener_queue;tl;tl=tl->next){
259
259
                        tp=&tap_packet_array[i];
260
260
                        if(tp->tap_id==tl->tap_id){
261
 
                                int passed=TRUE;
 
261
                                gboolean passed=TRUE;
262
262
                                if(tl->code){
263
263
                                        passed=dfilter_apply_edt(tl->code, edt);
264
264
                                }
326
326
                if(tl->reset){
327
327
                        tl->reset(tl->tapdata);
328
328
                }
329
 
                tl->needs_redraw=1;
 
329
                tl->needs_redraw=TRUE;
330
330
        }
331
331
 
332
332
}
350
350
                                tl->draw(tl->tapdata);
351
351
                        }
352
352
                }
353
 
                tl->needs_redraw=0;
 
353
                tl->needs_redraw=FALSE;
354
354
        }
355
355
}
356
356
 
387
387
 *           message.
388
388
 */
389
389
GString *
390
 
register_tap_listener(const char *tapname, void *tapdata, const char *fstring, tap_reset_cb reset, tap_packet_cb packet, tap_draw_cb draw)
 
390
register_tap_listener(const char *tapname, void *tapdata, const char *fstring,
 
391
    guint flags, tap_reset_cb reset, tap_packet_cb packet, tap_draw_cb draw)
391
392
{
392
393
        tap_listener_t *tl;
393
394
        int tap_id;
402
403
 
403
404
        tl=g_malloc(sizeof(tap_listener_t));
404
405
        tl->code=NULL;
405
 
        tl->needs_redraw=1;
 
406
        tl->needs_redraw=TRUE;
 
407
        tl->flags=flags;
406
408
        if(fstring){
407
409
                if(!dfilter_compile(fstring, &tl->code)){
408
410
                        error_string = g_string_new("");
411
413
                            fstring, dfilter_error_msg);
412
414
                        g_free(tl);
413
415
                        return error_string;
414
 
                } else {
415
 
                        num_tap_filters++;
416
416
                }
417
417
        }
418
418
 
455
455
        if(tl){
456
456
                if(tl->code){
457
457
                        dfilter_free(tl->code);
458
 
                        num_tap_filters--;
459
458
                        tl->code=NULL;
460
459
                }
461
 
                tl->needs_redraw=1;
 
460
                tl->needs_redraw=TRUE;
462
461
                if(fstring){
463
462
                        if(!dfilter_compile(fstring, &tl->code)){
464
463
                                error_string = g_string_new("");
466
465
                                                 "Filter \"%s\" is invalid - %s",
467
466
                                                 fstring, dfilter_error_msg);
468
467
                                return error_string;
469
 
                        } else {
470
 
                                num_tap_filters++;
471
468
                        }
472
469
                }
473
470
        }
503
500
        if(tl){
504
501
                if(tl->code){
505
502
                        dfilter_free(tl->code);
506
 
                        num_tap_filters--;
507
503
                }
508
504
                g_free(tl);
509
505
        }
513
509
 
514
510
/*
515
511
 * Return TRUE if we have tap listeners, FALSE otherwise.
516
 
 * Checking "num_tap_filters" isn't the right way to check whether we need
517
 
 * to do any dissection in order to run taps, as not all taps necessarily
518
 
 * have filters, and "num_tap_filters" is the number of tap filters, not
519
 
 * the number of tap listeners; it's only the right way to check whether
520
 
 * we need to build a protocol tree when doing dissection.
521
512
 */
522
513
gboolean
523
514
have_tap_listeners(void)
540
531
 
541
532
        return FALSE;
542
533
}
 
534
 
 
535
/*
 
536
 * Return TRUE if we have any tap listeners with filters, FALSE otherwise.
 
537
 */
 
538
gboolean
 
539
have_filtering_tap_listeners(void)
 
540
{
 
541
        tap_listener_t *tl;
 
542
 
 
543
        for(tl=(tap_listener_t *)tap_listener_queue;tl;tl=tl->next){
 
544
                if(tl->code)
 
545
                        return TRUE;
 
546
        }
 
547
        return FALSE;
 
548
}
 
549
 
 
550
/*
 
551
 * Get the union of all the flags for all the tap listeners; that gives
 
552
 * an indication of whether the protocol tree, or the columns, are
 
553
 * required by any taps.
 
554
 */
 
555
guint
 
556
union_of_tap_listener_flags(void)
 
557
{
 
558
        tap_listener_t *tl;
 
559
        guint flags = 0;
 
560
 
 
561
        for(tl=(tap_listener_t *)tap_listener_queue;tl;tl=tl->next){
 
562
                flags|=tl->flags;
 
563
        }
 
564
        return flags;
 
565
}