gen_pkt.c (17530B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * Packet generator for diagnostic (TR) tests. 8 * This packet generator can be used to generate random L2 and L3 Ethernet 9 * packets complete with CRC. Created in addition to existing packet generator 10 8 for added flexibility. 11 */ 12 13 #include <appl/diag/system.h> 14 #include <shared/alloc.h> 15 #include <shared/bsl.h> 16 #include "gen_pkt.h" 17 18 #define NUM_ENTRIES_CRC_TABLE 256 19 20 uint32 tgp_polynomial = 0x04c11db7; 21 uint32 tgp_initial_remainder = 0xffffffff; 22 uint8 tgp_refin = 0x1; 23 uint8 tgp_refout = 0x1; 24 uint32 tgp_final_xor_value = 0xffffffff; 25 uint32 tgp_global_seed_ctr = 0; 26 uint32 tgp_crc_table[NUM_ENTRIES_CRC_TABLE]; 27 28 /* 29 * Function: 30 * tgp_reflect 31 * Purpose: 32 * Reflect n-bit data 33 * Parameters: 34 * data - Input data (max 32 bits) 35 * nbits - Number of bits reflected 36 * Returns: 37 * Reflected data 38 */ 39 40 uint32 41 tgp_reflect(uint32 data, uint32 nbits) 42 { 43 uint32 reflection, i; 44 45 reflection = 0; 46 for (i = 0; i < nbits; i++) { 47 if (data & 0x00000001) { 48 reflection |= (1 << ((nbits - 1) - i)); 49 } 50 data = data >> 1; 51 } 52 return (reflection); 53 } 54 55 /* 56 * Function: 57 * tgp_populate_crc_table 58 * Purpose: 59 * Create CRC table for Ethernet packet CRC calculation. Populates 60 * tgp_crc_table. 61 * Parameters: 62 * None 63 * Returns: 64 * Nothing 65 */ 66 67 void 68 tgp_populate_crc_table(void) 69 { 70 uint32 remainder, topbit; 71 uint32 dividend; 72 uint32 i; 73 74 topbit = (1 << (32 - 1)); 75 76 for (dividend = 0; dividend < NUM_ENTRIES_CRC_TABLE; dividend++) { 77 remainder = dividend << (32 - 8); 78 79 for (i = 8; i > 0; i--) { 80 if (remainder & topbit) { 81 remainder = (remainder << 1) ^ tgp_polynomial; 82 } else { 83 remainder = (remainder << 1); 84 } 85 } 86 tgp_crc_table[dividend] = remainder; 87 } 88 89 } 90 91 /* 92 * Function: 93 * tgp_generate_calculate_crc 94 * Purpose: 95 * Calculate 4 byte CRC for Ethernet packet 96 * Parameters: 97 * pkt_ptr - Pointer to packet 98 * pkt_size - Packet Size in bytes 99 * Returns: 100 * 4 byte CRC. 101 */ 102 103 uint32 104 tgp_generate_calculate_crc(uint8 *pkt_ptr, int32 pkt_size) 105 { 106 uint32 i, remainder, reflected_remainder, crc; 107 uint8 data; 108 109 remainder = tgp_initial_remainder; 110 111 112 for (i = 0; i < (pkt_size - NUM_BYTES_CRC); i++) { 113 data = 114 (tgp_refin == 115 0x1) ? (tgp_reflect(pkt_ptr[i], 116 8) ^ (remainder >> (32 - 117 8))) : (pkt_ptr[i] ^ (remainder 118 >> (32 - 119 8))); 120 remainder = tgp_crc_table[data] ^ (remainder << 8); 121 } 122 reflected_remainder = tgp_reflect(remainder, 32); 123 124 125 crc = 126 (tgp_refout == 127 0x1) ? (reflected_remainder ^ tgp_final_xor_value) : (remainder ^ 128 tgp_final_xor_value); 129 130 return (crc); 131 } 132 133 /* 134 * Function: 135 * tgp_gen_random_l2_pkt 136 * Purpose: 137 * Generate random L2 Ethernet packet 138 * Parameters: 139 * pkt_ptr - Pointer to packet 140 * pkt_size - Packet size in bytes 141 * mac_da - MAC DA in packet header 142 * mac_sa - MAC SA in packet header 143 * tpid - TPID 144 * vlan_id - {priority, cfi, VLAN} 145 * Returns: 146 * Reflected data 147 */ 148 149 void 150 tgp_gen_random_l2_pkt(uint8 *pkt_ptr, uint32 pkt_size, 151 uint8 mac_da[NUM_BYTES_MAC_ADDR], 152 uint8 mac_sa[NUM_BYTES_MAC_ADDR], uint16 tpid, uint16 vlan_id) 153 { 154 int i; 155 uint32 crc; 156 157 for (i = 0; i < NUM_BYTES_MAC_ADDR; i++) { 158 pkt_ptr[i] = mac_da[i]; 159 } 160 161 for (i = NUM_BYTES_MAC_ADDR; i < (2 * NUM_BYTES_MAC_ADDR); i++) { 162 pkt_ptr[i] = mac_sa[i - NUM_BYTES_MAC_ADDR]; 163 } 164 165 pkt_ptr[2 * NUM_BYTES_MAC_ADDR] = (tpid >> 8) & 0x00ff; 166 pkt_ptr[(2 * NUM_BYTES_MAC_ADDR) + 1] = tpid & 0x00ff; 167 168 pkt_ptr[(2 * NUM_BYTES_MAC_ADDR) + 2] = (vlan_id >> 8) & 0x00ff; 169 pkt_ptr[(2 * NUM_BYTES_MAC_ADDR) + 3] = vlan_id & 0x00ff; 170 171 pkt_ptr[(2 * NUM_BYTES_MAC_ADDR) + 4] = 0xff; 172 pkt_ptr[(2 * NUM_BYTES_MAC_ADDR) + 5] = 0xff; 173 174 for (i = ((2 * NUM_BYTES_MAC_ADDR) + 6); i < (pkt_size - NUM_BYTES_CRC); 175 i++) { 176 /* coverity[dont_call : FALSE] */ 177 pkt_ptr[i] = sal_rand(); 178 179 } 180 181 for (i = 0; i < NUM_BYTES_CRC; i++) { 182 pkt_ptr[pkt_size - NUM_BYTES_CRC + i] = 0x00; 183 } 184 185 tgp_populate_crc_table(); 186 crc = tgp_generate_calculate_crc(pkt_ptr, pkt_size); 187 188 pkt_ptr[pkt_size - NUM_BYTES_CRC + 3] = (crc >> 24) & 0xff; 189 pkt_ptr[pkt_size - NUM_BYTES_CRC + 2] = (crc >> 16) & 0xff; 190 pkt_ptr[pkt_size - NUM_BYTES_CRC + 1] = (crc >> 8) & 0xff; 191 pkt_ptr[pkt_size - NUM_BYTES_CRC] = (crc) & 0xff; 192 tgp_global_seed_ctr++; 193 194 } 195 196 /* 197 * Function: 198 * tgp_generate_calculate_hdr_chksum 199 * Purpose: 200 * Calculate 2 byte checksum for IP header 201 * Parameters: 202 * pkt_ptr - Pointer to packet 203 * hdr_offset - Header Offset 204 * hdr_len - Header Length in bytes 205 * Returns: 206 * 2 byte header checksum 207 */ 208 209 uint16 210 tgp_generate_calculate_hdr_chksum(uint8 *pkt_ptr, int32 hdr_offset, 211 int32 hdr_len) 212 { 213 uint32 i, sum = 0; 214 uint16 chksum; 215 216 for (i = hdr_offset; i < hdr_offset + hdr_len; i+=2) { 217 sum += (pkt_ptr[i] << 8) + pkt_ptr[i+1]; 218 } 219 220 chksum = ~((sum >> 16 & 0x0000ffff) + (sum & 0x0000ffff)); 221 222 return (chksum); 223 } 224 225 /* 226 * Function: 227 * tgp_gen_random_ip_pkt 228 * Purpose: 229 * Generate random IPv4/6 Ethernet packet 230 * Parameters: 231 * pkt_ptr - Pointer to packet 232 * pkt_size - Packet size in bytes 233 * mac_da - MAC DA in packet header 234 * mac_sa - MAC SA in packet header 235 * vlan_id - {priority, cfi, VLAN} 236 * ip_da - IP DA in IPv4/6 header 237 * ip_sa - IP SA in IPv4/6 header 238 * ttl - TTL in IPv4 header/hop limit in IPv6 header 239 * tos - TOS in IPv4 header 240 * Returns: 241 * Reflected data 242 */ 243 244 void 245 tgp_gen_random_ip_pkt(uint8 ipv6, uint8 *pkt_ptr, uint32 pkt_size, 246 uint8 mac_da[NUM_BYTES_MAC_ADDR], 247 uint8 mac_sa[NUM_BYTES_MAC_ADDR], uint16 vlan_id, 248 uint32 ip_da, uint32 ip_sa, uint8 ttl, uint8 tos) 249 { 250 int i, offset = 0; 251 uint16 ip_len, pld_len, chk_sum; 252 uint32 crc; 253 254 /* Byte 0-5: MAC DA */ 255 for (i = 0; i < NUM_BYTES_MAC_ADDR; i++) { 256 pkt_ptr[offset++] = mac_da[i]; 257 } 258 259 /* Byte 6-11: MAC SA */ 260 for (i = 0; i < NUM_BYTES_MAC_ADDR; i++) { 261 pkt_ptr[offset++] = mac_sa[i]; 262 } 263 264 /* Byte 12-13: TPID */ 265 pkt_ptr[offset++] = 0x81; 266 pkt_ptr[offset++] = 0x00; 267 268 /* Byte 14-15: VLAN */ 269 pkt_ptr[offset++] = (vlan_id >> 8) & 0x00ff; 270 pkt_ptr[offset++] = vlan_id & 0x00ff; 271 272 if (ipv6) { 273 /* Byte 16-17: IPv6 Ether II Type */ 274 pkt_ptr[offset++] = 0x86; 275 pkt_ptr[offset++] = 0xdd; 276 277 /* Byte 18-21: IPv6 Version/Traffic Class/Flow Label */ 278 pkt_ptr[offset++] = 0x60; 279 pkt_ptr[offset++] = 0x30 | (sal_rand() & 0x000f); 280 pkt_ptr[offset++] = sal_rand(); 281 pkt_ptr[offset++] = sal_rand(); 282 283 /* Byte 22-23: IPv6 Payload Length */ 284 pld_len = pkt_size - NUM_BYTES_L2_HDR - NUM_BYTES_IPV6_HDR - 285 NUM_BYTES_CRC; 286 pkt_ptr[offset++] = (pld_len >> 8) & 0x00ff; 287 pkt_ptr[offset++] = pld_len & 0x00ff; 288 289 /* Byte 24: IPv6 Next Header (no next header) */ 290 pkt_ptr[offset++] = 0x3b; 291 292 /* Byte 25: IPv6 Hop Limit */ 293 pkt_ptr[offset++] = ttl; 294 295 /* Byte 26-41: IPv6 Link-Local SA */ 296 pkt_ptr[offset++] = 0xfe; 297 pkt_ptr[offset++] = 0x80; 298 pkt_ptr[offset++] = 0x00; 299 pkt_ptr[offset++] = 0x00; 300 pkt_ptr[offset++] = 0x00; 301 pkt_ptr[offset++] = 0x00; 302 pkt_ptr[offset++] = 0x00; 303 pkt_ptr[offset++] = 0x00; 304 pkt_ptr[offset++] = 0x00; 305 pkt_ptr[offset++] = 0x00; 306 pkt_ptr[offset++] = 0x00; 307 pkt_ptr[offset++] = 0x00; 308 for (i = NUM_BYTES_IPV4_ADDR - 1; i >= 0; i--) { 309 pkt_ptr[offset++] = (ip_sa >> (i * 8)) & 0x000000ff; 310 } 311 312 /* Byte 42-57: IPv6 Link-Local DA */ 313 pkt_ptr[offset++] = 0xfe; 314 pkt_ptr[offset++] = 0x80; 315 pkt_ptr[offset++] = 0x00; 316 pkt_ptr[offset++] = 0x00; 317 pkt_ptr[offset++] = 0x00; 318 pkt_ptr[offset++] = 0x00; 319 pkt_ptr[offset++] = 0x00; 320 pkt_ptr[offset++] = 0x00; 321 pkt_ptr[offset++] = 0x00; 322 pkt_ptr[offset++] = 0x00; 323 pkt_ptr[offset++] = 0x00; 324 pkt_ptr[offset++] = 0x00; 325 for (i = NUM_BYTES_IPV4_ADDR - 1; i >= 0; i--) { 326 pkt_ptr[offset++] = (ip_da >> (i * 8)) & 0x000000ff; 327 } 328 } else { 329 /* Byte 16-17: IPv4 Ether II Type */ 330 pkt_ptr[offset++] = 0x08; 331 pkt_ptr[offset++] = 0x00; 332 333 /* Byte 18: IPv4 Version/Header Length */ 334 pkt_ptr[offset++] = 0x45; 335 336 /* Byte 19: IPv4 TOS */ 337 pkt_ptr[offset++] = tos; 338 339 /* Byte 20-21: IPv4 Total Length */ 340 ip_len = pkt_size - NUM_BYTES_L2_HDR - NUM_BYTES_CRC; 341 pkt_ptr[offset++] = (ip_len >> 8) & 0x00ff; 342 pkt_ptr[offset++] = ip_len & 0x00ff; 343 344 /* Byte 22-23: IPv4 ID */ 345 pkt_ptr[offset++] = sal_rand(); 346 pkt_ptr[offset++] = sal_rand(); 347 348 /* Byte 24-25: IPv4 Fragment Flags/Offset */ 349 pkt_ptr[offset++] = 0x00; 350 pkt_ptr[offset++] = 0x00; 351 352 /* Byte 26: IPv4 TTL */ 353 pkt_ptr[offset++] = ttl; 354 355 /* Byte 27: IPv4 Protocol */ 356 pkt_ptr[offset++] = 0x00; 357 358 /* Byte 28-29: IPv4 Header Checksum */ 359 pkt_ptr[offset++] = 0x00; 360 pkt_ptr[offset++] = 0x00; 361 362 /* Byte 30-33: IPv4 SA */ 363 for (i = NUM_BYTES_IPV4_ADDR - 1; i >= 0; i--) { 364 pkt_ptr[offset++] = (ip_sa >> (i * 8)) & 0x000000ff; 365 } 366 367 /* Byte 34-37: IPv4 DA */ 368 for (i = NUM_BYTES_IPV4_ADDR - 1; i >= 0; i--) { 369 pkt_ptr[offset++] = (ip_da >> (i * 8)) & 0x000000ff; 370 } 371 372 /* Calculate IPv4 Header Checksum */ 373 chk_sum = tgp_generate_calculate_hdr_chksum(pkt_ptr, NUM_BYTES_L2_HDR, 374 NUM_BYTES_IPV4_HDR); 375 pkt_ptr[28] = (chk_sum >> 8) & 0x00ff; 376 pkt_ptr[29] = chk_sum & 0x00ff; 377 378 /* Calculate Payload Length */ 379 pld_len = pkt_size - NUM_BYTES_L2_HDR - NUM_BYTES_IPV4_HDR - 380 NUM_BYTES_CRC; 381 } 382 383 /* Random Payload */ 384 for (i = 0; i < pld_len; i++) { 385 /* coverity[dont_call : FALSE] */ 386 pkt_ptr[offset++] = sal_rand(); 387 } 388 389 /* Calculate CRC */ 390 tgp_populate_crc_table(); 391 crc = tgp_generate_calculate_crc(pkt_ptr, pkt_size); 392 for (i = NUM_BYTES_CRC - 1; i >= 0 ; i--) { 393 pkt_ptr[offset++] = (crc >> (i * 8)) & 0x000000ff; 394 } 395 396 tgp_global_seed_ctr++; 397 } 398 399 400 /* 401 * Function: 402 * tgp_gen_random_mpls_ip_pkt 403 * Purpose: 404 * Generate random MPLS, IPv4/6, Ethernet packet 405 * Parameters: 406 * pkt_ptr - Pointer to packet 407 * pkt_size - Packet size in bytes 408 * mac_da - MAC DA in packet header 409 * mac_sa - MAC SA in packet header 410 * vlan_id - {priority, cfi, VLAN} 411 * l3_en - 1 if L3 enabled 412 * l3_mpls_en - 1 if MPLS enabled 413 * mpls_labels - an uint32 array of MPLs labels 414 * ipv6_en - 1 if ipv6 enabled 415 * ip_da - IP DA in IPv4/6 header 416 * ip_sa - IP SA in IPv4/6 header 417 * ttl - TTL in IPv4 header/hop limit in IPv6 header 418 * tos - TOS in IPv4 header 419 * Returns: 420 * Reflected data 421 */ 422 void 423 tgp_gen_random_mpls_ip_pkt( 424 uint8 *pkt_ptr, 425 uint32 pkt_size, 426 uint8 mac_da[NUM_BYTES_MAC_ADDR], 427 uint8 mac_sa[NUM_BYTES_MAC_ADDR], 428 uint16 vlan_id, 429 int l3_en, 430 int l3_mpls_en, 431 uint32 *mpls_labels, 432 int ipv6_en, 433 uint32 *ipv6_da, 434 uint32 *ipv6_sa, 435 uint8 ttl, 436 uint8 tos) 437 { 438 int i, b, offset = 0; 439 uint16 ip_len, pld_len, chk_sum; 440 uint32 crc; 441 int mpls_labels_bytes; 442 443 mpls_labels_bytes = 0; 444 445 /* Byte 0-5: MAC DA */ 446 for (i = 0; i < NUM_BYTES_MAC_ADDR; i++) { 447 pkt_ptr[offset++] = mac_da[i]; 448 } 449 450 /* Byte 6-11: MAC SA */ 451 for (i = 0; i < NUM_BYTES_MAC_ADDR; i++) { 452 pkt_ptr[offset++] = mac_sa[i]; 453 } 454 455 /* Byte 12-13: TPID */ 456 pkt_ptr[offset++] = 0x81; 457 pkt_ptr[offset++] = 0x00; 458 459 /* Byte 14-15: VLAN */ 460 pkt_ptr[offset++] = (vlan_id >> 8) & 0x00ff; 461 pkt_ptr[offset++] = vlan_id & 0x00ff; 462 463 if (l3_mpls_en == 1) { 464 /* Byte 16-17: MPLS IPv6 Ether II Type */ 465 pkt_ptr[offset++] = 0x88; /* MPLS unicast */ 466 pkt_ptr[offset++] = 0x47; 467 468 /* MPLS 3 labels */ 469 for (i = 0; i < 3; i++ ) { 470 for (b = 24; b >=0; b -= 8) { 471 pkt_ptr[offset++] = (mpls_labels[i] >> b) & 0xff; 472 } 473 } 474 mpls_labels_bytes = (3 * NUM_BYTES_MPLS_HDR); 475 } else if (l3_en == 1) { 476 if (ipv6_en == 1) { 477 /* Byte 16-17: IPv6 Ether II Type */ 478 pkt_ptr[offset++] = 0x86; 479 pkt_ptr[offset++] = 0xdd; 480 } else { 481 /* Byte 16-17: IPv4 Ether II Type */ 482 pkt_ptr[offset++] = 0x08; 483 pkt_ptr[offset++] = 0x00; 484 } 485 mpls_labels_bytes = 0; 486 } 487 488 if (l3_en == 1) { 489 if (ipv6_en == 1) { 490 /* Byte 18-21: IPv6 Version/Traffic Class/Flow Label */ 491 pkt_ptr[offset++] = 0x60; 492 pkt_ptr[offset++] = 0x0; /* 0x30 | (sal_rand() & 0x000f);*/ 493 pkt_ptr[offset++] = 0x0; /* sal_rand(); */ 494 pkt_ptr[offset++] = 0x0; /* sal_rand(); */ 495 496 /* Byte 22-23: IPv6 Payload Length */ 497 pld_len = pkt_size - NUM_BYTES_L2_HDR - mpls_labels_bytes 498 - NUM_BYTES_IPV6_HDR - NUM_BYTES_CRC ; 499 pkt_ptr[offset++] = (pld_len >> 8) & 0x00ff; 500 pkt_ptr[offset++] = pld_len & 0x00ff; 501 502 /* Byte 24: IPv6 Next Header (no next header) */ 503 pkt_ptr[offset++] = 0x3b; 504 505 /* Byte 25: IPv6 Hop Limit */ 506 pkt_ptr[offset++] = ttl; 507 508 /* Byte 26-41: IPv6 Link-Local SA */ 509 for (i = 3; i >= 0; i-- ) { 510 for (b = 24; b >=0; b -= 8) { 511 pkt_ptr[offset++] = (ipv6_sa[i] >> b) & 0xff; 512 } 513 } 514 515 /* Byte 42-57: IPv6 Link-Local DA */ 516 for (i = 3; i >= 0; i-- ) { 517 for (b = 24; b >=0; b -= 8) { 518 pkt_ptr[offset++] = (ipv6_da[i] >> b) & 0xff; 519 } 520 } 521 } else { 522 /* Byte 18: IPv4 Version/Header Length */ 523 pkt_ptr[offset++] = 0x45; 524 525 /* Byte 19: IPv4 TOS */ 526 pkt_ptr[offset++] = tos; 527 528 /* Byte 20-21: IPv4 Total Length */ 529 ip_len = pkt_size - NUM_BYTES_L2_HDR - mpls_labels_bytes - NUM_BYTES_CRC; 530 pkt_ptr[offset++] = (ip_len >> 8) & 0x00ff; 531 pkt_ptr[offset++] = ip_len & 0x00ff; 532 533 /* Byte 22-23: IPv4 ID */ 534 pkt_ptr[offset++] = sal_rand(); 535 pkt_ptr[offset++] = sal_rand(); 536 537 /* Byte 24-25: IPv4 Fragment Flags/Offset */ 538 pkt_ptr[offset++] = 0x00; 539 pkt_ptr[offset++] = 0x00; 540 541 /* Byte 26: IPv4 TTL */ 542 pkt_ptr[offset++] = ttl; 543 544 /* Byte 27: IPv4 Protocol */ 545 pkt_ptr[offset++] = 0x00; 546 547 /* Byte 28-29: IPv4 Header Checksum */ 548 pkt_ptr[offset++] = 0x00; 549 pkt_ptr[offset++] = 0x00; 550 551 /* Byte 30-33: IPv4 SA */ 552 for (i = NUM_BYTES_IPV4_ADDR - 1; i >= 0; i--) { 553 pkt_ptr[offset++] = (ipv6_sa[0] >> (i * 8)) & 0x000000ff; 554 } 555 556 /* Byte 34-37: IPv4 DA */ 557 for (i = NUM_BYTES_IPV4_ADDR - 1; i >= 0; i--) { 558 pkt_ptr[offset++] = (ipv6_da[0] >> (i * 8)) & 0x000000ff; 559 } 560 561 /* Calculate IPv4 Header Checksum */ 562 chk_sum = tgp_generate_calculate_hdr_chksum(pkt_ptr, 563 NUM_BYTES_L2_HDR + mpls_labels_bytes, 564 NUM_BYTES_IPV4_HDR); 565 /*pkt_ptr[28] = (chk_sum >> 8) & 0x00ff; 566 pkt_ptr[29] = chk_sum & 0x00ff;*/ 567 pkt_ptr[offset - 10] = (chk_sum >> 8) & 0x00ff; 568 pkt_ptr[offset - 9] = chk_sum & 0x00ff; 569 570 /* Calculate Payload Length */ 571 pld_len = pkt_size - NUM_BYTES_L2_HDR - NUM_BYTES_IPV4_HDR - 572 mpls_labels_bytes - NUM_BYTES_CRC; 573 } 574 } else { /* L2 vlan tagged */ 575 pld_len = pkt_size - NUM_BYTES_L2_HDR; 576 } 577 578 579 /* Random Payload */ 580 for (i = 0; i < pld_len; i++) { 581 /* coverity[dont_call : FALSE] */ 582 pkt_ptr[offset++] = sal_rand(); 583 } 584 585 /* Calculate CRC */ 586 tgp_populate_crc_table(); 587 crc = tgp_generate_calculate_crc(pkt_ptr, pkt_size); 588 for (i = NUM_BYTES_CRC - 1; i >= 0 ; i--) { 589 pkt_ptr[offset++] = (crc >> (i * 8)) & 0x000000ff; 590 } 591 592 tgp_global_seed_ctr++; 593 } 594 595 596 597 /* 598 * Function: 599 * tgp_print_pkt 600 * Purpose: 601 * Print packet 602 * Parameters: 603 * pkt_ptr - Pointer to packet 604 * pkt_size - Packet size in bytes 605 * 606 * Returns: 607 * Nothing 608 */ 609 610 void 611 tgp_print_pkt(uint8 *pkt_ptr, uint32 pkt_size) 612 { 613 int i; 614 615 for (i = 0; i < pkt_size; i++) { 616 if (i % 16 == 0) { 617 cli_out("\n"); 618 } 619 cli_out("%02x ", pkt_ptr[i]); 620 } 621 cli_out("\n"); 622 }