1243730Srwatson/*- 2243730Srwatson * Copyright (c) 2009-2010 The FreeBSD Foundation 3243730Srwatson * All rights reserved. 4243730Srwatson * 5243730Srwatson * This software was developed by Pawel Jakub Dawidek under sponsorship from 6243730Srwatson * the FreeBSD Foundation. 7243730Srwatson * 8243730Srwatson * Redistribution and use in source and binary forms, with or without 9243730Srwatson * modification, are permitted provided that the following conditions 10243730Srwatson * are met: 11243730Srwatson * 1. Redistributions of source code must retain the above copyright 12243730Srwatson * notice, this list of conditions and the following disclaimer. 13243730Srwatson * 2. Redistributions in binary form must reproduce the above copyright 14243730Srwatson * notice, this list of conditions and the following disclaimer in the 15243730Srwatson * documentation and/or other materials provided with the distribution. 16243730Srwatson * 17243730Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 18243730Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19243730Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20243730Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 21243730Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22243730Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23243730Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24243730Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25243730Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26243730Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27243730Srwatson * SUCH DAMAGE. 28243730Srwatson */ 29243730Srwatson 30243730Srwatson#ifndef _PROTO_H_ 31243730Srwatson#define _PROTO_H_ 32243730Srwatson 33243730Srwatson#include <stdbool.h> /* bool */ 34243730Srwatson#include <stdlib.h> /* size_t */ 35243730Srwatson 36243730Srwatsonstruct proto_conn; 37243730Srwatson 38243730Srwatsonint proto_connect(const char *srcaddr, const char *dstaddr, int timeout, 39243730Srwatson struct proto_conn **connp); 40243730Srwatsonint proto_connect_wait(struct proto_conn *conn, int timeout); 41243730Srwatsonint proto_server(const char *addr, struct proto_conn **connp); 42243730Srwatsonint proto_accept(struct proto_conn *conn, struct proto_conn **newconnp); 43243730Srwatsonint proto_send(const struct proto_conn *conn, const void *data, size_t size); 44243730Srwatsonint proto_recv(const struct proto_conn *conn, void *data, size_t size); 45243730Srwatsonint proto_connection_send(const struct proto_conn *conn, 46243730Srwatson struct proto_conn *mconn); 47243730Srwatsonint proto_connection_recv(const struct proto_conn *conn, bool client, 48243730Srwatson struct proto_conn **newconnp); 49243730Srwatsonint proto_descriptor(const struct proto_conn *conn); 50243730Srwatsonbool proto_address_match(const struct proto_conn *conn, const char *addr); 51243730Srwatsonvoid proto_local_address(const struct proto_conn *conn, char *addr, 52243730Srwatson size_t size); 53243730Srwatsonvoid proto_remote_address(const struct proto_conn *conn, char *addr, 54243730Srwatson size_t size); 55243730Srwatsonint proto_timeout(const struct proto_conn *conn, int timeout); 56243730Srwatsonvoid proto_close(struct proto_conn *conn); 57243730Srwatsonint proto_exec(int argc, char *argv[]); 58243730Srwatsonint proto_set(const char *name, const char *value); 59243730Srwatsonconst char *proto_get(const char *name); 60243730Srwatson 61243730Srwatson#endif /* !_PROTO_H_ */ 62