PacketAnalizer.h 5.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #include "CcosFileHandle.h"
  3. #include <cstdint> // 添加标准整数类型头文件
  4. class PacketAnalizer
  5. {
  6. public:
  7. PacketAnalizer(void);
  8. virtual ~PacketAnalizer(void);
  9. static uint32_t GetPacketIdx(ResDataObject* pObj);
  10. static PACKET_TYPE GetPacketType(ResDataObject* pObj);
  11. static PACKET_CMD GetPacketCmd(ResDataObject* pObj);
  12. static std::string GetPacketKey(ResDataObject* pObj);
  13. static ResDataObject* GetPacketKeysRes(ResDataObject* pObj);
  14. static std::string GetPacketPublisher(ResDataObject* pObj);
  15. static bool GetPacketHandleExistance(ResDataObject* pPacket);
  16. static bool GetPacketHandle(ResDataObject* pPacket, ResDataObject& Handle);
  17. static bool GetPacketHandleBusId(ResDataObject* pPacket, std::string& BusId, bool dev);
  18. static bool GetPacketHandleMachineId(ResDataObject* pPacket, std::string& MachineId, bool dev);
  19. static bool GetPacketHandleProcId(ResDataObject* pPacket, uint64_t& ProcId, bool dev);
  20. static bool GetPacketHandleAddr(ResDataObject* pPacket, uint64_t& Addr, bool dev);
  21. static bool GetDestinationMachineId(ResDataObject& packet, std::string& machineId);
  22. static bool GetDestinationBusId(ResDataObject& packet, std::string& busId);
  23. static bool GetDestinationProcId(ResDataObject& packet, uint64_t& procId);
  24. static bool GetPacketHandleCrc(ResDataObject* pPacket, uint64_t& Crc);
  25. static bool MakePacketContextExistance(ResDataObject* pPacket);
  26. static bool GetPacketRoute(ResDataObject* pPacket, CCOS_PACKET_ROUTE& Route);
  27. static bool GetPacketContext(ResDataObject* pPacket, ResDataObject& Context);
  28. static bool GetPacketRetCode(ResDataObject* pPacket, RET_STATUS& retcode);
  29. static bool GetPacketMsgInfo(ResDataObject* pPacket, std::string& Info);
  30. static bool GetPacketTransaction(ResDataObject* pPacket, std::string& transaction);
  31. static bool CloneResponse(ResDataObject& Obj, ResDataObject* pReq);
  32. static uint32_t MakePacketIdx();
  33. static ACTION_SYNC_MODE GetPacketSyncMode(ResDataObject* pObj);
  34. static void MakeRetCode(RET_STATUS retcode, ResDataObject* pObj, const char* pMsg = NULL);
  35. static bool MakeResponseByReq(ResDataObject& Response, ResDataObject& Req, RET_STATUS ret, const char* pInfo = NULL);
  36. static void MakeNotify(ResDataObject& Obj, PACKET_CMD cmd, ResDataObject& Key, const ResDataObject& Context);
  37. static void MakeNotify(ResDataObject& Obj, PACKET_CMD cmd, const char* pKey, const ResDataObject& Context);
  38. static void MakeNotify(ResDataObject& Obj, PACKET_CMD cmd, const char* pKey, const char* pContext);
  39. static void MakeNotifyP2P(ResDataObject& Obj, PACKET_CMD cmd, ResDataObject* pReq, const char* pKey, const char* pContext);
  40. static uint32_t MakeActionRequest(ResDataObject& Obj, CcosDevFileHandle& handle, const char* pActionName, ResDataObject& ReqParams, ACTION_SYNC_MODE mode = ACTION_SYNC);
  41. static uint32_t MakeRequest(ResDataObject& Obj, const char* pszReqName, PACKET_CMD cmd, ResDataObject* reqParams);
  42. static uint32_t MakeOpenRequest(ResDataObject& Obj, CcosDevFileHandle& handle, const char* pFilePath);
  43. static bool MakeOpenResponse(ResDataObject& Req, ResDataObject& Res, ResDataObject& DevResource);
  44. static bool MakeCloseNotifyByRes(ResDataObject& Response, ResDataObject& Req);
  45. static bool MakeCloseRequestByRes(ResDataObject& Response, ResDataObject& Req);
  46. static bool MakeCloseRequest(ResDataObject& Obj, CcosDevFileHandle& handle, PACKET_TYPE Type = PACKET_TYPE_REQ);
  47. static bool MakeCloseResponse(ResDataObject& Req, ResDataObject& Res);
  48. static bool UpdatePacketRoute(ResDataObject& Obj, CCOS_PACKET_ROUTE Route);
  49. static bool UpdateOpenRequest(ResDataObject& Req, ResDataObject& MachineId, ResDataObject& busId, uint64_t ProcId, uint64_t Addr);
  50. static bool UpdateNotifyHandle(ResDataObject& Obj, CcosDevFileHandle& handle);
  51. static bool UpdateDeviceNotifyResponse(ResDataObject& Req, ResDataObject& MachineId, ResDataObject& busId, uint64_t ProcId, uint64_t Addr);
  52. static bool UpdatePacketContext(ResDataObject& packet, ResDataObject& Context);
  53. static bool UpdatePacketTransaction(ResDataObject& packet, std::string strTransaction);
  54. static bool GetParam(ResDataObject* pReq, unsigned int ParamIdx, ResDataObject& value);
  55. static bool AddParam(ResDataObject* pRes, unsigned int ParamIdx, ResDataObject& value);
  56. static bool UpdateParam(ResDataObject* pRes, unsigned int ParamIdx, ResDataObject& value);
  57. static bool UpdatePacketTopic(ResDataObject* Obj, const char* pszTopic, const char* pszClientID);
  58. static bool UpdatePacketKey(ResDataObject* Obj, const char* keystr);
  59. static bool UpdateContextTopic(ResDataObject* Obj, const char* pszRespTopic);
  60. static bool GetContextTopic(ResDataObject* Obj, ResDataObject& topic);
  61. static bool GetPacketTopic(ResDataObject* Obj, ResDataObject& topic);
  62. static bool CloneTransaction(ResDataObject* req, ResDataObject* res);
  63. static std::string GetActionTopic(const char* szDevicePath, const char* szAction);
  64. static bool UpdateHandleId(ResDataObject* Obj, uint64_t id);
  65. static bool GetHandleId(ResDataObject* Obj, uint64_t& Id);
  66. };