MulticastInfo1.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * signed MulticastInfo1 (struct plc * plc);
  11. *
  12. * plc.h
  13. *
  14. * Request multicast group membership information from the peer device
  15. * one VS_MULTICAST_INFO message;
  16. *
  17. * Contributor(s):
  18. * Nathaniel Houghton <nhoughto@qca.qualcomm.com>
  19. *
  20. *--------------------------------------------------------------------*/
  21. #ifndef MULTICASTINFO1_SOURCE
  22. #define MULTICASTINFO1_SOURCE
  23. #include <stdint.h>
  24. #include <memory.h>
  25. #include "../plc/plc.h"
  26. #include "../tools/memory.h"
  27. #include "../tools/number.h"
  28. #include "../tools/error.h"
  29. signed MulticastInfo1 (struct plc * plc)
  30. {
  31. struct channel * channel = (struct channel *) (plc->channel);
  32. struct message * message = (struct message *) (plc->message);
  33. #ifndef __GNUC__
  34. #pragma pack (push,1)
  35. #endif
  36. struct __packed source
  37. {
  38. uint8_t SOURCEADD [16];
  39. }
  40. * source;
  41. struct __packed member
  42. {
  43. uint8_t MEMBERADD [ETHER_ADDR_LEN];
  44. uint8_t MEMBERTEI;
  45. uint8_t SOURCEMODE;
  46. uint8_t NUMSOURCES;
  47. }
  48. * member;
  49. struct __packed group
  50. {
  51. uint8_t GROUPADD [16];
  52. uint8_t NUMMEMBERS;
  53. }
  54. * group;
  55. struct __packed vs_mcast_info_request
  56. {
  57. struct ethernet_hdr ethernet;
  58. struct qualcomm_fmi qualcomm;
  59. uint8_t REQTYPE;
  60. uint8_t GROUP_ADDRESS [16];
  61. }
  62. * request = (struct vs_mcast_info_request *) (message);
  63. struct __packed vs_mcast_info_confirm
  64. {
  65. struct ethernet_hdr ethernet;
  66. struct qualcomm_fmi qualcomm;
  67. uint8_t REQTYPE;
  68. uint8_t MSTATUS;
  69. uint8_t NUMGROUP;
  70. struct group group [1];
  71. }
  72. * confirm = (struct vs_mcast_info_confirm *) (message);
  73. #ifndef __GNUC__
  74. #pragma pack (pop)
  75. #endif
  76. char string [16 * 3];
  77. Request (plc, "Fetch Multicast Group Information");
  78. memset (message, 0, sizeof (struct message));
  79. EthernetHeader (& request->ethernet, channel->peer, channel->host, channel->type);
  80. QualcommHeader1 (& confirm->qualcomm, 1, (VS_MULTICAST_INFO | MMTYPE_REQ));
  81. request->REQTYPE = 0x00;
  82. plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  83. if (SendMME (plc) <= 0)
  84. {
  85. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  86. return (-1);
  87. }
  88. if (ReadMME (plc, 1, (VS_MULTICAST_INFO | MMTYPE_CNF)) <= 0)
  89. {
  90. error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
  91. return (-1);
  92. }
  93. if (confirm->MSTATUS)
  94. {
  95. Failure (plc, PLC_WONTDOIT);
  96. return (-1);
  97. }
  98. Confirm (plc, "Found %d Group(s)\n", confirm->NUMGROUP);
  99. group = (struct group *) (& confirm->group);
  100. while (confirm->NUMGROUP-- > 0)
  101. {
  102. printf ("\tgroup->GROUPADD = %s\n", hexstring (string, sizeof (string), group->GROUPADD, sizeof (group->GROUPADD)));
  103. printf ("\tgroup->NUMMEMBERS = %d\n", group->NUMMEMBERS);
  104. printf ("\n");
  105. member = (struct member *) (& group->NUMMEMBERS + 1);
  106. while (group->NUMMEMBERS-- > 0)
  107. {
  108. printf ("\t\tmember->MEMBERADD = %s\n", hexstring (string, sizeof (string), member->MEMBERADD, sizeof (member->MEMBERADD)));
  109. printf ("\t\tmember->MEMBERTEI = %d\n", member->MEMBERTEI);
  110. printf ("\t\tmember->SOURCEMODE = %d\n", member->SOURCEMODE);
  111. printf ("\t\tmember->NUMSOURCES = %d\n", member->NUMSOURCES);
  112. source = (struct source *) (& member->NUMSOURCES + 1);
  113. while (member->NUMSOURCES-- > 0)
  114. {
  115. printf ("\t\t\tsource->SOURCEADD = %s\n", hexstring (string, sizeof (string), source->SOURCEADD, sizeof (source->SOURCEADD)));
  116. printf ("\n");
  117. source++;
  118. }
  119. member = (struct member *) (source);
  120. printf ("\n");
  121. }
  122. group = (struct group *) (member);
  123. }
  124. return (0);
  125. }
  126. #endif