1 /* 2 ** Copyright (c) 2007-2009 Sendmail, Inc. and its suppliers. 3 ** All rights reserved. 4 ** 5 ** Copyright (c) 2009, 2012, 2014, 2018, The Trusted Domain Project. 6 ** All rights reserved. 7 */ 8 9 #ifndef _OPENDMARC_AR_H_ 10 #define _OPENDMARC_AR_H_ 11 12 /* system includes */ 13 #include <sys/types.h> 14 15 /* opendmarc includes */ 16 #include "opendmarc.h" 17 #include "dmarc.h" 18 19 /* limits */ 20 #define AUTHRESHDRNAME "Authentication-Results" 21 #define MAXARESULTS 16 22 #define MAXPROPS 16 23 #define MAXAVALUE 256 24 25 /* ARES_METHOD_T -- type for specifying an authentication method */ 26 typedef int ares_method_t; 27 28 #define ARES_METHOD_UNKNOWN (-1) 29 #define ARES_METHOD_AUTH 0 30 #define ARES_METHOD_DKIM 1 31 #define ARES_METHOD_DOMAINKEYS 2 32 #define ARES_METHOD_SENDERID 3 33 #define ARES_METHOD_SPF 4 34 #define ARES_METHOD_DKIMADSP 5 35 #define ARES_METHOD_IPREV 6 36 #define ARES_METHOD_DKIMATPS 7 37 #define ARES_METHOD_SMIME 8 38 #define ARES_METHOD_RRVS 9 39 #define ARES_METHOD_ARC 10 40 41 /* ARES_RESULT_T -- type for specifying an authentication result */ 42 typedef int ares_result_t; 43 44 #define ARES_RESULT_UNDEFINED (-1) 45 #define ARES_RESULT_PASS 0 46 #define ARES_RESULT_UNUSED 1 47 #define ARES_RESULT_SOFTFAIL 2 48 #define ARES_RESULT_NEUTRAL 3 49 #define ARES_RESULT_TEMPERROR 4 50 #define ARES_RESULT_PERMERROR 5 51 #define ARES_RESULT_NONE 6 52 #define ARES_RESULT_FAIL 7 53 #define ARES_RESULT_POLICY 8 54 #define ARES_RESULT_NXDOMAIN 9 55 #define ARES_RESULT_SIGNED 10 56 #define ARES_RESULT_UNKNOWN 11 57 #define ARES_RESULT_DISCARD 12 58 59 /* ARES_PTYPE_T -- type for specifying an authentication property */ 60 typedef int ares_ptype_t; 61 62 #define ARES_PTYPE_UNKNOWN (-1) 63 #define ARES_PTYPE_SMTP 0 64 #define ARES_PTYPE_HEADER 1 65 #define ARES_PTYPE_BODY 2 66 #define ARES_PTYPE_POLICY 3 67 #define ARES_PTYPE_ARCCHAIN 4 68 69 /* RESULT structure -- a single result */ 70 struct result 71 { 72 int result_props; 73 ares_method_t result_method; 74 ares_result_t result_result; 75 ares_ptype_t result_ptype[MAXPROPS]; 76 unsigned char result_reason[MAXAVALUE + 1]; 77 unsigned char result_property[MAXPROPS][MAXAVALUE + 1]; 78 unsigned char result_value[MAXPROPS][MAXAVALUE + 1]; 79 }; 80 81 /* AUTHRES structure -- the entire header parsed */ 82 struct authres 83 { 84 int ares_count; 85 unsigned char ares_host[DMARC_MAXHOSTNAMELEN + 1]; 86 unsigned char ares_version[MAXAVALUE + 1]; 87 struct result ares_result[MAXARESULTS]; 88 }; 89 90 /* 91 ** ARES_PARSE -- parse an Authentication-Results: header, return a 92 ** structure containing a parsed result 93 ** 94 ** Parameters: 95 ** hdr -- NULL-terminated contents of an Authentication-Results: 96 ** header field 97 ** ar -- a pointer to a (struct authres) loaded by values after parsing 98 ** 99 ** Return value: 100 ** 0 on success, -1 on failure. 101 */ 102 103 extern int ares_parse __P((u_char *hdr, struct authres *ar)); 104 105 #endif /* _OPENDMARC_AR_H_ */ 106