1 /* $OpenBSD: sync.h,v 1.5 2016/10/04 22:47:51 krw Exp $ */ 2 3 /* 4 * Copyright (c) 2008, Bob Beck <beck@openbsd.org> 5 * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef _DHCPD_SYNC 21 #define _DHCPD_SYNC 22 23 /* 24 * dhcpd(8) synchronisation protocol. 25 * 26 * This protocol has been designed for realtime synchronisation between 27 * multiple machines running dhcpd(8), running the same config. 28 * It is a simple Type-Length-Value based protocol, it allows easy 29 * extension with future subtypes and bulk transfers by sending multiple 30 * entries at once. The unencrypted messages will be authenticated using 31 * HMAC-SHA1. 32 * 33 */ 34 35 #define DHCP_SYNC_VERSION 1 36 #define DHCP_SYNC_MCASTADDR "224.0.1.240" /* XXX choose valid address */ 37 #define DHCP_SYNC_MCASTTTL IP_DEFAULT_MULTICAST_TTL 38 #define DHCP_SYNC_HMAC_LEN 20 /* SHA1 */ 39 #define DHCP_SYNC_MAXSIZE 1408 40 #define DHCP_SYNC_KEY "/var/db/dhcpd.key" 41 42 #define DHCP_ALIGNBYTES (15) 43 #define DHCP_ALIGN(p) (((u_int)(p) + DHCP_ALIGNBYTES) &~ DHCP_ALIGNBYTES) 44 45 struct dhcp_synchdr { 46 u_int8_t sh_version; 47 u_int8_t sh_af; 48 u_int16_t sh_length; 49 u_int32_t sh_counter; 50 u_int8_t sh_hmac[DHCP_SYNC_HMAC_LEN]; 51 u_int8_t sh_pad[4]; 52 } __packed; 53 54 struct dhcp_synctlv_hdr { 55 u_int16_t st_type; 56 u_int16_t st_length; 57 } __packed; 58 59 struct dhcp_synctlv_lease { 60 u_int16_t lv_type; 61 u_int16_t lv_length; 62 u_int32_t lv_starts, lv_ends, lv_timestamp; 63 struct iaddr lv_ip_addr; 64 struct hardware lv_hardware_addr; 65 } __packed; 66 67 #define DHCP_SYNC_END 0x0000 68 #define DHCP_SYNC_LEASE 0x0001 69 70 extern int syncfd; 71 extern int sync_init(const char *, const char *, u_short); 72 extern int sync_addhost(const char *, u_short); 73 extern void sync_recv(void); 74 extern void sync_lease(struct lease *); 75 #endif /* _DHCPD_SYNC */ 76