1 | /* $Id: debug.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NAT - debug helpers (declarations/defines).
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * This code is based on:
|
---|
30 | *
|
---|
31 | * Copyright (c) 1995 Danny Gasparovski.
|
---|
32 | *
|
---|
33 | * Please read the file COPYRIGHT for the
|
---|
34 | * terms and conditions of the copyright.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef _DEBUG_H_
|
---|
38 | #define _DEBUG_H_
|
---|
39 |
|
---|
40 | #include <VBox/log.h>
|
---|
41 | /* we've excluded stdio.h */
|
---|
42 | #define FILE void
|
---|
43 |
|
---|
44 | int debug_init (PNATState);
|
---|
45 | void ipstats (PNATState);
|
---|
46 | void tcpstats (PNATState);
|
---|
47 | void udpstats (PNATState);
|
---|
48 | void icmpstats (PNATState);
|
---|
49 | void mbufstats (PNATState);
|
---|
50 | void sockstats (PNATState);
|
---|
51 |
|
---|
52 | #ifdef LOG_ENABLED
|
---|
53 | # define TCP_STATE_SWITCH_TO(tp, new_tcp_state) \
|
---|
54 | do { \
|
---|
55 | Log2(("%R[tcpcb793] switch to %R[tcpstate] -> %R[tcpstate]\n", (tp), (tp->t_state) ,(new_tcp_state))); \
|
---|
56 | if ((tp)->t_socket) \
|
---|
57 | Log2(("%R[tcpcb793] %R[natsock]\n", (tp), (tp)->t_socket)); \
|
---|
58 | (tp)->t_state = (new_tcp_state); \
|
---|
59 | } while (0)
|
---|
60 | #else
|
---|
61 | # define TCP_STATE_SWITCH_TO(tp, new_tcp_state) (tp)->t_state = (new_tcp_state)
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | /* TCP CB state validity macro definitions
|
---|
65 | * we need to be sure that TCP is in right state.
|
---|
66 | * TCP_ACCEPTABLE_STATEX(tp, (X-states here))
|
---|
67 | */
|
---|
68 | #ifdef DEBUG_vvl
|
---|
69 | # define TCP_ACCEPTABLE_STATE1(tp, tcp_state1) Assert((tp)->t_state == (tcp_state))
|
---|
70 | # define TCP_ACCEPTABLE_STATE2(tp, tcp_state1, tcp_state2) \
|
---|
71 | Assert( (tp)->t_state == (tcp_state1) \
|
---|
72 | || (tp)->t_state == (tcp_state2) ); \
|
---|
73 | #else
|
---|
74 | # define TCP_ACCEPTABLE_STATE1(tp, tcp_state1) do { } while(0)
|
---|
75 | # define TCP_ACCEPTABLE_STATE2(tp, tcp_state1, tcp_state2) do { } while(0)
|
---|
76 | #endif
|
---|
77 | #endif
|
---|