panther_pib_peek.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * signed panther_pib_peek (void const * memory);
  11. *
  12. * pib.h
  13. *
  14. * print Panther/Lynx PIB identity information on stdout;
  15. *
  16. * Contributor(s):
  17. * Charles Maier <cmaier@qca.qualcomm.com>
  18. *
  19. *--------------------------------------------------------------------*/
  20. #ifndef PANTHER_PIB_PEEK_SOURCE
  21. #define PANTHER_PIB_PEEK_SOURCE
  22. #include <stdio.h>
  23. #include <memory.h>
  24. #include "../tools/memory.h"
  25. #include "../tools/number.h"
  26. #include "../key/HPAVKey.h"
  27. #include "../key/keys.h"
  28. #include "../pib/pib.h"
  29. static char const * CCoMode2 [] =
  30. {
  31. "Auto",
  32. "Never",
  33. "Always",
  34. "User",
  35. "Covert",
  36. "Unknown"
  37. };
  38. static char const * MDURole2 [] =
  39. {
  40. "Slave",
  41. "Master"
  42. };
  43. signed panther_pib_peek (void const * memory)
  44. {
  45. extern const struct key keys [KEYS];
  46. struct PIB3_0 * PIB = (struct PIB3_0 *) (memory);
  47. char buffer [HPAVKEY_SHA_LEN * 3];
  48. size_t key;
  49. printf ("\tPIB %d-%d %d bytes\n", PIB->VersionHeader.FWVersion, PIB->VersionHeader.PIBVersion, LE16TOH (PIB->VersionHeader.PIBLength));
  50. printf ("\tMAC %s\n", hexstring (buffer, sizeof (buffer), PIB->LocalDeviceConfig.MAC, sizeof (PIB->LocalDeviceConfig.MAC)));
  51. printf ("\tDAK %s", hexstring (buffer, sizeof (buffer), PIB->LocalDeviceConfig.DAK, sizeof (PIB->LocalDeviceConfig.DAK)));
  52. for (key = 0; key < KEYS; key++)
  53. {
  54. if (! memcmp (keys [key].DAK, PIB->LocalDeviceConfig.DAK, HPAVKEY_DAK_LEN))
  55. {
  56. printf (" (%s)", keys [key].phrase);
  57. break;
  58. }
  59. }
  60. printf ("\n");
  61. printf ("\tNMK %s", hexstring (buffer, sizeof (buffer), PIB->LocalDeviceConfig.NMK, sizeof (PIB->LocalDeviceConfig.NMK)));
  62. for (key = 0; key < KEYS; key++)
  63. {
  64. if (! memcmp (keys [key].NMK, PIB->LocalDeviceConfig.NMK, HPAVKEY_NMK_LEN))
  65. {
  66. printf (" (%s)", keys [key].phrase);
  67. break;
  68. }
  69. }
  70. printf ("\n");
  71. printf ("\tNID %s\n", hexstring (buffer, sizeof (buffer), PIB->LocalDeviceConfig.PreferredNID, sizeof (PIB->LocalDeviceConfig.PreferredNID)));
  72. printf ("\tNET %s\n", PIB->LocalDeviceConfig.NET);
  73. printf ("\tMFG %s\n", PIB->LocalDeviceConfig.MFG);
  74. printf ("\tUSR %s\n", PIB->LocalDeviceConfig.USR);
  75. printf ("\tCCo %s\n", CCoMode2 [PIB->LocalDeviceConfig.CCoSelection > SIZEOF (CCoMode2) - 1? SIZEOF (CCoMode2) - 1: PIB->LocalDeviceConfig.CCoSelection]);
  76. printf ("\tMDU %s\n", PIB->LocalDeviceConfig.MDUConfiguration? MDURole2 [PIB->LocalDeviceConfig.MDURole & 1]: "N/A");
  77. return (0);
  78. }
  79. #endif