You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spf.h 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef RSPAMD_SPF_H
  2. #define RSPAMD_SPF_H
  3. #include "config.h"
  4. #include "ref.h"
  5. #include "addr.h"
  6. struct rspamd_task;
  7. struct spf_resolved;
  8. typedef void (*spf_cb_t)(struct spf_resolved *record,
  9. struct rspamd_task *task, gpointer cbdata);
  10. typedef enum spf_mech_e {
  11. SPF_FAIL,
  12. SPF_SOFT_FAIL,
  13. SPF_PASS,
  14. SPF_NEUTRAL
  15. } spf_mech_t;
  16. typedef enum spf_action_e {
  17. SPF_RESOLVE_MX,
  18. SPF_RESOLVE_A,
  19. SPF_RESOLVE_PTR,
  20. SPF_RESOLVE_AAA,
  21. SPF_RESOLVE_REDIRECT,
  22. SPF_RESOLVE_INCLUDE,
  23. SPF_RESOLVE_EXISTS,
  24. SPF_RESOLVE_EXP
  25. } spf_action_t;
  26. #define RSPAMD_SPF_FLAG_IPV6 (1 << 0)
  27. #define RSPAMD_SPF_FLAG_IPV4 (1 << 1)
  28. #define RSPAMD_SPF_FLAG_PROCESSED (1 << 2)
  29. #define RSPAMD_SPF_FLAG_ANY (1 << 3)
  30. #define RSPAMD_SPF_FLAG_PARSED (1 << 4)
  31. #define RSPAMD_SPF_FLAG_INVALID (1 << 5)
  32. #define RSPAMD_SPF_FLAG_REFERENCE (1 << 6)
  33. #define RSPAMD_SPF_FLAG_REDIRECT (1 << 7)
  34. #define RSPAMD_SPF_FLAG_TEMPFAIL (1 << 8)
  35. #define RSPAMD_SPF_FLAG_NA (1 << 9)
  36. #define RSPAMD_SPF_FLAG_PERMFAIL (1 << 10)
  37. #define RSPAMD_SPF_FLAG_RESOLVED (1 << 11)
  38. struct spf_addr {
  39. guchar addr6[sizeof (struct in6_addr)];
  40. guchar addr4[sizeof (struct in_addr)];
  41. union {
  42. struct {
  43. guint16 mask_v4;
  44. guint16 mask_v6;
  45. } dual;
  46. guint32 idx;
  47. } m;
  48. guint flags;
  49. spf_mech_t mech;
  50. gchar *spf_string;
  51. struct spf_addr *prev, *next;
  52. };
  53. struct spf_resolved {
  54. gchar *domain;
  55. guint ttl;
  56. gboolean temp_failed;
  57. gboolean na;
  58. gboolean perm_failed;
  59. GArray *elts; /* Flat list of struct spf_addr */
  60. ref_entry_t ref; /* Refcounting */
  61. };
  62. /*
  63. * Resolve spf record for specified task and call a callback after resolution fails/succeed
  64. */
  65. gboolean rspamd_spf_resolve (struct rspamd_task *task, spf_cb_t callback,
  66. gpointer cbdata);
  67. /*
  68. * Get a domain for spf for specified task
  69. */
  70. const gchar * rspamd_spf_get_domain (struct rspamd_task *task);
  71. /*
  72. * Increase refcount
  73. */
  74. struct spf_resolved * spf_record_ref (struct spf_resolved *rec);
  75. /*
  76. * Decrease refcount
  77. */
  78. void spf_record_unref (struct spf_resolved *rec);
  79. #endif