xref: /openbsd-src/usr.sbin/sasyncd/net.h (revision 9945a12e699d4086ee532d8a97f7f43e818353e0)
1*9945a12eSmcbride /*	$OpenBSD: net.h,v 1.5 2006/06/02 20:09:43 mcbride Exp $	*/
27aea46c5Sho 
37aea46c5Sho /*
47aea46c5Sho  * Copyright (c) 2005 H�kan Olsson.  All rights reserved.
57aea46c5Sho  *
67aea46c5Sho  * Redistribution and use in source and binary forms, with or without
77aea46c5Sho  * modification, are permitted provided that the following conditions
87aea46c5Sho  * are met:
97aea46c5Sho  *
107aea46c5Sho  * 1. Redistributions of source code must retain the above copyright
117aea46c5Sho  *    notice, this list of conditions and the following disclaimer.
127aea46c5Sho  * 2. Redistributions in binary form must reproduce the above copyright
137aea46c5Sho  *    notice, this list of conditions and the following disclaimer in the
147aea46c5Sho  *    documentation and/or other materials provided with the distribution.
157aea46c5Sho  *
167aea46c5Sho  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
177aea46c5Sho  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
187aea46c5Sho  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
197aea46c5Sho  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
207aea46c5Sho  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
217aea46c5Sho  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
227aea46c5Sho  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
237aea46c5Sho  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
247aea46c5Sho  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
257aea46c5Sho  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
267aea46c5Sho  */
277aea46c5Sho 
287aea46c5Sho /*
297aea46c5Sho  * This code was written under funding by Multicom Security AB.
307aea46c5Sho  */
317aea46c5Sho 
327aea46c5Sho 
337aea46c5Sho struct qmsg;
347aea46c5Sho struct syncpeer {
357aea46c5Sho 	LIST_ENTRY(syncpeer)	link;
367aea46c5Sho 
377aea46c5Sho 	char		*name;		/* FQDN or an IP, from conf */
381bf4baafSho 	struct sockaddr	*sa;
397aea46c5Sho 	int		 socket;
407aea46c5Sho 	enum RUNSTATE	 runstate;
417aea46c5Sho 
427aea46c5Sho 	SIMPLEQ_HEAD(, qmsg)	msgs;
437aea46c5Sho };
447aea46c5Sho 
457aea46c5Sho /* Control message types. */
46*9945a12eSmcbride enum CTLTYPE { RESERVED = 0, CTL_STATE, CTL_ERROR, CTL_ACK,
47*9945a12eSmcbride     CTL_ENDSNAP, CTL_UNKNOWN };
487aea46c5Sho #define CTLTYPES { \
49*9945a12eSmcbride 	"RESERVED", "CTL_STATE", "CTL_ERROR", "CTL_ACK", \
50*9945a12eSmcbride 	"CTL_ENDSNAP", "CTL_UNKNOWN" \
517aea46c5Sho };
527aea46c5Sho 
537aea46c5Sho /* net.c */
541d55a410Sho void	net_connect(void);
557aea46c5Sho void	net_disconnect_peer(struct syncpeer *);
567aea46c5Sho 
577aea46c5Sho /* net_ctl.c */
587aea46c5Sho void	net_ctl_handle_msg(struct syncpeer *, u_int8_t *, u_int32_t);
597aea46c5Sho int	net_ctl_send_ack(struct syncpeer *, enum CTLTYPE, u_int32_t);
607aea46c5Sho int	net_ctl_send_error(struct syncpeer *, enum CTLTYPE);
61*9945a12eSmcbride int	net_ctl_send_endsnap(struct syncpeer *);
627aea46c5Sho int	net_ctl_send_state(struct syncpeer *);
637aea46c5Sho 
64