123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- /*====================================================================*
- * Copyright (c) 2021-2022 Qualcomm Technologies, Inc.
- * All Rights Reserved.
- * Confidential and Proprietary - Qualcomm Technologies, Inc.
- *--------------------------------------------------------------------*/
- /*====================================================================*
- *
- * signed TopologyTableInfo (struct plc * plc);
- *
- *
- * Send a query to STA to display/reset the Topology table from the device
- *
- * Contributor(s):
- * Abirama Sundari Sivakumar <asivakum@qti.qualcomm.com>
- *
- *--------------------------------------------------------------------*/
- #ifndef TOPOLOGYTABLEINFO_SOURCE
- #define TOPOLOGYTABLEINFO_SOURCE
- #include <stdint.h>
- #include <stdlib.h>
- #include "../plc/plc.h"
- #include "../tools/error.h"
- #define MAX_TOPOTABLE_ENTRIES 64
- #define TEIWORDARRAY_SIZE 8 //(256/32)
- #define WORDSIZE_BITS 32
- #define STATUS_FAILURE 0
- #define STATUS_SUCCESS 1
- bool IsTEIPresent(uint8_t tei, uint32_t *array)
- {
- uint8_t byte = (tei/WORDSIZE_BITS) ;
- uint8_t nbit = (tei % WORDSIZE_BITS) ;
- return (((array[byte] & (1<< nbit))==0) ? false : true);
- }
- signed TopologyTableInfo (struct plc * plc)
- {
- struct channel * channel = (struct channel *) (plc->channel);
- struct message * message = (struct message *) (plc->message);
- #ifndef __GNUC__
- #pragma pack (push,1)
- #endif
- struct __packed CCTEIMACEntry
- {
- uint8_t mTEI;
- uint16_t mMACAddrLast16Bits;
- }
- *vTEIMACEntry;
- struct __packed TopoTableEntry
- {
- uint8_t STAMACAddr[ETHER_ADDR_LEN];
- uint8_t STATEI;
- uint8_t TopoAttributes;
- uint8_t SNID;
- uint8_t mNumDiscTEIs;
- struct CCTEIMACEntry mTEIMACEntry[1];
- }
- * vTopoTableEntry;
- struct __packed DiscNeighborSTAInfo
- {
- uint8_t STAMACAddr[ETHER_ADDR_LEN];
- uint8_t STAAttributes;
- }
- * vDiscNeighborNode;
- struct __packed NeighborCCoInfo
- {
- uint8_t CCoMACAddr[ETHER_ADDR_LEN];
- uint8_t SNID;
- uint8_t IsSameNID;
- }
- *vNeighborCCo;
- struct __packed vs_topology_table_request
- {
- struct ethernet_hdr ethernet;
- struct qualcomm_hdr qualcomm;
- uint8_t ReqType;
- }
- * request = (struct vs_topology_table_request *) (message);
- struct __packed vs_topology_table_confirm
- {
- struct ethernet_hdr ethernet;
- struct qualcomm_fmi qualcomm;
- uint8_t Status;
- uint8_t LocalSNID;
- uint8_t NumEntries;
- struct TopoTableEntry TopoTableEntries [1];
- uint8_t NumNeighborNodes;
- struct DiscNeighborSTAInfo DiscNeighborSTAInfos[1];
- uint8_t NumNeighborCCos;
- struct NeighborCCoInfo NeighborCCoInfos[1];
- }
- *confirm = (struct vs_topology_table_confirm*)(message);
- uint8_t vCounter;
- #ifndef __GNUC__
- #pragma pack (pop)
- #endif
- if (plc->topotable_action == 0)
- {
- Request (plc, "TopologyTable-Query");
- }
- else if (plc->topotable_action == 1)
- {
- Request (plc, "TopologyTable-QueryNeighborListWithTopoTable");
- }
- else if (plc->topotable_action == 2)
- {
- Request (plc, "TopologyTable-Reset");
- }
- memset (message, 0, sizeof (* message));
- EthernetHeader (& request->ethernet, channel->peer, channel->host, channel->type);
- QualcommHeader (& request->qualcomm, 0, (VS_TOPOLOGY_TABLE | MMTYPE_REQ));
- request->ReqType = plc->topotable_action;
- plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
- if (SendMME (plc) <= 0)
- {
- error (PLC_EXIT (plc), ECANCELED, CHANNEL_CANTSEND);
- return (-1);
- }
- if (ReadFMI(plc, 1, (VS_TOPOLOGY_TABLE | MMTYPE_CNF)) <= 0)
- {
- error(1, ECANCELED, CHANNEL_CANTREAD);
- }
- confirm = (struct vs_topology_table_confirm*)(plc->content);
- if (confirm->Status == 0)
- {
- Failure(plc, PLC_WONTDOIT);
- }
- Confirm (plc, "LocalSNID = %d NumTopoEntries = %d \n", confirm->LocalSNID, confirm->NumEntries);
- vTopoTableEntry = (struct TopoTableEntry *) (confirm->TopoTableEntries);
- uint8_t* vTopoTableEntryPtr;
- vCounter = 0;
- char string[24];
- if (plc->topotable_action == 2)
- {
- printf("\nDeletion of Topology Table success\n");
- }
- while (confirm->NumEntries-- > 0)
- {
- vCounter++;
- bool IsSameNID = ((vTopoTableEntry->TopoAttributes & 0x1)? true: false);
- bool IsAssociated = ((vTopoTableEntry->TopoAttributes & 0x2) ? true : false);
- bool IsCCo = ((vTopoTableEntry->TopoAttributes & 0x4) ? true : false);
- printf ("Entry:%d Mac= %s TEI=%d", vCounter, hexstring (string, sizeof (string), vTopoTableEntry->STAMACAddr, sizeof (vTopoTableEntry->STAMACAddr)), vTopoTableEntry->STATEI);
- printf(" SNID=%d SameNID=%d IsAssociated=%d IsCCo=%d ", vTopoTableEntry->SNID, IsSameNID, IsAssociated, IsCCo);
- uint8_t vNumDiscTEIs = vTopoTableEntry->mNumDiscTEIs;
- vTEIMACEntry = (struct CCTEIMACEntry*)(vTopoTableEntry->mTEIMACEntry);
- printf("NumDiscTEIs=%d\n", vNumDiscTEIs);
- if (vNumDiscTEIs > 0)
- {
- printf(" TEIList --- ");
- while (vNumDiscTEIs-- > 0)
- {
- printf("%d-%04X ,", vTEIMACEntry->mTEI, vTEIMACEntry->mMACAddrLast16Bits);
- vTEIMACEntry++;
- }
- }
- printf ("\n\n");
- memset(string, 0, sizeof(string));
- vTopoTableEntryPtr = (uint8_t*)(vTEIMACEntry);
- vTopoTableEntry = (struct TopoTableEntry*)vTopoTableEntryPtr;
- }
- if (plc->topotable_action == 1) //Query neighbor List with Topo Table
- {
- vCounter = 0;
- uint8_t* vNeighborNodesPtr = (uint8_t*)(vTopoTableEntry );
- uint8_t vNumNeighborNodes = *vNeighborNodesPtr;
- vNeighborNodesPtr++; //increment pointer to move to required offset
- vDiscNeighborNode = (struct DiscNeighborSTAInfo*)(vNeighborNodesPtr);
- if (vNumNeighborNodes > 0)
- {
- printf("\n ----------------------List of Discovered Neighbor STAs----------------\n");
- }
- while (vNumNeighborNodes-- > 0)
- {
- vCounter++;
- bool IsSameNID = ((vDiscNeighborNode->STAAttributes & 0x1) ? true : false);
- bool IsAssociated = ((vDiscNeighborNode->STAAttributes & 0x2) ? true : false);
- bool IsExpired = ((vDiscNeighborNode->STAAttributes & 0x4) ? true : false);
- uint8_t SNID = ((vDiscNeighborNode->STAAttributes >> 3)& 0x1F);
- if (SNID == 0x1F)
- SNID = 0xFF;
- printf("Node:%d Mac= %s ", vCounter, hexstring(string, sizeof(string), vDiscNeighborNode->STAMACAddr, sizeof(vDiscNeighborNode->STAMACAddr)));
- printf(" SNID=%d SameNID=%d IsAssociated=%d IsExpired=%d \n", SNID, IsSameNID, IsAssociated, IsExpired);
- vDiscNeighborNode++;
- }
- vCounter = 0;
- uint8_t* vNeighborCCosPtr = (uint8_t*)(vDiscNeighborNode);
- uint8_t vNumNeighborCCos = *vNeighborCCosPtr;
- if (vNumNeighborCCos > 0)
- {
- vNeighborCCosPtr++;
- printf("\n ----------------------List of Discovered Neighbor CCos----------------\n");
- vNeighborCCo = (struct NeighborCCoInfo*)(vNeighborCCosPtr);
- }
- while (vNumNeighborCCos-- > 0)
- {
- vCounter++;
- printf("Node:%d Mac= %s ", vCounter, hexstring(string, sizeof(string), vNeighborCCo->CCoMACAddr, sizeof(vNeighborCCo->CCoMACAddr)));
- printf(" SNID=%d SameNID=%d \n", vNeighborCCo->SNID, vNeighborCCo->IsSameNID);
- vNeighborCCo++;
- }
- }
- free(plc->content);
- plc->content = NULL;
- return (0);
- }
- #endif //TOPOLOGYTABLEINFO_SOURCE
|