|
3 | 3 | package gosdk |
4 | 4 |
|
5 | 5 | // Following is a distillation of the Envoy ABI for dynamic modules: |
6 | | -// https://github.com/envoyproxy/envoy/blob/dc2d3098ae5641555f15c71d5bb5ce0060a8015c/source/extensions/dynamic_modules/abi.h |
| 6 | +// https://github.com/envoyproxy/envoy/blob/6d9bb7d9a85d616b220d1f8fe67b61f82bbdb8d3/source/extensions/dynamic_modules/abi.h |
7 | 7 | // |
8 | 8 | // Why not using the header file directly? That is because Go runtime complains |
9 | 9 | // about passing pointers to C code on the boundary. In the following code, we replace |
@@ -91,13 +91,19 @@ bool envoy_dynamic_module_callback_http_get_response_body_vector( |
91 | 91 | bool envoy_dynamic_module_callback_http_get_response_body_vector_size( |
92 | 92 | uintptr_t filter_envoy_ptr, size_t* size); |
93 | 93 |
|
| 94 | +// envoy_dynamic_module_type_module_buffer is a struct representing a buffer owned by the module. |
| 95 | +typedef struct { |
| 96 | + uintptr_t ptr; |
| 97 | + size_t length; |
| 98 | +} envoy_dynamic_module_type_module_buffer; |
| 99 | +
|
94 | 100 | #cgo noescape envoy_dynamic_module_callback_http_send_response |
95 | | -// Uncomment once https://github.com/envoyproxy/envoy/pull/39206 is merged. |
96 | | -// #cgo nocallback envoy_dynamic_module_callback_http_send_response |
| 101 | +#cgo nocallback envoy_dynamic_module_callback_http_send_response |
97 | 102 | void envoy_dynamic_module_callback_http_send_response( |
98 | 103 | uintptr_t filter_envoy_ptr, uint32_t status_code, |
99 | 104 | uintptr_t headers_vector, size_t headers_vector_size, |
100 | | - uintptr_t body, size_t body_length); |
| 105 | + envoy_dynamic_module_type_module_buffer body, |
| 106 | + envoy_dynamic_module_type_module_buffer details); |
101 | 107 |
|
102 | 108 | #cgo noescape envoy_dynamic_module_callback_http_get_request_headers_count |
103 | 109 | #cgo nocallback envoy_dynamic_module_callback_http_get_request_headers_count |
@@ -161,8 +167,8 @@ import ( |
161 | 167 | "unsafe" |
162 | 168 | ) |
163 | 169 |
|
164 | | -// https://github.com/envoyproxy/envoy/blob/dc2d3098ae5641555f15c71d5bb5ce0060a8015c/source/extensions/dynamic_modules/abi_version.h |
165 | | -var version = append([]byte("ca2be3b80954d2a0e22b41d033b18eff9390c30261c8ec9ffe6e6bf971f41c27"), 0) |
| 170 | +// https://github.com/envoyproxy/envoy/blob/6d9bb7d9a85d616b220d1f8fe67b61f82bbdb8d3/source/extensions/dynamic_modules/abi.h |
| 171 | +var version = append([]byte("4dae397a7c9ff0238d318d57ea656ce8b3fbff595787dcd7ee2ff5b79c9fe10f"), 0) |
166 | 172 |
|
167 | 173 | //export envoy_dynamic_module_on_program_init |
168 | 174 | func envoy_dynamic_module_on_program_init() uintptr { |
@@ -546,8 +552,8 @@ func (e envoyFilter) SendLocalReply(statusCode uint32, headers [][2]string, body |
546 | 552 | C.uint32_t(statusCode), |
547 | 553 | C.uintptr_t(headersVecPtr), |
548 | 554 | C.size_t(headersVecSize), |
549 | | - C.uintptr_t(bodyPtr), |
550 | | - C.size_t(bodySize), |
| 555 | + C.envoy_dynamic_module_type_module_buffer{ptr: C.uintptr_t(bodyPtr), length: C.size_t(bodySize)}, |
| 556 | + C.envoy_dynamic_module_type_module_buffer{ptr: 0, length: 0}, // Empty details |
551 | 557 | ) |
552 | 558 | runtime.KeepAlive(headers) |
553 | 559 | runtime.KeepAlive(body) |
|
0 commit comments