| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Macros
exceptions.h File Reference
`#include "except.h"`
`#include <wsutil/ws_assert.h>`

Go to the source code of this file.

## Macros
#define | XCEPT_GROUP_WIRESHARK 1
#define | BoundsError 1
#define | ContainedBoundsError 2
#define | ReportedBoundsError 3
#define | FragmentBoundsError 4
#define | TypeError 5
#define | DissectorError 6
#define | ScsiBoundsError 7
#define | OutOfMemoryError 8
#define | ReassemblyError 9
#define | CATCH_NONFATAL_ERRORS CATCH4(ReportedBoundsError, ContainedBoundsError, ScsiBoundsError, ReassemblyError)
#define | CATCH_BOUNDS_ERRORS
#define | CATCH_BOUNDS_AND_DISSECTOR_ERRORS
#define | EXCEPT_CAUGHT
#define | EXCEPT_RETHROWN
#define | EXCEPT_FINALLY
#define | TRY
#define | ENDTRY
#define | CATCH(x)
#define | CATCH2(x, y)
#define | CATCH3(x, y, z)
#define | CATCH4(w, x, y, z)
#define | CATCH5(v, w, x, y, z)
#define | CATCH6(u, v, w, x, y, z)
#define | CATCH7(t, u, v, w, x, y, z)
#define | CATCH_ALL
#define | FINALLY
#define | THROW(x)
#define | THROW_ON(cond, x)
#define | THROW_MESSAGE(x, y)
#define | THROW_MESSAGE_ON(cond, x, y)
#define | THROW_FORMATTED(x, ...)
#define | VTHROW_FORMATTED(x, format, args)
#define | GET_MESSAGE except_message(exc)
#define | RETHROW
#define | EXCEPT_CODE except_code(exc)
#define | CLEANUP_PUSH(f, a)
#define | CLEANUP_POP except_cleanup_pop(0)
#define | CLEANUP_CALL_AND_POP except_cleanup_pop(1)
#define | CLEANUP_PUSH_PFX(pfx, f, a)
#define | CLEANUP_POP_PFX(pfx)
#define | CLEANUP_CALL_AND_POP_PFX(pfx)

## Detailed Description

Wireshark's exceptions.

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

## Macro Definition Documentation

## ◆ BoundsError

#define BoundsError 1

Index is beyond the captured length of the tvbuff. This generally means that the capture was done with a "slice" length or "snapshot" length less than the maximum packet size, and a link-layer packet was cut short by that, so not all of the data in the link-layer packet was available.

## ◆ CATCH

#define CATCH | ( |  | x | ) |

Value:
if (except_state == 0 && exc != 0 && \
exc->except_id.except_code == (x) && \
(except_state |= EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH2

#define CATCH2 | ( |  | x,
|  |  | y )

Value:
if (except_state == 0 && exc != 0 && \
(exc->except_id.except_code == (x) || \
exc->except_id.except_code == (y)) && \
(except_state|=EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH3

#define CATCH3 | ( |  | x,
|  |  | y,
|  |  | z )

Value:
if (except_state == 0 && exc != 0 && \
(exc->except_id.except_code == (x) || \
exc->except_id.except_code == (y) || \
exc->except_id.except_code == (z)) && \
(except_state|=EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH4

#define CATCH4 | ( |  | w,
|  |  | x,
|  |  | y,
|  |  | z )

Value:
if (except_state == 0 && exc != 0 && \
(exc->except_id.except_code == (w) || \
exc->except_id.except_code == (x) || \
exc->except_id.except_code == (y) || \
exc->except_id.except_code == (z)) && \
(except_state|=EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH5

#define CATCH5 | ( |  | v,
|  |  | w,
|  |  | x,
|  |  | y,
|  |  | z )

Value:
if (except_state == 0 && exc != 0 && \
(exc->except_id.except_code == (v) || \
exc->except_id.except_code == (w) || \
exc->except_id.except_code == (x) || \
exc->except_id.except_code == (y) || \
exc->except_id.except_code == (z)) && \
(except_state|=EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH6

#define CATCH6 | ( |  | u,
|  |  | v,
|  |  | w,
|  |  | x,
|  |  | y,
|  |  | z )

Value:
if (except_state == 0 && exc != 0 && \
(exc->except_id.except_code == (u) || \
exc->except_id.except_code == (v) || \
exc->except_id.except_code == (w) || \
exc->except_id.except_code == (x) || \
exc->except_id.except_code == (y) || \
exc->except_id.except_code == (z)) && \
(except_state|=EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH7

#define CATCH7 | ( |  | t,
|  |  | u,
|  |  | v,
|  |  | w,
|  |  | x,
|  |  | y,
|  |  | z )

Value:
if (except_state == 0 && exc != 0 && \
(exc->except_id.except_code == (t) || \
exc->except_id.except_code == (u) || \
exc->except_id.except_code == (v) || \
exc->except_id.except_code == (w) || \
exc->except_id.except_code == (x) || \
exc->except_id.except_code == (y) || \
exc->except_id.except_code == (z)) && \
(except_state|=EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH_ALL

#define CATCH_ALL

Value:
if (except_state == 0 && exc != 0 && \
(except_state|=EXCEPT_CAUGHT)) \
/* user's code goes here */

## ◆ CATCH_BOUNDS_AND_DISSECTOR_ERRORS

#define CATCH_BOUNDS_AND_DISSECTOR_ERRORS

Value:
CATCH7(BoundsError, FragmentBoundsError, ContainedBoundsError, \
ReportedBoundsError, ScsiBoundsError, DissectorError, \
ReassemblyError)
BoundsError
#define BoundsError
Definition exceptions.h:25
ReassemblyError
#define ReassemblyError
Definition exceptions.h:99
ScsiBoundsError
#define ScsiBoundsError
Definition exceptions.h:84
ReportedBoundsError
#define ReportedBoundsError
Definition exceptions.h:47
FragmentBoundsError
#define FragmentBoundsError
Definition exceptions.h:57
DissectorError
#define DissectorError
Definition exceptions.h:73
ContainedBoundsError
#define ContainedBoundsError
Definition exceptions.h:38

## ◆ CATCH_BOUNDS_ERRORS

#define CATCH_BOUNDS_ERRORS

Value:
CATCH5(BoundsError, FragmentBoundsError, ReportedBoundsError, \
ContainedBoundsError, ScsiBoundsError)

## ◆ CLEANUP_CALL_AND_POP_PFX

#define CLEANUP_CALL_AND_POP_PFX | ( |  | pfx | ) |

Value:
except_cleanup_pop_pfx(pfx,1)

## ◆ CLEANUP_POP_PFX

#define CLEANUP_POP_PFX | ( |  | pfx | ) |

Value:
except_cleanup_pop_pfx(pfx,0)

## ◆ CLEANUP_PUSH

#define CLEANUP_PUSH | ( |  | f,
|  |  | a )

Value:
except_cleanup_push((f),(a))

## ◆ CLEANUP_PUSH_PFX

#define CLEANUP_PUSH_PFX | ( |  | pfx,
|  |  | f,
|  |  | a )

Value:
except_cleanup_push_pfx(pfx,(f),(a))

## ◆ ContainedBoundsError

#define ContainedBoundsError 2

Index is beyond the contained length of the tvbuff. This generally means that the tvbuff was constructed as a subset of a parent tvbuff, based on a length specified by data in the packet, but the length in question runs past the reported length of the data in the parent tvbuff. That means that the packet is invalid, as the data indicating the length says the length exceeds what's contained in the packet. It is therefore currently reported as a "Malformed packet".

## ◆ DissectorError

#define DissectorError 6

A bug was detected in a dissector.

DO NOT throw this with THROW(); that means that no details about the dissector error will be reported. (Instead, the message will blame you for not providing details.)

Instead, use the DISSECTOR_ASSERT(), etc. macros in epan/proto.h.

## ◆ ENDTRY

#define ENDTRY

Value:
/* rethrow the exception if necessary */ \
if(!(except_state&EXCEPT_CAUGHT) && exc != 0) \
except_rethrow(exc); \
except_try_pop();\
}

## ◆ EXCEPT_CAUGHT

#define EXCEPT_CAUGHT

Value:
1 /* exception has been caught, no need to rethrow at
* ENDTRY */

## ◆ EXCEPT_FINALLY

#define EXCEPT_FINALLY

Value:
4 /* we've entered the FINALLY block - don't allow
* RETHROW, and don't reenter FINALLY if a
* different exception is thrown */

## ◆ EXCEPT_RETHROWN

#define EXCEPT_RETHROWN

Value:
2 /* the exception was rethrown from a CATCH
* block. Don't reenter the CATCH blocks, but do
* execute FINALLY and rethrow at ENDTRY */

## ◆ FINALLY

#define FINALLY

Value:
if( !(except_state & EXCEPT_FINALLY) && (except_state|=EXCEPT_FINALLY)) \
/* user's code goes here */

## ◆ FragmentBoundsError

#define FragmentBoundsError 4

Index is beyond the contained length, and possibly the reported length, of the tvbuff, but we believe it is an unreassembled fragment, either because the "this is an unreassembled fragment" flag or pinfo->fragmented is set. This means that the packet wasn't reassembled, but could possibly be correctly dissected if reassembly preferences were changed. It is therefore not reported as a "Malformed packet".

## ◆ OutOfMemoryError

#define OutOfMemoryError 8

Running out of memory. A dissector tried to allocate memory but that failed.

## ◆ ReassemblyError

#define ReassemblyError 9

The reassembly state machine was passed a bad fragment offset, or other similar issues. We used to use DissectorError in these cases, but they're not necessarily the dissector's fault - if the packet contains a bad fragment offset, the dissector shouldn't have to figure that out by itself since that's what the reassembly machine is for.

## ◆ ReportedBoundsError

#define ReportedBoundsError 3

Index is beyond the reported length of the tvbuff. This generally means that the packet is invalid, i.e. whatever code constructed the packet and put it on the wire didn't put enough data into it. It is therefore currently reported as a "Malformed packet".

## ◆ RETHROW

#define RETHROW

Value:
{ \
/* check we're in a catch block */ \
ws_assert(except_state == EXCEPT_CAUGHT); \
/* we can't use except_rethrow here, as that pops a catch block \
* off the stack, and we don't want to do that, because we want to \
* execute the FINALLY {} block first. \
* except_throw doesn't provide an interface to rethrow an existing \
* exception; however, longjmping back to except_try_push() has the \
* desired effect. \
* \
* Note also that THROW and RETHROW should provide much the same \
* functionality in terms of which blocks to enter, so any messing \
* about with except_state in here would indicate that THROW is \
* doing the wrong thing. \
*/ \
longjmp(except_ch.except_jmp,1); \
}

## ◆ ScsiBoundsError

#define ScsiBoundsError 7

Index is out of range. An attempt was made to read past the end of a buffer. This error is specific to SCSI data transfers where for some CDBs it is normal that the data PDU might be short. I.e. ReportLuns initially called with allocation_length=8, just enough to get the "size" of lun list back after which the initiator will reissue the command with an allocation_length that is big enough.

## ◆ THROW

#define THROW | ( |  | x | ) |

Value:
except_throw(XCEPT_GROUP_WIRESHARK, (x), NULL)

## ◆ THROW_FORMATTED

#define THROW_FORMATTED | ( |  | x,
|  |  | ... )

Value:
except_throwf(XCEPT_GROUP_WIRESHARK, (x), __VA_ARGS__)

## ◆ THROW_MESSAGE

#define THROW_MESSAGE | ( |  | x,
|  |  | y )

Value:
except_throw(XCEPT_GROUP_WIRESHARK, (x), (y))

## ◆ THROW_MESSAGE_ON

#define THROW_MESSAGE_ON | ( |  | cond,
|  |  | x,
|  |  | y )

Value:
G_STMT_START { \
if ((cond)) \
except_throw(XCEPT_GROUP_WIRESHARK, (x), (y)); \
} G_STMT_END

## ◆ THROW_ON

#define THROW_ON | ( |  | cond,
|  |  | x )

Value:
G_STMT_START { \
if ((cond)) \
except_throw(XCEPT_GROUP_WIRESHARK, (x), NULL); \
} G_STMT_END

## ◆ TRY

#define TRY

Value:
{\
except_t *volatile exc; \
volatile int except_state = 0; \
static const except_id_t catch_spec[] = { \
{ XCEPT_GROUP_WIRESHARK, XCEPT_CODE_ANY } }; \
except_try_push(catch_spec, 1, &exc); \
\
if(except_state & EXCEPT_CAUGHT) \
except_state |= EXCEPT_RETHROWN; \
except_state &= ~EXCEPT_CAUGHT; \
\
if (except_state == 0 && exc == 0) \
/* user's code goes here */
except_id_t
Identifies an exception class by group and code.
Definition except.h:55
except_t
Represents a thrown exception instance, including its identity, message, and dynamic data.
Definition except.h:64

## ◆ TypeError

#define TypeError 5

During dfilter parsing

## ◆ VTHROW_FORMATTED

#define VTHROW_FORMATTED | ( |  | x,
|  |  | format,
|  |  | args )

Value:
except_vthrowf(XCEPT_GROUP_WIRESHARK, (x), format, args)