133965Sjdp/*- 260484Sobrien * Copyright (c) 2009-2010 The FreeBSD Foundation 360484Sobrien * All rights reserved. 433965Sjdp * 533965Sjdp * This software was developed by Pawel Jakub Dawidek under sponsorship from 633965Sjdp * the FreeBSD Foundation. 733965Sjdp * 833965Sjdp * Redistribution and use in source and binary forms, with or without 933965Sjdp * modification, are permitted provided that the following conditions 1033965Sjdp * are met: 1133965Sjdp * 1. Redistributions of source code must retain the above copyright 1233965Sjdp * notice, this list of conditions and the following disclaimer. 1333965Sjdp * 2. Redistributions in binary form must reproduce the above copyright 1433965Sjdp * notice, this list of conditions and the following disclaimer in the 1533965Sjdp * documentation and/or other materials provided with the distribution. 1633965Sjdp * 1733965Sjdp * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 1833965Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1933965Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2077298Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 2133965Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2233965Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2377298Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2477298Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2577298Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2677298Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2733965Sjdp * SUCH DAMAGE. 2877298Sobrien * 2933965Sjdp * $FreeBSD$ 3033965Sjdp */ 3133965Sjdp 3277298Sobrien#ifndef _PROTO_IMPL_H_ 3333965Sjdp#define _PROTO_IMPL_H_ 3433965Sjdp 3533965Sjdp#include <sys/queue.h> 3633965Sjdp 3733965Sjdp#include <stdbool.h> /* bool */ 3877298Sobrien#include <stdlib.h> /* size_t */ 3933965Sjdp 4033965Sjdp#define __constructor __attribute__((constructor)) 4133965Sjdp 4233965Sjdptypedef int prt_client_t(const char *, const char *, void **); 4333965Sjdptypedef int prt_connect_t(void *, int); 4433965Sjdptypedef int prt_connect_wait_t(void *, int); 4533965Sjdptypedef int prt_server_t(const char *, void **); 4633965Sjdptypedef int prt_accept_t(void *, void **); 4733965Sjdptypedef int prt_wrap_t(int, bool, void **); 4833965Sjdptypedef int prt_send_t(void *, const unsigned char *, size_t, int); 4933965Sjdptypedef int prt_recv_t(void *, unsigned char *, size_t, int *); 5033965Sjdptypedef int prt_descriptor_t(const void *); 5133965Sjdptypedef bool prt_address_match_t(const void *, const char *); 5233965Sjdptypedef void prt_local_address_t(const void *, char *, size_t); 5360484Sobrientypedef void prt_remote_address_t(const void *, char *, size_t); 5460484Sobrientypedef void prt_close_t(void *); 5577298Sobrien 5677298Sobrienstruct proto { 5777298Sobrien const char *prt_name; 5877298Sobrien prt_client_t *prt_client; 5977298Sobrien prt_connect_t *prt_connect; 6077298Sobrien prt_connect_wait_t *prt_connect_wait; 6177298Sobrien prt_server_t *prt_server; 6277298Sobrien prt_accept_t *prt_accept; 6377298Sobrien prt_wrap_t *prt_wrap; 6477298Sobrien prt_send_t *prt_send; 6577298Sobrien prt_recv_t *prt_recv; 6677298Sobrien prt_descriptor_t *prt_descriptor; 6777298Sobrien prt_address_match_t *prt_address_match; 6860484Sobrien prt_local_address_t *prt_local_address; 6960484Sobrien prt_remote_address_t *prt_remote_address; 7077298Sobrien prt_close_t *prt_close; 7133965Sjdp TAILQ_ENTRY(proto) prt_next; 7233965Sjdp}; 7333965Sjdp 7433965Sjdpvoid proto_register(struct proto *proto, bool isdefault); 7533965Sjdp 7633965Sjdpint proto_common_send(int sock, const unsigned char *data, size_t size, int fd); 7733965Sjdpint proto_common_recv(int sock, unsigned char *data, size_t size, int *fdp); 7833965Sjdp 7933965Sjdp#endif /* !_PROTO_IMPL_H_ */ 8033965Sjdp