PLCTopologyPrint.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * signed TopologyPrint (struct plcnetworks * plctopology);
  11. *
  12. * plc.h
  13. *
  14. * print plctopology structure in human readable format on stdout;
  15. *
  16. * Contributor(s):
  17. * Charles Maier <cmaier@qca.qualcomm.com>
  18. *
  19. *--------------------------------------------------------------------*/
  20. #ifndef TOPOLOGYPRINT_SOURCE
  21. #define TOPOLOGYPRINT_SOURCE
  22. #include <stdio.h>
  23. #include "../plc/plc.h"
  24. #include "../tools/memory.h"
  25. signed PLCTopologyPrint (struct plctopology * plctopology)
  26. {
  27. signed plcnetworks = plctopology->plcnetworks;
  28. struct plcnetwork * plcnetwork = (struct plcnetwork *) (& plctopology->plcnetwork);
  29. while (plcnetworks--)
  30. {
  31. signed plcstations = plcnetwork->plcstations;
  32. struct plcstation * plcstation = (struct plcstation *) (& plcnetwork->plcstation);
  33. while (plcstations--)
  34. {
  35. char address [ETHER_ADDR_LEN * 3];
  36. printf ("%s ", plcstation->LOC? "LOC": "REM");
  37. printf ("%s ", plcstation->CCO? "CCO": "STA");
  38. printf ("%03d ", plcstation->TEI);
  39. printf ("%s ", hexstring (address, sizeof (address), plcstation->MAC, sizeof (plcstation->MAC)));
  40. printf ("%s ", hexstring (address, sizeof (address), plcstation->BDA, sizeof (plcstation->BDA)));
  41. printf ("%03d ", plcstation->RX);
  42. printf ("%03d ", plcstation->TX);
  43. printf ("%s ", plcstation->hardware);
  44. printf ("%s ", plcstation->firmware);
  45. printf ("\n");
  46. plcstation++;
  47. }
  48. plcnetwork = (struct plcnetwork *) (plcstation);
  49. }
  50. #if 0
  51. printf ("\n");
  52. #endif
  53. return (0);
  54. }
  55. #endif