proto.h revision 212033
11541Srgrimes/*-
21541Srgrimes * Copyright (c) 2009-2010 The FreeBSD Foundation
31541Srgrimes * All rights reserved.
41541Srgrimes *
51541Srgrimes * This software was developed by Pawel Jakub Dawidek under sponsorship from
61541Srgrimes * the FreeBSD Foundation.
71541Srgrimes *
81541Srgrimes * Redistribution and use in source and binary forms, with or without
91541Srgrimes * modification, are permitted provided that the following conditions
101541Srgrimes * are met:
111541Srgrimes * 1. Redistributions of source code must retain the above copyright
121541Srgrimes *    notice, this list of conditions and the following disclaimer.
131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer in the
151541Srgrimes *    documentation and/or other materials provided with the distribution.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes * $FreeBSD: head/sbin/hastd/proto.h 212033 2010-08-30 22:26:42Z pjd $
3050477Speter */
311541Srgrimes
321541Srgrimes#ifndef	_PROTO_H_
3370650Swollman#define	_PROTO_H_
3470650Swollman
351541Srgrimes#include <stdbool.h>	/* bool */
3692407Sbde#include <stdlib.h>	/* size_t */
3759288Sjlemon
38174647Sjeffstruct proto_conn;
39174647Sjeff
40174647Sjeffint proto_client(const char *addr, struct proto_conn **connp);
411541Srgrimesint proto_connect(struct proto_conn *conn);
421541Srgrimesint proto_server(const char *addr, struct proto_conn **connp);
431541Srgrimesint proto_accept(struct proto_conn *conn, struct proto_conn **newconnp);
441541Srgrimesint proto_send(const struct proto_conn *conn, const void *data, size_t size);
451541Srgrimesint proto_recv(const struct proto_conn *conn, void *data, size_t size);
46174647Sjeffint proto_descriptor(const struct proto_conn *conn);
47174647Sjeffbool proto_address_match(const struct proto_conn *conn, const char *addr);
48174647Sjeffvoid proto_local_address(const struct proto_conn *conn, char *addr,
491541Srgrimes    size_t size);
501541Srgrimesvoid proto_remote_address(const struct proto_conn *conn, char *addr,
51174647Sjeff    size_t size);
5292252Salfredint proto_timeout(const struct proto_conn *conn, int timeout);
5364326Sgreenvoid proto_close(struct proto_conn *conn);
54225177Sattilio
5592719Salfred#endif	/* !_PROTO_H_ */
5692719Salfred