1 /* $OpenBSD: sync.h,v 1.1 2007/03/04 03:19:41 beck Exp $ */ 2 3 /* 4 * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _SPAMD_SYNC 20 #define _SPAMD_SYNC 21 22 /* 23 * spamd(8) synchronisation protocol. 24 * 25 * This protocol has been designed for realtime synchronisation between 26 * multiple machines running spamd(8), ie. in front of a MX and a backup MX. 27 * It is a simple Type-Length-Value based protocol, it allows easy 28 * extension with future subtypes and bulk transfers by sending multiple 29 * entries at once. The unencrypted messages will be authenticated using 30 * HMAC-SHA1. 31 * 32 * the spamd(8) synchronisation protocol is not intended to be used as 33 * a public SPAM sender database or distribution between vendors. 34 */ 35 36 #define SPAM_SYNC_VERSION 1 37 #define SPAM_SYNC_MCASTADDR "224.0.1.240" /* XXX choose valid address */ 38 #define SPAM_SYNC_MCASTTTL IP_DEFAULT_MULTICAST_TTL 39 #define SPAM_SYNC_HMAC_LEN 20 /* SHA1 */ 40 #define SPAM_SYNC_MAXSIZE 1408 41 #define SPAM_SYNC_KEY "/etc/mail/spamd.key" 42 43 struct spam_synchdr { 44 u_int8_t sh_version; 45 u_int8_t sh_af; 46 u_int32_t sh_counter; 47 u_int16_t sh_length; 48 u_int8_t sh_hmac[SPAM_SYNC_HMAC_LEN]; 49 u_int16_t sh_pad[1]; 50 } __packed; 51 52 struct spam_synctlv_hdr { 53 u_int16_t st_type; 54 u_int16_t st_length; 55 } __packed; 56 57 struct spam_synctlv_grey { 58 u_int16_t sg_type; 59 u_int16_t sg_length; 60 u_int32_t sg_timestamp; 61 u_int32_t sg_ip; 62 u_int16_t sg_from_length; 63 u_int16_t sg_to_length; 64 u_int16_t sg_helo_length; 65 } __packed; 66 67 struct spam_synctlv_addr { 68 u_int16_t sd_type; 69 u_int16_t sd_length; 70 u_int32_t sd_timestamp; 71 u_int32_t sd_expire; 72 u_int32_t sd_ip; 73 } __packed; 74 75 #define SPAM_SYNC_END 0x0000 76 #define SPAM_SYNC_GREY 0x0001 77 #define SPAM_SYNC_WHITE 0x0002 78 #define SPAM_SYNC_TRAPPED 0x0003 79 80 extern int sync_init(const char *, const char *, u_short); 81 extern int sync_addhost(const char *, u_short); 82 extern void sync_recv(void); 83 extern void sync_update(time_t, char *, char *, char *, char *); 84 extern void sync_white(time_t, time_t, char *); 85 extern void sync_trapped(time_t, time_t, char *); 86 87 #endif /* _SPAMD_SYNC */ 88