log A record for block list
[ghsmtp.git] / OpenDMARC.hpp
blob5ef263e1c26f44e5f872f4498806cdc7d0309035
1 #ifndef OPENDMARC_DOT_HPP
2 #define OPENDMARC_DOT_HPP
4 #include "IP6.hpp"
6 #include <opendmarc/dmarc.h>
8 #include <glog/logging.h>
10 namespace OpenDMARC {
12 enum class advice;
13 constexpr char const* advice_to_string(advice adv);
15 class lib {
16 // no copy
17 lib(lib const&) = delete;
18 lib& operator=(lib const&) = delete;
20 public:
21 // move
22 lib(lib&&) = default;
23 lib& operator=(lib&&) = default;
25 lib();
26 ~lib();
28 private:
29 OPENDMARC_LIB_T lib_;
32 class policy {
33 // no copy
34 policy(policy const&) = delete;
35 policy& operator=(policy const&) = delete;
37 public:
38 policy() = default;
40 // move
41 policy(policy&&) = default;
42 policy& operator=(policy&&) = default;
44 ~policy();
46 void connect(char const* ip);
47 bool store_from_domain(char const* from_domain);
48 bool store_dkim(char const* d_equal_domain,
49 char const* d_selector,
50 int dkim_result,
51 char const* human_result);
52 bool store_spf(char const* domain,
53 int result,
54 int origin,
55 char const* human_readable);
56 bool query_dmarc(char const* domain);
57 advice get_advice();
59 private:
60 DMARC_POLICY_T* pctx_{nullptr};
63 enum class advice {
64 ACCEPT,
65 REJECT,
66 QUARANTINE,
67 NONE,
70 constexpr char const* advice_to_string(advice adv)
72 switch (adv) {
73 case advice::ACCEPT: return "accept";
74 case advice::REJECT: return "reject";
75 case advice::QUARANTINE: return "quarantine";
76 case advice::NONE: break;
78 return "none";
81 constexpr char const* policy_spf_to_string(int pol)
83 switch (pol) {
84 case DMARC_POLICY_SPF_OUTCOME_NONE: return "SPF_OUTCOME_NONE";
85 case DMARC_POLICY_SPF_OUTCOME_PASS: return "SPF_OUTCOME_PASS";
86 case DMARC_POLICY_SPF_OUTCOME_FAIL: return "SPF_OUTCOME_FAIL";
87 case DMARC_POLICY_SPF_OUTCOME_TMPFAIL: return "SPF_OUTCOME_TMPFAIL";
88 case DMARC_POLICY_SPF_ALIGNMENT_PASS: return "SPF_ALIGNMENT_PASS";
89 case DMARC_POLICY_SPF_ALIGNMENT_FAIL: return "SPF_ALIGNMENT_FAIL";
91 return "none";
94 } // namespace OpenDMARC
96 #endif // OPENDMARC_DOT_HPP