table.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #ifndef PHPCPP_HELLOWORLD_TABLE_H
  2. #define PHPCPP_HELLOWORLD_TABLE_H
  3. #include <iostream>
  4. #include <phpcpp.h>
  5. #include "bpf_module.h"
  6. #include "BPF.h"
  7. class BaseTable : public Php::Base {
  8. public:
  9. ebpf::BPF *bpf;
  10. std::string tb_name;
  11. BaseTable(ebpf::BPF *bpf_instance, const std::string &tb_name)
  12. : bpf(bpf_instance), tb_name(tb_name) {}
  13. virtual ~BaseTable() = default;
  14. void printName();
  15. // void printName() { std::cout << "Table name: " << tb_name << std::endl; }
  16. // Php::Value Value(Php::Parameters &param) {
  17. // auto index = param[0].numericValue();
  18. // // todo val type
  19. // uint64_t val;
  20. // auto table = bpf->get_array_table<uint64_t>(tb_name);
  21. // auto res = table.get_value(index, val);
  22. // if (!res.ok()) {
  23. // throw Php::Exception("Get value error in" + std::string(tb_name));
  24. // }
  25. // Php::Value phpValue = static_cast<int64_t>(val);
  26. // return phpValue;
  27. // }
  28. };
  29. class PerfEventArrayTable : public BaseTable {
  30. private:
  31. std::string cb;
  32. public:
  33. using BaseTable::BaseTable;
  34. virtual ~PerfEventArrayTable() = default;
  35. static void callbackfn(void *cookie, void *data, int data_size);
  36. void php_open_perf_buffer(Php::Parameters &params);
  37. int perf_buffer_poll(int timeout_ms);
  38. };
  39. class HashTable : public BaseTable {
  40. public:
  41. using BaseTable::BaseTable;
  42. Php::Value php_get_values();
  43. void php_clear();
  44. };
  45. class ArrayTable : public BaseTable {
  46. public:
  47. using BaseTable::BaseTable;
  48. Php::Value php_get_value(Php::Parameters &param);
  49. };
  50. class ProgArrayTable : public BaseTable {
  51. public:
  52. using BaseTable::BaseTable;
  53. // void Value(Php::Parameters &param) {
  54. // auto index = param[0].numericValue();
  55. // // todo key type
  56. // uint64_t val;
  57. // auto table = bpf->get_array_table<uint64_t>(tb_name);
  58. //// virtual StatusTuple get_value(const int& index, ValueType& value) {
  59. // auto res = table.get_value(index, val);
  60. // }
  61. };
  62. class PerCpuHashTable : public BaseTable {
  63. public:
  64. using BaseTable::BaseTable;
  65. };
  66. class PerCpuArrayTable : public BaseTable {
  67. public:
  68. using BaseTable::BaseTable;
  69. Php::Value php_sum_value(Php::Parameters &param);
  70. };
  71. class LpmTrieTable : public BaseTable {
  72. public:
  73. using BaseTable::BaseTable;
  74. };
  75. class StackTraceTable : public BaseTable {
  76. public:
  77. using BaseTable::BaseTable;
  78. Php::Value php_get_values(Php::Parameters &param);
  79. };
  80. class LruHashTable : public BaseTable {
  81. public:
  82. using BaseTable::BaseTable;
  83. };
  84. class LruPerCpuHashTable : public BaseTable {
  85. public:
  86. using BaseTable::BaseTable;
  87. };
  88. class CgroupArrayTable : public BaseTable {
  89. public:
  90. using BaseTable::BaseTable;
  91. };
  92. class DevMapTable : public BaseTable {
  93. public:
  94. using BaseTable::BaseTable;
  95. };
  96. class CpuMapTable : public BaseTable {
  97. public:
  98. using BaseTable::BaseTable;
  99. };
  100. class XskMapTable : public BaseTable {
  101. public:
  102. using BaseTable::BaseTable;
  103. };
  104. class MapInMapArrayTable : public BaseTable {
  105. public:
  106. using BaseTable::BaseTable;
  107. };
  108. class MapInMapHashTable : public BaseTable {
  109. public:
  110. using BaseTable::BaseTable;
  111. };
  112. class QueueStackTable : public BaseTable {
  113. public:
  114. using BaseTable::BaseTable;
  115. };
  116. class RingBufTable : public BaseTable {
  117. public:
  118. using BaseTable::BaseTable;
  119. };
  120. #endif //PHPCPP_HELLOWORLD_TABLE_H