forked from osmocom/wireshark
Make sure per-packet tap callbacks return gbooleans.
The tap API changed the return type of per-packet listener callbacks from int to gboolean back in 2009. Update a bunch of functions and some documentation accordingly. Change-Id: I79affe65db975caed3cc296a7e2985b7b9cdf4cc Reviewed-on: https://code.wireshark.org/review/9853 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
08e80b1653
commit
9557c73f81
|
@ -215,10 +215,10 @@ You can hand register_tap_listener() NULL for both (*draw) and (*reset)
|
|||
Perhaps you want an extension that will execute a certain command
|
||||
every time it sees a certain packet?
|
||||
Well, try this :
|
||||
int packet(void *tapdata,...) {
|
||||
gboolean packet(void *tapdata,...) {
|
||||
...
|
||||
system("mail ...");
|
||||
return0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
register_tap_listener("tcp", struct, "tcp.port==57", NULL, packet, NULL);
|
||||
|
@ -237,7 +237,3 @@ Well, try this :
|
|||
See tap-rpcstat.c for an example
|
||||
See tap.c as well. It contains lots of comments and descriptions on the tap
|
||||
system.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -81,11 +81,11 @@ static int tap_packet_cb_error_handler(lua_State* L) {
|
|||
}
|
||||
|
||||
|
||||
static int lua_tap_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const void *data) {
|
||||
static gboolean lua_tap_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const void *data) {
|
||||
Listener tap = (Listener)tapdata;
|
||||
int retval = 0;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (tap->packet_ref == LUA_NOREF) return 0;
|
||||
if (tap->packet_ref == LUA_NOREF) return FALSE;
|
||||
|
||||
lua_settop(tap->L,0);
|
||||
|
||||
|
@ -107,7 +107,7 @@ static int lua_tap_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt
|
|||
|
||||
switch ( lua_pcall(tap->L,3,1,1) ) {
|
||||
case 0:
|
||||
retval = (int)luaL_optinteger(tap->L,-1,1);
|
||||
retval = luaL_optinteger(tap->L,-1,1) == 0 ? FALSE : TRUE;
|
||||
break;
|
||||
case LUA_ERRRUN:
|
||||
break;
|
||||
|
|
|
@ -81,7 +81,7 @@ expert_stat_reset(void *tapdata)
|
|||
}
|
||||
|
||||
/* Process stat struct for an expert frame */
|
||||
static int
|
||||
static gboolean
|
||||
expert_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_,
|
||||
const void *pointer)
|
||||
{
|
||||
|
@ -107,12 +107,12 @@ expert_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U
|
|||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Don't store details at a lesser severity than we are interested in */
|
||||
if (severity_level < lowest_report_level) {
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* If a duplicate just bump up frequency.
|
||||
|
@ -122,7 +122,7 @@ expert_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U
|
|||
if ((strcmp(ei->protocol, entry->protocol) == 0) &&
|
||||
(strcmp(ei->summary, entry->summary) == 0)) {
|
||||
entry->frequency++;
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ expert_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U
|
|||
/* Store a copy of the expert entry */
|
||||
g_array_append_val(data->ei_array[severity_level], tmp_entry);
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Output for all of the items of one severity */
|
||||
|
|
|
@ -110,10 +110,10 @@ static gint compare_doubles(gconstpointer a, gconstpointer b)
|
|||
* "icmp" tap, the third parameter type is icmp_transaction_t.
|
||||
*
|
||||
* function returns :
|
||||
* 0: no updates, no need to call (*draw) later
|
||||
* !0: state has changed, call (*draw) sometime later
|
||||
* FALSE: no updates, no need to call (*draw) later
|
||||
* TRUE: state has changed, call (*draw) sometime later
|
||||
*/
|
||||
static int
|
||||
static gboolean
|
||||
icmpstat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *data)
|
||||
{
|
||||
icmpstat_t *icmpstat = (icmpstat_t *)tapdata;
|
||||
|
@ -121,13 +121,13 @@ icmpstat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_,
|
|||
double resp_time, *rt;
|
||||
|
||||
if (trans == NULL)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
if (trans->resp_frame) {
|
||||
resp_time = nstime_to_msec(&trans->resp_time);
|
||||
rt = g_new(double, 1);
|
||||
if (rt == NULL)
|
||||
return 0;
|
||||
return FALSE;
|
||||
*rt = resp_time;
|
||||
icmpstat->rt_list = g_slist_prepend(icmpstat->rt_list, rt);
|
||||
icmpstat->num_resps++;
|
||||
|
@ -143,9 +143,9 @@ icmpstat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_,
|
|||
} else if (trans->rqst_frame)
|
||||
icmpstat->num_rqsts++;
|
||||
else
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,10 +111,10 @@ static gint compare_doubles(gconstpointer a, gconstpointer b)
|
|||
* "icmpv6" tap, the third parameter type is icmp_transaction_t.
|
||||
*
|
||||
* function returns :
|
||||
* 0: no updates, no need to call (*draw) later
|
||||
* !0: state has changed, call (*draw) sometime later
|
||||
* FALSE: no updates, no need to call (*draw) later
|
||||
* TRUE: state has changed, call (*draw) sometime later
|
||||
*/
|
||||
static int
|
||||
static gboolean
|
||||
icmpv6stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *data)
|
||||
{
|
||||
icmpv6stat_t *icmpv6stat = (icmpv6stat_t *)tapdata;
|
||||
|
@ -122,13 +122,13 @@ icmpv6stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_
|
|||
double resp_time, *rt;
|
||||
|
||||
if (trans == NULL)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
if (trans->resp_frame) {
|
||||
resp_time = nstime_to_msec(&trans->resp_time);
|
||||
rt = g_new(double, 1);
|
||||
if (rt == NULL)
|
||||
return 0;
|
||||
return FALSE;
|
||||
*rt = resp_time;
|
||||
icmpv6stat->rt_list = g_slist_prepend(icmpv6stat->rt_list, rt);
|
||||
icmpv6stat->num_resps++;
|
||||
|
@ -144,9 +144,9 @@ icmpv6stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_
|
|||
} else if (trans->rqst_frame)
|
||||
icmpv6stat->num_rqsts++;
|
||||
else
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ expert_dlg_reset(void *tapdata)
|
|||
expert_dlg_display_reset(etd);
|
||||
}
|
||||
|
||||
static int
|
||||
static gboolean
|
||||
expert_dlg_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pointer)
|
||||
{
|
||||
expert_info_t *ei;
|
||||
|
@ -231,9 +231,9 @@ expert_dlg_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_
|
|||
g_assert_not_reached();
|
||||
}
|
||||
if(ei->severity < etd->severity_report_level) {
|
||||
return 0; /* draw not required */
|
||||
return FALSE; /* draw not required */
|
||||
} else {
|
||||
return 1; /* draw required */
|
||||
return TRUE; /* draw required */
|
||||
}
|
||||
}
|
||||
static void
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
#include <epan/dissectors/packet-ssl-utils.h>
|
||||
#endif
|
||||
|
||||
static int
|
||||
static gboolean
|
||||
ssl_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *ssl)
|
||||
{
|
||||
follow_info_t * follow_info = (follow_info_t*) tapdata;
|
||||
|
@ -73,7 +73,7 @@ ssl_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_
|
|||
|
||||
/* Skip packets without decrypted payload data. */
|
||||
pi = (SslPacketInfo*) p_get_proto_data(wmem_file_scope(), pinfo, proto_ssl, 0);
|
||||
if (!pi || !pi->appl_data) return 0;
|
||||
if (!pi || !pi->appl_data) return FALSE;
|
||||
|
||||
/* Compute the packet's sender. */
|
||||
if (follow_info->client_port == 0) {
|
||||
|
@ -117,7 +117,7 @@ ssl_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_
|
|||
follow_info->bytes_written[from] += rec->data.data_len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
/* Follow the SSL stream, if any, to which the last packet that we called
|
||||
a dissection routine on belongs (this might be the most recently
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/follow_udp.h"
|
||||
|
||||
static int
|
||||
static gboolean
|
||||
udp_queue_packet_data(void *tapdata, packet_info *pinfo,
|
||||
epan_dissect_t *edt _U_, const void *data)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ udp_queue_packet_data(void *tapdata, packet_info *pinfo,
|
|||
follow_info->bytes_written[follow_record->is_server] += follow_record->data->len;
|
||||
|
||||
follow_info->payload = g_list_append(follow_info->payload, follow_record);
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Follow the UDP stream, if any, to which the last packet that we called
|
||||
|
|
|
@ -366,7 +366,7 @@ FollowStreamDialog::readStream()
|
|||
}
|
||||
|
||||
//Copy from ui/gtk/follow_udp.c
|
||||
static int
|
||||
static gboolean
|
||||
udp_queue_packet_data(void *tapdata, packet_info *pinfo,
|
||||
epan_dissect_t *, const void *data)
|
||||
{
|
||||
|
@ -396,11 +396,11 @@ udp_queue_packet_data(void *tapdata, packet_info *pinfo,
|
|||
follow_info->bytes_written[follow_record->is_server] += follow_record->data->len;
|
||||
|
||||
follow_info->payload = g_list_append(follow_info->payload, follow_record);
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//Copy from ui/gtk/follow_ssl.c
|
||||
static int
|
||||
static gboolean
|
||||
ssl_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *, const void *ssl)
|
||||
{
|
||||
follow_info_t * follow_info = (follow_info_t*) tapdata;
|
||||
|
@ -457,7 +457,7 @@ ssl_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *, const
|
|||
follow_info->bytes_written[from] += rec->data.data_len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -312,7 +312,7 @@ add_address(address *vadd, sctp_assoc_info_t *info, guint16 direction)
|
|||
return info;
|
||||
}
|
||||
|
||||
static int
|
||||
static gboolean
|
||||
packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data)
|
||||
{
|
||||
const struct _sctp_info *sctp_info = (const struct _sctp_info *)data;
|
||||
|
@ -1177,7 +1177,7 @@ packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const voi
|
|||
info = calc_checksum(sctp_info, info);
|
||||
info->n_packets++;
|
||||
}
|
||||
return(1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "tap_export_pdu.h"
|
||||
|
||||
/* Main entry point to the tap */
|
||||
static int
|
||||
static gboolean
|
||||
export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const void *data)
|
||||
{
|
||||
const exp_pdu_data_t *exp_pdu_data = (const exp_pdu_data_t *)data;
|
||||
|
|
Loading…
Reference in New Issue