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 * $P4: //depot/projects/trustedbsd/openbsm/bin/auditdistd/proto_impl.h#1 $ 30243730Srwatson */ 31243730Srwatson 32243730Srwatson#ifndef _PROTO_IMPL_H_ 33243730Srwatson#define _PROTO_IMPL_H_ 34243730Srwatson 35243730Srwatson#include <sys/queue.h> 36243730Srwatson 37243730Srwatson#include <stdbool.h> /* bool */ 38243730Srwatson#include <stdlib.h> /* size_t */ 39243730Srwatson 40243730Srwatson#define __constructor __attribute__((constructor)) 41243730Srwatson 42243730Srwatsonstruct proto_conn; 43243730Srwatson 44243730Srwatsontypedef int prt_connect_t(const char *, const char *, int, void **); 45243730Srwatsontypedef int prt_connect_wait_t(void *, int); 46243730Srwatsontypedef int prt_server_t(const char *, void **); 47243730Srwatsontypedef int prt_accept_t(void *, void **); 48243730Srwatsontypedef int prt_wrap_t(int, bool, void **); 49243730Srwatsontypedef int prt_send_t(void *, const unsigned char *, size_t, int); 50243730Srwatsontypedef int prt_recv_t(void *, unsigned char *, size_t, int *); 51243730Srwatsontypedef int prt_descriptor_t(const void *); 52243730Srwatsontypedef bool prt_address_match_t(const void *, const char *); 53243730Srwatsontypedef void prt_local_address_t(const void *, char *, size_t); 54243730Srwatsontypedef void prt_remote_address_t(const void *, char *, size_t); 55243730Srwatsontypedef void prt_close_t(void *); 56243730Srwatsontypedef int prt_exec_t(int, char *[]); 57243730Srwatson 58243730Srwatsonstruct proto { 59243730Srwatson const char *prt_name; 60243730Srwatson prt_connect_t *prt_connect; 61243730Srwatson prt_connect_wait_t *prt_connect_wait; 62243730Srwatson prt_server_t *prt_server; 63243730Srwatson prt_accept_t *prt_accept; 64243730Srwatson prt_wrap_t *prt_wrap; 65243730Srwatson prt_send_t *prt_send; 66243730Srwatson prt_recv_t *prt_recv; 67243730Srwatson prt_descriptor_t *prt_descriptor; 68243730Srwatson prt_address_match_t *prt_address_match; 69243730Srwatson prt_local_address_t *prt_local_address; 70243730Srwatson prt_remote_address_t *prt_remote_address; 71243730Srwatson prt_close_t *prt_close; 72243730Srwatson prt_exec_t *prt_exec; 73243730Srwatson TAILQ_ENTRY(proto) prt_next; 74243730Srwatson}; 75243730Srwatson 76243730Srwatsonvoid proto_register(struct proto *proto, bool isdefault); 77243730Srwatson 78243730Srwatsonint proto_wrap(const char *protoname, bool client, int fd, 79243730Srwatson struct proto_conn **newconnp); 80243730Srwatson 81243730Srwatsonint proto_common_send(int sock, const unsigned char *data, size_t size, int fd); 82243730Srwatsonint proto_common_recv(int sock, unsigned char *data, size_t size, int *fdp); 83243730Srwatson 84243730Srwatson#endif /* !_PROTO_IMPL_H_ */ 85