replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
[metze/wireshark/wip.git] / ui / mcast_stream.h
1 /* mcast_stream.h
2  *
3  * Copyright 2006, Iskratel , Slovenia
4  * By Jakob Bratkovic <j.bratkovic@iskratel.si> and
5  * Miha Jemec <m.jemec@iskratel.si>
6  *
7  * based on rtp_stream.h
8  * Copyright 2003, Alcatel Business Systems
9  * By Lars Ruoff <lars.ruoff@gmx.net>
10  *
11  * Wireshark - Network traffic analyzer
12  * By Gerald Combs <gerald@wireshark.org>
13  * Copyright 1998 Gerald Combs
14  *
15  * SPDX-License-Identifier: GPL-2.0-or-later */
16
17 #ifndef __MCAST_STREAM_H__
18 #define __MCAST_STREAM_H__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23
24 #include <epan/tap.h>
25
26 #define MAX_SPEED 200000
27
28 /* typedefs for sliding window and buffer size */
29 typedef struct buffer{
30     nstime_t *buff;            /* packet times */
31     gint32 first;              /* pointer to the first element */
32     gint32 last;               /* pointer to the last element */
33     gint32 burstsize;          /* current burst */
34     gint32 topburstsize;       /* maximum burst in the refresh interval*/
35     gint32 count;              /* packet counter */
36     gint32 burststatus;        /* burst status */
37     gint32 numbursts;          /* number of bursts */
38     gint32 buffusage;          /* buffer usage */
39     gint32 buffstatus;         /* buffer status */
40     gint32 numbuffalarms;      /* number of alarms triggered by buffer underruns */
41     gint32 topbuffusage;       /* top buffer usage in refresh interval */
42     double maxbw;              /* Maximum bandwidth usage. Bits/s */
43 } t_buffer;
44
45
46 /* defines an mcast stream */
47 typedef struct _mcast_stream_info {
48     address src_addr;
49     guint16 src_port;
50     address dest_addr;
51     guint16 dest_port;
52     guint32 npackets;
53     double  apackets;
54     guint32 total_bytes;
55     double  average_bw;         /* Bits/s */
56
57     guint32 first_frame_num; /* frame number of first frame */
58     /* start of recording (GMT) of this stream */
59     nstime_t start_abs;        /* absolute stream start time */
60     nstime_t start_rel;        /* stream start time relative to first packet in capture */
61     nstime_t stop_rel;         /* stream stop time relative to first packet in capture */
62     guint16 vlan_id;
63
64     /*for the sliding window */
65     t_buffer element;
66
67 } mcast_stream_info_t;
68
69 typedef struct _mcaststream_tapinfo mcaststream_tapinfo_t;
70
71 typedef void (*mcaststream_tap_reset_cb)(mcaststream_tapinfo_t *tapinfo);
72 typedef void (*mcaststream_tap_draw_cb)(mcaststream_tapinfo_t *tapinfo);
73
74 /* structure that holds the information about all detected streams */
75 /* struct holding all information of the tap */
76 struct _mcaststream_tapinfo {
77     gpointer user_data;     /* User data pointer */
78     mcaststream_tap_reset_cb tap_reset; /**< tap reset callback */
79     mcaststream_tap_draw_cb tap_draw;   /**< tap draw callback */
80     GList*  strinfo_list;   /* list of mcast_stream_info_t */
81     guint32 npackets;       /* total number of mcast packets of all streams */
82     mcast_stream_info_t* allstreams; /* structure holding information common for all streams */
83
84     gboolean is_registered; /* if the tap listener is currently registered or not */
85 };
86
87
88 extern gint32  mcast_stream_trigger;
89 extern gint32  mcast_stream_bufferalarm;
90 extern guint16 mcast_stream_burstint;
91 extern gint32  mcast_stream_emptyspeed;
92 extern gint32  mcast_stream_cumulemptyspeed;
93
94 /****************************************************************************/
95 /* INTERFACE */
96
97 /*
98 * Registers the mcast_streams tap listener (if not already done).
99 * From that point on, the Mcast streams list will be updated with every redissection.
100 * This function is also the entry point for the initialization routine of the tap system.
101 * So whenever mcast_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
102 * If not, it will be registered on demand by the mcast_streams and mcast_analysis functions that need it.
103 */
104 void register_tap_listener_mcast_stream(mcaststream_tapinfo_t *tapinfo);
105
106 /*
107 * Removes the mcast_streams tap listener (if not already done)
108 * From that point on, the Mcast streams list won't be updated any more.
109 */
110 void remove_tap_listener_mcast_stream(mcaststream_tapinfo_t *tapinfo);
111
112 /*
113 * Cleans up memory of mcast streams tap.
114 */
115 void mcaststream_reset(mcaststream_tapinfo_t *tapinfo);
116
117 /*
118 * Scans all packets for Mcast streams and updates the Mcast streams list.
119 * (redissects all packets)
120 */
121 void mcaststream_scan(mcaststream_tapinfo_t *tapinfo, capture_file *cap_file);
122
123 #ifdef __cplusplus
124 }
125 #endif /* __cplusplus */
126
127 #endif /* __MCAST_STREAM_H__ */
128
129 /*
130  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
131  *
132  * Local variables:
133  * c-basic-offset: 4
134  * tab-width: 8
135  * indent-tabs-mode: nil
136  * End:
137  *
138  * vi: set shiftwidth=4 tabstop=8 expandtab:
139  * :indentSize=4:tabSize=8:noTabs=true:
140  */