proto_impl.h revision 219873
197403Sobrien/*- 297403Sobrien * Copyright (c) 2009-2010 The FreeBSD Foundation 3169691Skan * All rights reserved. 4169691Skan * 597403Sobrien * This software was developed by Pawel Jakub Dawidek under sponsorship from 697403Sobrien * the FreeBSD Foundation. 797403Sobrien * 897403Sobrien * Redistribution and use in source and binary forms, with or without 997403Sobrien * modification, are permitted provided that the following conditions 1097403Sobrien * are met: 1197403Sobrien * 1. Redistributions of source code must retain the above copyright 1297403Sobrien * notice, this list of conditions and the following disclaimer. 1397403Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1497403Sobrien * notice, this list of conditions and the following disclaimer in the 1597403Sobrien * documentation and/or other materials provided with the distribution. 1697403Sobrien * 1797403Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 1897403Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19169691Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2097403Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 2197403Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2297403Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2397403Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2497403Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2597403Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2697403Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2797403Sobrien * SUCH DAMAGE. 2897403Sobrien * 2997403Sobrien * $FreeBSD: head/sbin/hastd/proto_impl.h 219873 2011-03-22 16:21:11Z pjd $ 3097403Sobrien */ 31169691Skan 3297403Sobrien#ifndef _PROTO_IMPL_H_ 3397403Sobrien#define _PROTO_IMPL_H_ 3497403Sobrien 3597403Sobrien#include <sys/queue.h> 3697403Sobrien 37169691Skan#include <stdbool.h> /* bool */ 38169691Skan#include <stdlib.h> /* size_t */ 3997403Sobrien 4097403Sobrien#define __constructor __attribute__((constructor)) 41169691Skan 42169691Skantypedef int prt_client_t(const char *, const char *, void **); 43169691Skantypedef int prt_connect_t(void *, int); 44169691Skantypedef int prt_connect_wait_t(void *, int); 45132720Skantypedef int prt_server_t(const char *, void **); 46132720Skantypedef int prt_accept_t(void *, void **); 4797403Sobrientypedef int prt_wrap_t(int, bool, void **); 4897403Sobrientypedef int prt_send_t(void *, const unsigned char *, size_t, int); 4997403Sobrientypedef int prt_recv_t(void *, unsigned char *, size_t, int *); 5097403Sobrientypedef int prt_descriptor_t(const void *); 5197403Sobrientypedef bool prt_address_match_t(const void *, const char *); 5297403Sobrientypedef void prt_local_address_t(const void *, char *, size_t); 5397403Sobrientypedef void prt_remote_address_t(const void *, char *, size_t); 5497403Sobrientypedef void prt_close_t(void *); 5597403Sobrien 5697403Sobrienstruct proto { 5797403Sobrien const char *prt_name; 5897403Sobrien prt_client_t *prt_client; 5997403Sobrien prt_connect_t *prt_connect; 6097403Sobrien prt_connect_wait_t *prt_connect_wait; 6197403Sobrien prt_server_t *prt_server; 6297403Sobrien prt_accept_t *prt_accept; 6397403Sobrien prt_wrap_t *prt_wrap; 6497403Sobrien prt_send_t *prt_send; 6597403Sobrien prt_recv_t *prt_recv; 6697403Sobrien prt_descriptor_t *prt_descriptor; 6797403Sobrien prt_address_match_t *prt_address_match; 68169691Skan prt_local_address_t *prt_local_address; 69169691Skan prt_remote_address_t *prt_remote_address; 7097403Sobrien prt_close_t *prt_close; 7197403Sobrien TAILQ_ENTRY(proto) prt_next; 7297403Sobrien}; 7397403Sobrien 7497403Sobrienvoid proto_register(struct proto *proto, bool isdefault); 7597403Sobrien 7697403Sobrienint proto_common_send(int sock, const unsigned char *data, size_t size, int fd); 7797403Sobrienint proto_common_recv(int sock, unsigned char *data, size_t size, int *fdp); 7897403Sobrien 7997403Sobrien#endif /* !_PROTO_IMPL_H_ */ 8097403Sobrien