| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: pcg_debug.vr |
| 4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved |
| 5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
| 6 | // |
| 7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 8 | // |
| 9 | // This program is free software; you can redistribute it and/or modify |
| 10 | // it under the terms of the GNU General Public License as published by |
| 11 | // the Free Software Foundation; version 2 of the License. |
| 12 | // |
| 13 | // This program is distributed in the hope that it will be useful, |
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // GNU General Public License for more details. |
| 17 | // |
| 18 | // You should have received a copy of the GNU General Public License |
| 19 | // along with this program; if not, write to the Free Software |
| 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | // |
| 22 | // For the avoidance of doubt, and except that if any non-GPL license |
| 23 | // choice is available it will apply instead, Sun elects to use only |
| 24 | // the General Public License version 2 (GPLv2) at this time for any |
| 25 | // software where a choice of GPL license versions is made |
| 26 | // available with the language indicating that GPLv2 or any later version |
| 27 | // may be used, or where a choice of which version of the GPL is applied is |
| 28 | // otherwise unspecified. |
| 29 | // |
| 30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 31 | // CA 95054 USA or visit www.sun.com if you need additional information or |
| 32 | // have any questions. |
| 33 | // |
| 34 | // ========== Copyright Header End ============================================ |
| 35 | task display_buf( byte_array buf, integer hwlen, (integer ifedx=0)) { |
| 36 | integer ptr=0; |
| 37 | integer tunneling_ipv4 =0; |
| 38 | integer tunneling_ipv6 =0; |
| 39 | integer buf_shift; |
| 40 | integer n; |
| 41 | bit [15:0] len; |
| 42 | bit [7:0] flag_bit; |
| 43 | bit [79:0] id; |
| 44 | integer token; |
| 45 | |
| 46 | printf("\n\n______________________________________________________________\n"); |
| 47 | printf("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n\n"); |
| 48 | |
| 49 | if(ifedx==1) printf("This is an INTER FEDX packet\n\n"); |
| 50 | |
| 51 | printf("____________ Hex Dump ____________\n"); |
| 52 | for(n=0;n<hwlen;n++) { |
| 53 | if( !(n % 16) ) printf("\n%d: ",n); |
| 54 | printf("%h ", buf.val[ptr++]); |
| 55 | } |
| 56 | printf("\n__________________________________\n\n"); |
| 57 | |
| 58 | ptr=0; |
| 59 | |
| 60 | if(ifedx==1) { |
| 61 | printf("Interfedx Control Word: %h\n\n", {buf.val[ptr+1], buf.val[ptr]} ); |
| 62 | ptr=ptr+2; |
| 63 | } |
| 64 | |
| 65 | |
| 66 | // L2 Header Info |
| 67 | |
| 68 | printf(" L2 Header\n"); |
| 69 | printf("+---------------\n"); |
| 70 | |
| 71 | printf("| Destination Address: %h.%h.%h.%h.%h.%h\n", buf.val[ptr++], buf.val[ptr++], |
| 72 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 73 | printf("| Source Address: %h.%h.%h.%h.%h.%h\n", buf.val[ptr++], buf.val[ptr++], |
| 74 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 75 | |
| 76 | len = {buf.val[ptr++], buf.val[ptr++]}; |
| 77 | |
| 78 | |
| 79 | // check if it is an Ethernet Tagged (802.Q) Frame |
| 80 | if( len == TPID_8021Q ) { |
| 81 | |
| 82 | // check to see if it is an LLC-SNAP packet |
| 83 | if( {buf.val[ptr+4], buf.val[ptr+5], buf.val[ptr+6]} == LLC_SNAP ) { |
| 84 | printf("| L2 Header Type: 802.1Q Tagged LLC-SNAP Ethernet Header\n"); |
| 85 | printf("| TPID: %0h\n", len ); |
| 86 | printf("| TCI: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 87 | |
| 88 | len = {buf.val[ptr++], buf.val[ptr++]}; |
| 89 | |
| 90 | printf("| LEN/TYPE: 0x%h(%0d)\n", len, len ); |
| 91 | printf("| LLC: %h\n", {buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] }); |
| 92 | printf("| SNAP: %h\n", {buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 93 | buf.val[ptr++], buf.val[ptr++] } ); |
| 94 | // Store L2 pkt type |
| 95 | len = {buf.val[ptr - 2], buf.val[ptr - 1]}; |
| 96 | } |
| 97 | else { |
| 98 | // it is not an LLC-SNAP packet |
| 99 | |
| 100 | printf("| L2 Header Type: 802.1Q Tagged Ethernet Header\n"); |
| 101 | printf("| TPID: %0h\n", len ); |
| 102 | printf("| TCI: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 103 | |
| 104 | len = {buf.val[ptr++], buf.val[ptr++]}; |
| 105 | |
| 106 | printf("| TYPE/LEN: 0x%h(%d)\n", len, len); |
| 107 | } |
| 108 | } |
| 109 | else if ( len == CNTL_FRAME ) { |
| 110 | // Check to see if it is a MAC control Frame |
| 111 | |
| 112 | printf("| L2 Header Type: MAC Control Frame Header\n"); |
| 113 | printf("| Type: %h\n", len ); |
| 114 | } |
| 115 | else { |
| 116 | // packet is a regular 802.3 Ethernet packet |
| 117 | printf("| L2 Header Type: 802.3 Ethernet Header\n"); |
| 118 | printf("| Data Length/Type: 0x%h(%0d)\n", len, len); |
| 119 | } |
| 120 | |
| 121 | token = { buf.val[ptr], buf.val[ptr+1] }; |
| 122 | |
| 123 | |
| 124 | // Check to see if it has an L3 Header |
| 125 | if(len>16'h0600 & len != CNTL_FRAME) { |
| 126 | len = -1; |
| 127 | |
| 128 | // check version field to see whether it is an IPv4 or IPv6 packet |
| 129 | if( buf.val[ptr - 2 ] == 8'h08 ) { |
| 130 | |
| 131 | // it is an IPv4 packet |
| 132 | |
| 133 | // Check protocol field to see if it is an IPSec packet |
| 134 | if( buf.val[ptr + 9] == AH_PROTO) { |
| 135 | // Authetication Header (AH) option present |
| 136 | printf("+-------------------------------------\n"); |
| 137 | printf(" L3 Header-- Type: IPv4, IPSec: AH\n"); |
| 138 | printf("+--------------------------------------\n"); |
| 139 | } |
| 140 | else if( buf.val[ptr + 9] == ESP_PROTO) { |
| 141 | // Encapsulating Security Payload (ESP) option present |
| 142 | printf("+-------------------------------------\n"); |
| 143 | printf(" L3 Header-- Type: IPv4, IPSec: ESP\n"); |
| 144 | printf("+--------------------------------------\n"); |
| 145 | } |
| 146 | else if( buf.val[ptr + 9] == IP_V4_PROTO) { |
| 147 | // Tunneled IP packet |
| 148 | printf("+-------------------------------------\n"); |
| 149 | printf(" L3 Header-- Type: Tunnel (IPv4/IPv4)\n"); |
| 150 | printf("+--------------------------------------\n"); |
| 151 | printf("| IP Header Tunnel Layer 1: IPv4\n| \n"); |
| 152 | |
| 153 | tunneling_ipv4 = 1; |
| 154 | } |
| 155 | else if( buf.val[ptr + 9] == IP_V6_PROTO) { |
| 156 | // Tunneled IP packet |
| 157 | printf("+-------------------------------------\n"); |
| 158 | printf(" L3 Header-- Type: Tunnel (IPv4/IPv6)\n"); |
| 159 | printf("+--------------------------------------\n"); |
| 160 | printf("| IP Header Tunnel Layer 1: IPv4\n| \n"); |
| 161 | |
| 162 | tunneling_ipv6 = 1; |
| 163 | } |
| 164 | else { |
| 165 | // Regular IP packet |
| 166 | printf("+-------------------------------------\n"); |
| 167 | printf(" L3 Header-- Type: IPv4\n"); |
| 168 | printf("+--------------------------------------\n"); |
| 169 | } |
| 170 | ptr--; |
| 171 | ptr--; |
| 172 | |
| 173 | display_class(buf, ptr); |
| 174 | |
| 175 | // |
| 176 | // L3 Header parsing |
| 177 | // |
| 178 | printf("| IPV4 Checksum: %h%h\n", buf.val[ptr-2], buf.val[ptr-1] ); |
| 179 | |
| 180 | printf("| IP SRC Address: %h.%h.%h.%h\n", |
| 181 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 182 | printf("| IP DST Address: %h.%h.%h.%h\n", |
| 183 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 184 | |
| 185 | // Check if tunneling present |
| 186 | if( tunneling_ipv4 ) { |
| 187 | // IPv4/IPv4 Tunneling |
| 188 | |
| 189 | printf("| ----------- \n|\n"); |
| 190 | printf("| IP Header Tunnel Layer 2: IPv4:\n"); |
| 191 | printf("| \n"); |
| 192 | |
| 193 | ptr--; |
| 194 | ptr--; |
| 195 | |
| 196 | display_class(buf, ptr); |
| 197 | |
| 198 | printf("| IP SRC Address: %h.%h.%h.%h\n", |
| 199 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 200 | printf("| IP DST Address: %h.%h.%h.%h\n", |
| 201 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 202 | |
| 203 | } |
| 204 | else if( tunneling_ipv6) { |
| 205 | // IPv4/IPv6 Tunneling |
| 206 | |
| 207 | printf("| ----------- \n|\n"); |
| 208 | printf("| IP Header Tunnel Layer 2: IPv6:\n"); |
| 209 | printf("| \n"); |
| 210 | |
| 211 | ptr--; |
| 212 | ptr--; |
| 213 | |
| 214 | display_class_ipv6(buf, ptr); |
| 215 | |
| 216 | printf("| Payload Len: 0x%h(%d)\n", buf.val[ptr++], buf.val[ptr++]); |
| 217 | printf("| Next Header: 0x%h\n", buf.val[ptr++]); |
| 218 | printf("| Hop Limit : 0x%h\n", buf.val[ptr++]); |
| 219 | printf("| IP SRC Address: %h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h\n", |
| 220 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 221 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 222 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 223 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 224 | printf("| IP DST Address: %h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h\n", |
| 225 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 226 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 227 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 228 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 229 | } |
| 230 | |
| 231 | |
| 232 | // |
| 233 | // L4 Header Parsing |
| 234 | // |
| 235 | |
| 236 | // Determine location of protocol/next header field in buffer |
| 237 | if( tunneling_ipv6 ) |
| 238 | // Tunnel layer 2 of hdr was IPv6 |
| 239 | buf_shift = 34; |
| 240 | else |
| 241 | buf_shift = 11; |
| 242 | |
| 243 | // Check Protocol field to see if it has a L4 Header |
| 244 | if( buf.val[ptr - buf_shift ] == UDP_PROTO) { |
| 245 | // UDP L4 pkt present |
| 246 | printf("+-------------------------------------\n"); |
| 247 | printf(" L4 Header-- Type: UDP \n"); |
| 248 | printf("+--------------------------------------\n"); |
| 249 | printf("| UDP SRC Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 250 | printf("| UDP DST Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 251 | |
| 252 | token = { buf.val[ptr + 4], buf.val[ptr + 5] }; |
| 253 | } |
| 254 | else if( buf.val[ptr - buf_shift ] == TCP_PROTO) { |
| 255 | // TCP L4 pkt present |
| 256 | printf("+-------------------------------------\n"); |
| 257 | printf(" L4 Header-- Type: TCP\n"); |
| 258 | printf("+--------------------------------------\n"); |
| 259 | |
| 260 | printf("| TCP SRC Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 261 | printf("| TCP DST Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 262 | printf("| TCP Sequence #: %h\n", {buf.val[ptr++], buf.val[ptr++], |
| 263 | buf.val[ptr++], buf.val[ptr++]} ); |
| 264 | printf("| TCP ACK #: %h\n", {buf.val[ptr++], buf.val[ptr++], |
| 265 | buf.val[ptr++], buf.val[ptr++]} ); |
| 266 | |
| 267 | // increment ptr to pass viewing of uncessary bits |
| 268 | ptr += 1; |
| 269 | |
| 270 | flag_bit = buf.val[ptr++]; |
| 271 | |
| 272 | printf("| TCP Flag bits: URG:%b ACK:%b PSH:%b RST:%b SYN:%b FIN:%b\n", |
| 273 | flag_bit[5], flag_bit[4], flag_bit[3], flag_bit[2], flag_bit[1], flag_bit[0]); |
| 274 | printf("| Window Size: %h\n", {buf.val[ptr++], buf.val[ptr++]}); |
| 275 | printf("| TCP Checksum: %h\n", {buf.val[ptr++], buf.val[ptr++]}); |
| 276 | printf("+---------------\n"); |
| 277 | |
| 278 | token = { buf.val[ptr + 2], buf.val[ptr+3] }; |
| 279 | //token = { buf.val[ptr + 4], buf.val[ptr+5] }; |
| 280 | } // end else if |
| 281 | else { |
| 282 | // No L4 pkt present |
| 283 | token = { buf.val[ptr], buf.val[ptr+1] }; |
| 284 | } |
| 285 | } // end if (IPv4 pkt) |
| 286 | else { |
| 287 | |
| 288 | // it is an IPv6 packet |
| 289 | |
| 290 | // Check Next Header field to see if it is an IPSec packet |
| 291 | if( buf.val[ptr + 6] == AH_PROTO) { |
| 292 | // Authetication Header (AH) option present |
| 293 | printf("+-------------------------------------\n"); |
| 294 | printf(" L3 Header-- Type: IPv6, IPSec: AH\n"); |
| 295 | printf("+--------------------------------------\n"); |
| 296 | } |
| 297 | else if( buf.val[ptr + 6] == ESP_PROTO) { |
| 298 | // Encapsulating Security Payload (ESP) option present |
| 299 | printf("+-------------------------------------\n"); |
| 300 | printf(" L3 Header-- Type: IPv6, IPSec: ESP\n"); |
| 301 | printf("+--------------------------------------\n"); |
| 302 | } |
| 303 | else if( buf.val[ptr + 6] == IP_V4_PROTO) { |
| 304 | // Tunneled IP packet |
| 305 | printf("+-------------------------------------\n"); |
| 306 | printf(" L3 Header-- Type: Tunnel (IPv6/IPv4)\n"); |
| 307 | printf("+--------------------------------------\n"); |
| 308 | printf("| IP Header Tunnel Layer 1: IPv6\n"); |
| 309 | printf("| \n"); |
| 310 | |
| 311 | tunneling_ipv4 = 1; |
| 312 | } |
| 313 | else if( buf.val[ptr + 6] == IP_V6_PROTO) { |
| 314 | // Tunneld IP packet |
| 315 | printf("+-------------------------------------\n"); |
| 316 | printf(" L3 Header-- Type: Tunnel (IPv6/IPv6)\n"); |
| 317 | printf("+--------------------------------------\n"); |
| 318 | printf("| IP Header Tunnel Layer 1: IPv6\n"); |
| 319 | printf("| \n"); |
| 320 | |
| 321 | tunneling_ipv6 = 1; |
| 322 | } |
| 323 | else { |
| 324 | // Regular IP packet |
| 325 | printf("+-------------------------------------\n"); |
| 326 | printf(" L3 Header-- Type: IPv6\n"); |
| 327 | printf("+--------------------------------------\n"); |
| 328 | } |
| 329 | ptr--; |
| 330 | ptr--; |
| 331 | |
| 332 | display_class_ipv6(buf, ptr); |
| 333 | |
| 334 | printf("| Payload Len: 0x%h(%d)\n", buf.val[ptr++], buf.val[ptr++]); |
| 335 | printf("| Next Header: 0x%h\n", buf.val[ptr++]); |
| 336 | printf("| Hop Limit : 0x%h\n", buf.val[ptr++]); |
| 337 | printf("| IP SRC Address: %h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h\n", |
| 338 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 339 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 340 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 341 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 342 | printf("| IP DST Address: %h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h\n", |
| 343 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 344 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 345 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 346 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 347 | |
| 348 | // Check if tunneling present |
| 349 | if( tunneling_ipv4 ) { |
| 350 | // IPv6/IPv4 Tunneling |
| 351 | |
| 352 | printf("| ----------- \n|\n"); |
| 353 | printf("| IP Header Tunnel Layer 2: IPv4:\n"); |
| 354 | printf("| \n"); |
| 355 | |
| 356 | ptr--; |
| 357 | ptr--; |
| 358 | |
| 359 | display_class(buf, ptr); |
| 360 | |
| 361 | printf("| IP SRC Address: %h.%h.%h.%h\n", |
| 362 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 363 | printf("| IP DST Address: %h.%h.%h.%h\n", |
| 364 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 365 | |
| 366 | } |
| 367 | else if( tunneling_ipv6) { |
| 368 | // IPv6/IPv6 Tunneling |
| 369 | |
| 370 | printf("| ----------- \n|\n"); |
| 371 | printf("| IP Header Tunnel Layer 2: IPv6:\n"); |
| 372 | printf("| \n"); |
| 373 | |
| 374 | ptr--; |
| 375 | ptr--; |
| 376 | |
| 377 | display_class_ipv6(buf, ptr); |
| 378 | |
| 379 | printf("| Payload Len: 0x%h(%d)\n", buf.val[ptr++], buf.val[ptr++]); |
| 380 | printf("| Next Header: 0x%h\n", buf.val[ptr++]); |
| 381 | printf("| Hop Limit : 0x%h\n", buf.val[ptr++]); |
| 382 | printf("| IP SRC Address: %h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h\n", |
| 383 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 384 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 385 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 386 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 387 | printf("| IP DST Address: %h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h:%h%h\n", |
| 388 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 389 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 390 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], |
| 391 | buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] ); |
| 392 | } |
| 393 | |
| 394 | // |
| 395 | // L4 Header Parsing |
| 396 | // |
| 397 | |
| 398 | // Determine location of protocol/next header field in buffer |
| 399 | if( tunneling_ipv4 ) |
| 400 | // Tunnel layer 2 of hdr was IPv4 |
| 401 | buf_shift = 11; |
| 402 | else |
| 403 | buf_shift = 34; |
| 404 | |
| 405 | if( buf.val[ptr - buf_shift ] == UDP_PROTO) { |
| 406 | // UDP L4 pkt present |
| 407 | |
| 408 | printf("+-------------------------------------\n"); |
| 409 | printf(" L4 Header-- Type: UDP \n"); |
| 410 | printf("+--------------------------------------\n"); |
| 411 | printf("| UDP SRC Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 412 | printf("| UDP DST Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 413 | |
| 414 | token = { buf.val[ptr + 4], buf.val[ptr+5] }; |
| 415 | } |
| 416 | else if( buf.val[ptr - buf_shift ] == TCP_PROTO) { |
| 417 | // TCP L4 pkt present |
| 418 | printf("+-------------------------------------\n"); |
| 419 | printf(" L4 Header-- Type: TCP\n"); |
| 420 | printf("+--------------------------------------\n"); |
| 421 | |
| 422 | printf("| TCP SRC Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 423 | printf("| TCP DST Port: %h\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 424 | printf("| TCP Sequence #: %h\n", {buf.val[ptr++], buf.val[ptr++], |
| 425 | buf.val[ptr++], buf.val[ptr++]} ); |
| 426 | printf("| TCP ACK #: %h\n", {buf.val[ptr++], buf.val[ptr++], |
| 427 | buf.val[ptr++], buf.val[ptr++]} ); |
| 428 | |
| 429 | // increment ptr to pass viewing of uncessary bits |
| 430 | ptr += 1; |
| 431 | |
| 432 | flag_bit = buf.val[ptr++]; |
| 433 | |
| 434 | printf("| TCP Flag bits: URG:%b ACK:%b PSH:%b RST:%b SYN:%b FIN:%b\n", |
| 435 | flag_bit[5], flag_bit[4], flag_bit[3], flag_bit[2], flag_bit[1], flag_bit[0]); |
| 436 | printf("| Window Size: %h\n", {buf.val[ptr++], buf.val[ptr++]}); |
| 437 | printf("+---------------\n"); |
| 438 | |
| 439 | token = { buf.val[ptr + 4], buf.val[ptr+5] }; |
| 440 | |
| 441 | } // end else if TCP pkt |
| 442 | else { |
| 443 | // No L4 pkt present |
| 444 | token = { buf.val[ptr], buf.val[ptr+1] }; |
| 445 | } |
| 446 | } // end else (IPv6 Pkt) |
| 447 | } // end if L3 Header Present |
| 448 | |
| 449 | |
| 450 | if(len<0) len = hwlen; |
| 451 | |
| 452 | printf("\nTime: %0d\n",{get_time(HI),get_time(LO)}); |
| 453 | printf("Token: %0d\n", token); |
| 454 | |
| 455 | // See if packet (Token) exists in DB |
| 456 | if( assoc_index(CHECK, pack_db, token) == 0 ) { |
| 457 | printf("Warning: Could Not find Packet in Packet Database\n"); |
| 458 | } else { |
| 459 | printf("Packet originated on Port: %0d\n", pack_db[token].org_port ); |
| 460 | } |
| 461 | |
| 462 | // Display Data payload portion of packet |
| 463 | printf("\n"); |
| 464 | if(ifedx==1) display_data(buf, ptr, hwlen-ptr-4-4 ); |
| 465 | else display_data(buf, ptr, hwlen-ptr-4 ); |
| 466 | |
| 467 | printf("\n"); |
| 468 | printf("CRC: %h\n", { buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] } ); |
| 469 | |
| 470 | if(ifedx==1) |
| 471 | printf("\n INTER FEDX CRC: %h\n", |
| 472 | { buf.val[ptr++], buf.val[ptr++], buf.val[ptr++], buf.val[ptr++] } ); |
| 473 | |
| 474 | printf("\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); |
| 475 | printf("--------------------------------------------------------------\n\n"); |
| 476 | |
| 477 | } // end task |
| 478 | |
| 479 | |
| 480 | task display_class(byte_array buf, var integer ptr) { |
| 481 | integer n,last; |
| 482 | |
| 483 | last = ptr+14; |
| 484 | |
| 485 | printf("| Class: "); |
| 486 | |
| 487 | // Hex Dump |
| 488 | for(n=0;n<14;n++) printf("%h ", buf.val[ptr+n] ); |
| 489 | printf("\n"); |
| 490 | |
| 491 | if( {buf.val[ptr], buf.val[ptr+1]} < 16'h0600) |
| 492 | printf("| Length: %0d\n|\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 493 | else |
| 494 | printf("| Type: %0h\n|\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 495 | |
| 496 | ptr=last; |
| 497 | } |
| 498 | |
| 499 | |
| 500 | task display_class_ipv6(byte_array buf, var integer ptr) { |
| 501 | integer n,last; |
| 502 | |
| 503 | last = ptr+6; |
| 504 | |
| 505 | printf("| Class: "); |
| 506 | |
| 507 | // Hex Dump |
| 508 | for(n=0;n<10;n++) printf("%h ", buf.val[ptr+n] ); |
| 509 | printf("\n"); |
| 510 | |
| 511 | if( {buf.val[ptr], buf.val[ptr+1]} < 16'h0600) |
| 512 | printf("| Length: %0d\n|\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 513 | else |
| 514 | printf("| Type: %0h\n|\n", {buf.val[ptr++], buf.val[ptr++]} ); |
| 515 | |
| 516 | ptr=last; |
| 517 | } |
| 518 | |
| 519 | |
| 520 | |
| 521 | task display_data(byte_array buf, var integer ptr, integer len) { |
| 522 | integer n; |
| 523 | |
| 524 | printf(" Data:\n"); |
| 525 | printf("+---------------"); |
| 526 | |
| 527 | if(len<1) |
| 528 | printf("\n| No Payload ..."); |
| 529 | else |
| 530 | |
| 531 | for(n=0;n< len ;n++) { |
| 532 | if( !(n % 16) ) printf("\n| %d: ",n); |
| 533 | printf("%h ", buf.val[ptr++]); |
| 534 | } |
| 535 | printf("\n+---------------\n"); |
| 536 | } |
| 537 | |
| 538 | |
| 539 | task display_id(bit [79:0] id) { |
| 540 | |
| 541 | printf(" ID Tags:\n"); |
| 542 | printf("+---------------\n"); |
| 543 | printf("| Src port: %0d\n", id[79:75] ); |
| 544 | printf("| Dst port: %0h\n", id[74:35] ); |
| 545 | printf("| Order Type: %0h\n", id[34:33] ); |
| 546 | printf("| Order Sequnce: %0d\n", id[32:27] ); |
| 547 | printf("| Packet number: %0d\n", id[26:11] ); |
| 548 | printf("| Data Type: %0d\n", id[10:8] ); |
| 549 | printf("| Data Seed: %0d\n", id[7:0] ); |
| 550 | printf("+---------------\n"); |
| 551 | } |
| 552 | |
| 553 | |
| 554 | task display_db(integer token) { |
| 555 | |
| 556 | printf("\n========== Display DB Entry %0d ========== \n",token); |
| 557 | if(pack_db[token] == null) { |
| 558 | printf("This entry is not allocated ...\n"); |
| 559 | } else { |
| 560 | printf("\tframe.frame_type: %h\n",pack_db[token].frame.frame_type); |
| 561 | printf("\tframe.frame_class: %h\n",pack_db[token].frame.frame_class); |
| 562 | printf("\tframe.class_mask: %h\n",pack_db[token].frame.class_mask); |
| 563 | printf("\tframe.class_funct: %h\n",pack_db[token].frame.class_funct); |
| 564 | printf("\tframe.data_type: %h\n",pack_db[token].frame.data_type); |
| 565 | printf("\tframe.data_seed: %h\n",pack_db[token].frame.data_seed); |
| 566 | printf("\tframe.data_length: %h\n",pack_db[token].data_length); |
| 567 | printf("\n"); |
| 568 | printf("\tsrc_node.l2_addr: %h\n",pack_db[token].src_node.l2_addr); |
| 569 | printf("\tsrc_node.tci: %h\n",pack_db[token].src_node.tci); |
| 570 | printf("\tsrc_node.ip_addr: %h\n",pack_db[token].src_node.ip_addr); |
| 571 | printf("\tsrc_node.ipv6_addr: %h\n",pack_db[token].src_node.ipv6_addr); |
| 572 | printf("\n"); |
| 573 | printf("\tdst_node.l2_addr: %h\n",pack_db[token].dst_node.l2_addr); |
| 574 | printf("\tdst_node.tci: %h\n",pack_db[token].dst_node.tci); |
| 575 | printf("\tdst_node.ip_addr: %h\n",pack_db[token].dst_node.ip_addr); |
| 576 | printf("\tdst_node.ipv6_addr: %h\n",pack_db[token].dst_node.ipv6_addr); |
| 577 | printf("\n"); |
| 578 | printf("\ttup.src_tcp_udp_port: %h\n",pack_db[token].tup.src_tcp_udp_port); |
| 579 | printf("\ttup.dst_tcp_udp_port: %h\n",pack_db[token].tup.dst_tcp_udp_port); |
| 580 | printf("\n"); |
| 581 | printf("\trcv_isn: %0h\n",pack_db[token].rx_param.rcv_isn); |
| 582 | printf("\tlast_ackno: %0h\n",pack_db[token].rx_param.last_ackno); |
| 583 | printf("\tadv_isn: %0h\n",pack_db[token].tx_param.adv_isn); |
| 584 | printf("\tlast_seqno: %0h\n",pack_db[token].tx_param.last_seqno); |
| 585 | printf("\n"); |
| 586 | printf("\torg_port: %0d\n",pack_db[token].org_port); |
| 587 | printf("\torder_seq: %0d\n",pack_db[token].order_seq); |
| 588 | printf("\tpckt_num: %0d\n",pack_db[token].pckt_num); |
| 589 | printf("\toptions: %h\n",pack_db[token].options); |
| 590 | } |
| 591 | printf("========================================== \n\n"); |
| 592 | } |
| 593 | |
| 594 | task display_flow(integer flow_id) { |
| 595 | |
| 596 | printf("\n========== Display FLOW DB Entry %0d ========== \n",flow_id); |
| 597 | if(flow_db[flow_id] == null) { |
| 598 | printf("This entry is not allocated ...\n"); |
| 599 | } else { |
| 600 | printf("\tframe.data_length: %h\n",flow_db[flow_id].data_length); |
| 601 | printf("\n"); |
| 602 | printf("\ttup.src_tcp_udp_port: %h\n",flow_db[flow_id].tup.src_tcp_udp_port); |
| 603 | printf("\ttup.dst_tcp_udp_port: %h\n",flow_db[flow_id].tup.dst_tcp_udp_port); |
| 604 | printf("\n"); |
| 605 | printf("\torg_port: %0d\n",flow_db[flow_id].org_port); |
| 606 | printf("\trcv_isn: %0h\n",flow_db[flow_id].rx_param.rcv_isn); |
| 607 | printf("\tlast_ackno: %0h\n",flow_db[flow_id].rx_param.last_ackno); |
| 608 | printf("\tadv_isn: %0h\n",flow_db[flow_id].tx_param.adv_isn); |
| 609 | printf("\tlast_seqno: %0h\n",flow_db[flow_id].tx_param.last_seqno); |
| 610 | //printf("\tpckt_num: %0d\n",pack_db[token].pckt_num); |
| 611 | //printf("\toptions: %h\n",pack_db[token].options); |
| 612 | } |
| 613 | printf("========================================== \n\n"); |
| 614 | } |