table.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. };
  44. class ArrayTable : public BaseTable {
  45. public:
  46. using BaseTable::BaseTable;
  47. Php::Value php_get_value(Php::Parameters &param);
  48. };
  49. class ProgArrayTable : public BaseTable {
  50. public:
  51. using BaseTable::BaseTable;
  52. // void Value(Php::Parameters &param) {
  53. // auto index = param[0].numericValue();
  54. // // todo key type
  55. // uint64_t val;
  56. // auto table = bpf->get_array_table<uint64_t>(tb_name);
  57. //// virtual StatusTuple get_value(const int& index, ValueType& value) {
  58. // auto res = table.get_value(index, val);
  59. // }
  60. };
  61. class PerCpuHashTable : public BaseTable {
  62. public:
  63. using BaseTable::BaseTable;
  64. };
  65. class PerCpuArrayTable : public BaseTable {
  66. public:
  67. using BaseTable::BaseTable;
  68. Php::Value php_sum_value(Php::Parameters &param);
  69. };
  70. class LpmTrieTable : public BaseTable {
  71. public:
  72. using BaseTable::BaseTable;
  73. };
  74. class StackTraceTable : public BaseTable {
  75. public:
  76. using BaseTable::BaseTable;
  77. Php::Value php_get_values(Php::Parameters &param);
  78. };
  79. class LruHashTable : public BaseTable {
  80. public:
  81. using BaseTable::BaseTable;
  82. };
  83. class LruPerCpuHashTable : public BaseTable {
  84. public:
  85. using BaseTable::BaseTable;
  86. };
  87. class CgroupArrayTable : public BaseTable {
  88. public:
  89. using BaseTable::BaseTable;
  90. };
  91. class DevMapTable : public BaseTable {
  92. public:
  93. using BaseTable::BaseTable;
  94. };
  95. class CpuMapTable : public BaseTable {
  96. public:
  97. using BaseTable::BaseTable;
  98. };
  99. class XskMapTable : public BaseTable {
  100. public:
  101. using BaseTable::BaseTable;
  102. };
  103. class MapInMapArrayTable : public BaseTable {
  104. public:
  105. using BaseTable::BaseTable;
  106. };
  107. class MapInMapHashTable : public BaseTable {
  108. public:
  109. using BaseTable::BaseTable;
  110. };
  111. class QueueStackTable : public BaseTable {
  112. public:
  113. using BaseTable::BaseTable;
  114. };
  115. class RingBufTable : public BaseTable {
  116. public:
  117. using BaseTable::BaseTable;
  118. };
  119. #endif //PHPCPP_HELLOWORLD_TABLE_H