-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
44 lines (34 loc) · 1.51 KB
/
common.h
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
// Copyright 2023 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SECAGENTD_COMMON_H_
#define SECAGENTD_COMMON_H_
#include <unistd.h>
#include "absl/strings/str_format.h"
#include "dbus/bus.h"
namespace secagentd {
// Used by BPF skeleton wrappers to help call a C++ class method from a C style
// callback. The void* ctx shall always point to a
// RepeatingCallback<void(const bpf::event&)>. void* data is cast into a
// bpf::event and then passed into this RepeatingCallback.
extern "C" int indirect_c_callback(void* ctx, void* data, size_t size);
namespace common {
void SetDBus(scoped_refptr<dbus::Bus>);
scoped_refptr<dbus::Bus> GetDBus();
} // namespace common
namespace Types {
enum class BpfSkeleton { kProcess, kNetwork };
enum class Plugin { kAgent, kNetwork, kProcess, kAuthenticate };
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
AbslFormatConvert(const BpfSkeleton& type,
const absl::FormatConversionSpec&,
absl::FormatSink* output_sink);
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
AbslFormatConvert(const Types::Plugin& type,
const absl::FormatConversionSpec&,
absl::FormatSink* sink);
} // namespace Types
std::ostream& operator<<(std::ostream& out, const Types::Plugin& type);
std::ostream& operator<<(std::ostream& out, const Types::BpfSkeleton& type);
} // namespace secagentd
#endif // SECAGENTD_COMMON_H_