* Save TCP state at a given moment; optionally, both tcpcb and TCP packet * header state will be saved. */
| 96 | * header state will be saved. |
| 97 | */ |
| 98 | void |
| 99 | tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen, |
| 100 | struct tcphdr *th, int req) |
| 101 | { |
| 102 | #ifdef INET6 |
| 103 | int isipv6; |
| 104 | #endif /* INET6 */ |
| 105 | tcp_seq seq, ack; |
| 106 | int len, flags; |
| 107 | struct tcp_debug *td; |
| 108 | |
| 109 | mtx_lock(&tcp_debug_mtx); |
| 110 | td = &tcp_debug[tcp_debx++]; |
| 111 | if (tcp_debx == TCP_NDEBUG) |
| 112 | tcp_debx = 0; |
| 113 | bzero(td, sizeof(*td)); |
| 114 | #ifdef INET6 |
| 115 | isipv6 = (ipgen != NULL && ((struct ip *)ipgen)->ip_v == 6) ? 1 : 0; |
| 116 | #endif /* INET6 */ |
| 117 | td->td_family = |
| 118 | #ifdef INET6 |
| 119 | (isipv6 != 0) ? AF_INET6 : |
| 120 | #endif |
| 121 | AF_INET; |
| 122 | #ifdef INET |
| 123 | td->td_time = iptime(); |
| 124 | #endif |
| 125 | td->td_act = act; |
| 126 | td->td_ostate = ostate; |
| 127 | td->td_tcb = (caddr_t)tp; |
| 128 | if (tp != NULL) |
| 129 | td->td_cb = *tp; |
| 130 | if (ipgen != NULL) { |
| 131 | switch (td->td_family) { |
| 132 | #ifdef INET |
| 133 | case AF_INET: |
| 134 | bcopy(ipgen, &td->td_ti.ti_i, sizeof(td->td_ti.ti_i)); |
| 135 | break; |
| 136 | #endif |
| 137 | #ifdef INET6 |
| 138 | case AF_INET6: |
| 139 | bcopy(ipgen, td->td_ip6buf, sizeof(td->td_ip6buf)); |
| 140 | break; |
| 141 | #endif |
| 142 | } |
| 143 | } |
| 144 | if (th != NULL) { |
| 145 | switch (td->td_family) { |
| 146 | #ifdef INET |
| 147 | case AF_INET: |
| 148 | td->td_ti.ti_t = *th; |
| 149 | break; |
| 150 | #endif |
| 151 | #ifdef INET6 |
| 152 | case AF_INET6: |
| 153 | td->td_ti6.th = *th; |
| 154 | break; |
| 155 | #endif |
no test coverage detected