Repository navigation
Expand file tree
/
Copy pathwindows_platform.cpp
More file actions
70 lines (64 loc) · 2.21 KB
/
Copy pathwindows_platform.cpp
File metadata and controls
70 lines (64 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT
#include <cassert>
#include <stdexcept>
#include "api_internal.h"
#include "crab_verifier_wrapper.hpp"
#include "api_common.hpp"
#include "ebpf_api.h"
#include "ebpf_helpers.h"
#include "helpers.hpp"
#include "map_descriptors.hpp"
#include "platform.hpp"
#include "spec_type_descriptors.hpp"
#include "windows_platform.hpp"
#include "windows_platform_common.hpp"
int
create_map_internal(
uint32_t type, uint32_t key_size, uint32_t value_size, uint32_t max_entries, ebpf_verifier_options_t options);
static int
create_map_windows(
uint32_t map_type, uint32_t key_size, uint32_t value_size, uint32_t max_entries, ebpf_verifier_options_t options)
{
int fd;
if (options.mock_map_fds) {
EbpfMapType type = get_map_type_windows(map_type);
fd = create_map_crab(type, key_size, value_size, max_entries, options);
cache_map_file_descriptor(map_type, key_size, value_size, max_entries, fd);
return fd;
}
return create_map_internal(map_type, key_size, value_size, max_entries, options);
}
void
parse_maps_section_windows(
std::vector<EbpfMapDescriptor>& map_descriptors,
const char* data,
size_t size,
const struct ebpf_platform_t*,
ebpf_verifier_options_t options)
{
if (size % sizeof(ebpf_map_definition_t) != 0) {
throw std::runtime_error(
std::string("bad maps section size, must be a multiple of ") +
std::to_string(sizeof(ebpf_map_definition_t)));
}
auto mapdefs =
std::vector<ebpf_map_definition_t>((ebpf_map_definition_t*)data, (ebpf_map_definition_t*)(data + size));
for (auto& s : mapdefs) {
map_descriptors.emplace_back(EbpfMapDescriptor{
.original_fd = create_map_windows(s.type, s.key_size, s.value_size, s.max_entries, options),
.type = (uint32_t)s.type,
.key_size = s.key_size,
.value_size = s.value_size,
});
}
}
const ebpf_platform_t g_ebpf_platform_windows = {
get_program_type_windows,
get_helper_prototype_windows,
is_helper_usable_windows,
sizeof(ebpf_map_definition_t),
parse_maps_section_windows,
get_map_descriptor_windows,
get_map_type_windows,
};